def kadup_cli(self): saved_settings = proc_helpers.get_settings('settings.json') intro_help = """ ==================================================================================================== Welcome to Kadup's command line interface! Commands: * run-backup - Run's rsync based on the settings.json file. If that file is missing info kadup will go through its questionnaire. * print-settings - Will list the contents of your settings.json file. * help - Will print this information again. * exit or quit - Exits the command line interface. ==================================================================================================== """ print(intro_help) while True: command = input('->>>--kadup---> ') if command == 'exit' or command == 'quit': break elif command == 'help': print(intro_help) elif command == 'print-settings': pprint.pprint(saved_settings) elif command == 'run-backup': if saved_settings['Settings']['Questions'] == None: saved_settings = self.cli_questions() if saved_settings['Settings']['Executables'] == None: saved_settings = self.get_executables() self.run_rsync(saved_settings)
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)