class foo(Cmd): intro = ''' __ _ _ _ / _(_) ___| | ___ _ _ __| | | |_| |/ __| |/ _ \| | | |/ _` | | _| | (__| | (_) | |_| | (_| | |_| |_|\___|_|\___/ \__,_|\__,_| Cloud that loves your data. ''' def update_prompt(self): if os.path.exists('ficloud.yml'): project = project_name_by_dir() else: project = '~' self.prompt = '(%s:%s) ' % (project, env.host_string or '~') def __init__(self, completekey='tab', stdin=None, stdout=None): self.client = FicloudDeployment() self.client.init(os.getcwd(), 'dev') self.update_prompt() Cmd.__init__(self, completekey, stdin, stdout) def completedefault(self, *ignored): return Cmd.completedefault(self, *ignored) def exec_argparse(self, args): args = arg_parser.parse_args(args=args) args.argv0 = argv[0] if isinstance(args.func, str): getattr(self.client, args.func)(**vars(args)) else: args.func(**vars(args)) def onecmd(self, line): try: # reset project config self.client._project = None if line.strip() != '': args = shlex.split(line.strip()) if args[0] == 'EOF': if confirm('\nCtrl+d. Exit?', True): return True if args[0] in ('docker', 'ls', 'll', 'l', 'git'): os.system(' '.join(args)) else: self.exec_argparse(args) else: arg_parser.print_help() except KeyboardInterrupt as e: print('Ctrl+c. Task interrupted.') except SystemExit as e: pass except Exception as e: print('Error: %s' % str(e)) self.update_prompt()
def get_deployment(self, name, version): deployment = FicloudDeployment() target_dir = self.get_app_deployment_dir(name, version) deployment.init(target_dir, 'prod', '%s0%s' % (name, version)) return deployment