970 the name of the source to synchronize. |
970 the name of the source to synchronize. |
971 """ |
971 """ |
972 name = 'source-sync' |
972 name = 'source-sync' |
973 arguments = '<instance> <source>' |
973 arguments = '<instance> <source>' |
974 min_args = max_args = 2 |
974 min_args = max_args = 2 |
975 |
975 options = ( |
976 def run(self, args): |
976 ('loglevel', |
|
977 {'short': 'l', 'type' : 'choice', 'metavar': '<log level>', |
|
978 'default': 'info', 'choices': ('debug', 'info', 'warning', 'error'), |
|
979 }), |
|
980 ) |
|
981 |
|
982 def run(self, args): |
|
983 from cubicweb.cwctl import init_cmdline_log_threshold |
977 config = ServerConfiguration.config_for(args[0]) |
984 config = ServerConfiguration.config_for(args[0]) |
978 config.global_set_option('log-file', None) |
985 config.global_set_option('log-file', None) |
979 config.log_format = '%(levelname)s %(name)s: %(message)s' |
986 config.log_format = '%(levelname)s %(name)s: %(message)s' |
980 logger = logging.getLogger('cubicweb.sources') |
987 init_cmdline_log_threshold(config, self['loglevel']) |
981 logger.setLevel(logging.INFO) |
|
982 # only retrieve cnx to trigger authentication, close it right away |
988 # only retrieve cnx to trigger authentication, close it right away |
983 repo, cnx = repo_cnx(config) |
989 repo, cnx = repo_cnx(config) |
984 cnx.close() |
990 cnx.close() |
985 try: |
991 try: |
986 source = repo.sources_by_uri[args[1]] |
992 source = repo.sources_by_uri[args[1]] |