# HG changeset patch # User Julien Cristau # Date 1436195724 -7200 # Node ID 8a2e2efe9362cb9541f018cbb755a59ef93ded0c # Parent 83b87bdefd0e5c724aabbc1f2bf8a9ee6c6d7ac5 [serverctl] fix source-sync command Closes #5491700 diff -r 83b87bdefd0e -r 8a2e2efe9362 server/serverctl.py --- a/server/serverctl.py Tue Jul 07 10:41:34 2015 +0200 +++ b/server/serverctl.py Mon Jul 06 17:15:24 2015 +0200 @@ -980,20 +980,19 @@ ) def run(self, args): + from cubicweb import repoapi from cubicweb.cwctl import init_cmdline_log_threshold config = ServerConfiguration.config_for(args[0]) config.global_set_option('log-file', None) config.log_format = '%(levelname)s %(name)s: %(message)s' init_cmdline_log_threshold(config, self['loglevel']) - # only retrieve cnx to trigger authentication, close it right away - repo, cnx = repo_cnx(config) - cnx.close() + repo = repoapi.get_repository(config=config) try: source = repo.sources_by_uri[args[1]] except KeyError: raise ExecutionError('no source named %r' % args[1]) - session = repo.internal_session() - stats = source.pull_data(session, force=True, raise_on_error=True) + with repo.internal_cnx() as cnx: + stats = source.pull_data(cnx, force=True, raise_on_error=True) for key, val in stats.iteritems(): if val: print key, ':', val