class QuickSyncer(): def __init__(self): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) self.config_parser = QuickSyncConfigParser() self.arg_parser = QuickSyncArgumentParser() def run(self): logging.debug('Starting Sync') args = self.arg_parser.parse_args() self.config_parser.readfp(args.configfile) self.do_sync(self.config_parser.get_folders()) logging.debug('Sync Complete') def do_sync(self, folders): for tup in folders: f, t = tup[0], tup[1] logging.debug('Syncing %s to %s', f, t) cmd = self.build_command(f, t) subprocess.call(cmd, shell=True) logging.debug('-' * 30) def build_command(self, f, t): return RSYNC_CMD % {'FROM': f, 'TO': t, 'OPTIONS': RSYNC_OPTIONS}
def __init__(self): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) self.config_parser = QuickSyncConfigParser() self.arg_parser = QuickSyncArgumentParser()