def gen_build_metainfo(argv, prog='octopus'): argparser = argparse.ArgumentParser( description="octopus gen_build_metainfo", prog=prog) argparser.add_argument('--build-no', dest='build_no', help='build', type=int, default=0) args = argparser.parse_args(argv) CITool.gen_build_metainfo('./', args.build_no)
def get_program(args): """ 获取程序 """ build_no = args.build_no path = args.program citool = CITool() path = citool.get_program(program, build_no) local('cp -r path ./' + program)
def install_depends(argv, prog): """ 安装程序需要的依赖(假定是在当前目录下获取octopus.prj,用处是帮助在本地搭建环境) """ argparser = argparse.ArgumentParser(description="octopus install_depends", prog=prog) argparser.add_argument('-c', '--conf', dest='config_file', help='octopus配置文件路径, 寻找优先级为./octopus.conf > ~/.octopus/octopus.conf') argparser.add_argument('-t', '--type', dest='type',default='all', help='要安装的依赖类型,取值为compile, runtime, all') args = argparser.parse_args(argv) config_file = get_config_file(args.config_file) print 'use config ' + config_file if config_file is None: print "please specift config file" return 1 if args.type != 'compile' and args.type != 'runtime' and args.type != 'all': print 'wrong type, must be [compile, runtime, all]' return 1 citool = CITool(config_file) program_path = '.' program_info = ProgramInfo(program_path) citool.install_depends(program_info.get_depends(), args.type)
def deploy(argv, prog='octopus'): argparser = argparse.ArgumentParser(description="octopus deploy", prog=prog) argparser.add_argument('-c', '--conf', dest='config_file', help='octopus配置文件路径, 寻找优先级为./octopus.conf > ~/.octopus/octopus.conf') argparser.add_argument('--build-no', dest='build_no', help='build', type=int, default=0) argparser.add_argument( '--program', dest='program', help='要部署的程序') argparser.add_argument( '--env', dest='env', help='部署环境', default='test') args = argparser.parse_args(argv) config_file = get_config_file(args.config_file) if config_file is None: print "please specift config file" return 1 citool = CITool(config_file) # 如果指定了program ,先下载program. program_path = '.' if args.program: program_path = citool.get_program(args.program, args.build_no) program_path = os.path.abspath(program_path) print 'start deploy ' + program_path + ', env=' + args.env citool.deploy(program_path, args.env)