def main(): try: settings = proc_helpers.get_settings('settings.json') BACKUP_OBJECTS_DICT = { 'Windows': backup_models.WindowsBackup(settings), 'Darwin': backup_models.UnixBackup(settings), 'Linux': backup_models.UnixBackup(settings) } if settings == None: main() else: operating_system = settings['Settings']['Operating_System'] backup_object = BACKUP_OBJECTS_DICT[operating_system] help_text = "To start the Kadup CLI simply run: $ python3 kadup.py -c run" arg_parser = ArgumentParser() arg_parser.add_argument('-c', dest='cli', help=help_text, default=None) if arg_parser.parse_args().cli == 'run': backup_object.kadup_cli() else: backup_object.run_backup() return None except Exception as error: print('Kadup has encountered an error. Please check kadup.log.') proc_helpers.make_log('exception', error)
def run_rsync(self, runtime_settings): command_parameters = { 'rsync_path': runtime_settings['Settings']['Executables']['rsync'], 'backup_path': self.make_unix_pathname\ (runtime_settings['Settings']['Questions']['backup_dir']), 'dest_path': self.make_unix_pathname\ (runtime_settings['Settings']['Questions']['dest_dir']) } command = self.rsync_command(command_parameters['rsync_path'], command_parameters['backup_path'], command_parameters['dest_path']) run_command = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,\ universal_newlines=True, shell=True) proc_helpers.make_log('info', run_command.stdout.read()) return None