1074 the name of the source to synchronize. |
1074 the name of the source to synchronize. |
1075 """ |
1075 """ |
1076 name = 'source-sync' |
1076 name = 'source-sync' |
1077 arguments = '<instance> <source>' |
1077 arguments = '<instance> <source>' |
1078 min_args = max_args = 2 |
1078 min_args = max_args = 2 |
1079 |
1079 options = ( |
1080 def run(self, args): |
1080 ('loglevel', |
|
1081 {'short': 'l', 'type' : 'choice', 'metavar': '<log level>', |
|
1082 'default': 'info', 'choices': ('debug', 'info', 'warning', 'error'), |
|
1083 }), |
|
1084 ) |
|
1085 |
|
1086 def run(self, args): |
|
1087 from cubicweb.cwctl import init_cmdline_log_threshold |
1081 config = ServerConfiguration.config_for(args[0]) |
1088 config = ServerConfiguration.config_for(args[0]) |
1082 config.global_set_option('log-file', None) |
1089 config.global_set_option('log-file', None) |
1083 config.log_format = '%(levelname)s %(name)s: %(message)s' |
1090 config.log_format = '%(levelname)s %(name)s: %(message)s' |
1084 logger = logging.getLogger('cubicweb.sources') |
1091 init_cmdline_log_threshold(config, self['loglevel']) |
1085 logger.setLevel(logging.INFO) |
|
1086 # only retrieve cnx to trigger authentication, close it right away |
1092 # only retrieve cnx to trigger authentication, close it right away |
1087 repo, cnx = repo_cnx(config) |
1093 repo, cnx = repo_cnx(config) |
1088 cnx.close() |
1094 cnx.close() |
1089 try: |
1095 try: |
1090 source = repo.sources_by_uri[args[1]] |
1096 source = repo.sources_by_uri[args[1]] |