class syncCommand(CementCommand): config = namespaces['mirror'].config def __init__(self, *args): CementCommand.__init__(self, *args) self.proxy = RHNSatelliteProxy() if self.cli_opts.user: self.proxy.get_session(use_cache=False) def mirror_channel(self, channel, path): local_dir = re.sub('\%\(mirror_dir\)', self.config['mirror_dir'], path) chan = RHNSatelliteChannel(label=channel, local_dir=local_dir) log.info("mirroring of %s started" % chan.label) try: chan.sync(verify=self.cli_opts.verify) except RuntimeError, e: log.error("RuntimeError => %s", e) sys.exit(1) except KeyboardInterrupt, e: log.warn('Caught KeyboardInterrupt => Attempting to exit clean...') # remove the last file attempted if len(chan.attempted_files) > 0: last_path = os.path.join( chan.local_dir, chan.attempted_files[-1]) if os.path.exists(last_path): log.debug('cleanup: removing last attempted file %s' \ % last_path) os.remove(last_path) chan._remove_lock() sys.exit(1)
def run(self): """ Takes an API path (i.e. auth.login) and args (i.e username) and attempts to make a call to the RHN Proxy. Useful for development. """ cmd = self.cli_args.pop(0) path = self.cli_args.pop(0) args = self.cli_args proxy = RHNSatelliteProxy() if self.cli_opts.user: proxy.get_session(use_cache=False) else: proxy.get_session() try: res = proxy.call(path, *args) except xmlrpclib.Fault, e: res = proxy.noauth_call(path, *args)