def rollback(vhost_path): """ Updates symlinks: Remove current instance and rename previous to current """ with cd(vhost_path): if exists('./previous_instance'): commands.delete('./current_instance') commands.rename('./previous_instance', './current_instance')
def parse(commands): _command = commands[0] if _command == 'help': # Done command.help() elif _command == 'add': # Done command.add(commands[1:]) elif _command == 'display': # All done # TODO: Date # sort [date|cost] command.display() elif _command == 'delete': # Done command.delete(commands[1]) elif _command == 'find': # TODO if len(commands) == 1: print('please enter criteria') return True command.find(commands[1:]) elif _command == 'clear': command.clear() elif _command == 'quit': # Done command.quit() return False return True
def _main(args, config, timesheet): if args['add']: add(args, config, timesheet) if args['show']: show(args, timesheet) if args['reauth']: reauth(config) if args['delete']: delete(args, timesheet)
def run(self): if self.args.c: commands.check(app=self, input_str=":c {0}".format(self.args.c)) if self.args.d: commands.delete(app=self, input_str=":d {0}".format(self.args.d)) if self.args.clear: commands.clear(app=self) print str(self.list),
def set_current_instance(vhost_path, instance_path): """ Delete previous, set current to previous and new to current """ with cd(vhost_path): commands.delete('./previous_instance') if exists('./current_instance'): commands.rename('./current_instance', './previous_instance') commands.create_symbolic_link(instance_path, './current_instance')
def prune_obsolete_instances(): """ Find old instances and remove them to free up space """ removed_instances = [] for instance in get_obsolete_instances(env.vhost_path): is_current = bool(get_instance_stamp(env.current_instance_path) == instance) is_previous = bool(get_instance_stamp(env.previous_instance_path) == instance) if not (is_current or is_previous): commands.delete(os.path.join(env.vhost_path, instance)) removed_instances.append(instance) if removed_instances: print(green('\nThese old instances were removed from remote filesystem:')) print(removed_instances)
def delete(self, query): id_ = query["id_"] try: del_file = cmd.delete(self.es, id_) return { "success": True, "file": del_file } except IndexError as e: return { "success": False }
def run_agent_mode(): """ Prompt the user for commands and listen for the response. Commands are run with agent parameters and limitations. When the "logout" command is given, this function returns. """ print 'Logged in as agent' records = [] deleted_accounts = [] while True: line = inputOutput.prompt_for_input().lower() if line == 'logout': inputOutput.write_summary_file(records, sys.argv[2]) print 'Logged out' return elif line == 'transfer': tmp_transfer = commands.transfer(True) if (validation.validate_deleted(tmp_transfer[1], deleted_accounts) or validation.validate_deleted(tmp_transfer[2], deleted_accounts)): records.append(tmp_transfer) print 'Transfer successful' else: print 'Error: Account does not exist' elif line == 'withdraw': tmp_withdraw = commands.withdraw(True, {}) if validation.validate_deleted(tmp_withdraw[1], deleted_accounts): records.append(tmp_withdraw) print 'Withdraw successful' else: print 'Error: Account does not exist' elif line == 'deposit': tmp_deposit = commands.deposit(True) if validation.validate_deleted(tmp_deposit[1], deleted_accounts): records.append(tmp_deposit) print 'Deposit successful' else: print 'Error: Account does not exist' elif line == 'create': records.append(commands.create()) elif line == 'delete': tmp_delete = commands.delete() records.append(tmp_delete) deleted_accounts.append(tmp_delete[1]) else: print 'Error: command not recognized'
from commands import delete delete("parts", "part_id", 6)