def dist_create(self): """ 创建发布目录 """ _ssh.mkdir(DIST_PATH) _ssh.mkdir(BIN_PATH) _ssh.rm(ENV_PATH) create_cmd = 'virtualenv --no-site-packages --python=python2.7 %s' _ssh.run(create_cmd % ENV_PATH)
def up_svr(self): """ 更新服务器代码 """ self.up_svn_info() corelib = ('lib', 'corelib') _corelib_pyx = corelib + ('_corelib.pyx', ) #编译pyx _tool.cython(path.join(svr_path, *_corelib_pyx)) # _tool.compile_pyc(svr_path) rpath = GAME_PATH if _ssh.exists(rpath): _ssh.rm(rpath) _ssh.mkdir(rpath) _ssh.mkdir(PUB_PATH) exclude = ('.hg/', '.svn/', 'pkg/', 'runtime/', '*.py', '*.log', '*.profile', '*.pyx', '*/build/', '*.so', '*.pyd', '.*', 'dist/', '**local_config.pyc', '*.rar') _ssh.rsync_project(local_dir=path.join(svr_path, '*'), remote_dir=rpath+'/', delete=True, exclude=exclude, extra_opts='--delete-excluded') with _ssh.cd(DIST_PATH): #编译 with _ssh.cd(_ssh.join(DIST_PATH, 'svr', *corelib)): _ssh.run('%s setup.pyc build_ext --inplace' % PY_BIN) # 打包 _ssh.run('tar -czf %s/%s ./%s ./%s' % (pub_name, lastest_file, env_name, svr_name)) #备份处理 _ssh.run('cp %s/%s %s/%s%s' % (pub_name, lastest_file, pub_name, lastest_back_prefix, _tool.strftime()))
def pkg_down(self): """ py模块下载 """ down_cmd = 'pip install --no-install -d %s %s' _ssh.mkdir(MODULES_FOLDER) for m in self.PY_PKGS: _ssh.run(down_cmd % (MODULES_FOLDER, m)) for m in self.WEB_PY_PKGS: _ssh.run(down_cmd % (MODULES_FOLDER, m))
def update_svr(self, ver=None): """ 上传新的服务端压缩包 """ _ssh.mkdir(PUB_PATH) _ssh.mkdir(CFG_PATH) if ver: name = '%s%s' % (lastest_back_prefix, ver) else: name = lastest_file with _ssh.cd(PUB_PATH): _ssh.rm(lastest_file) _ssh.put('config/%s' % cfg_config, _ssh.join(CFG_PATH, cfg_config)) _ssh.put('%s/%s' % (pub_name, name), _ssh.join(PUB_PATH, lastest_file)) _ssh.rm(env_name) _ssh.rm(svr_name) _ssh.run('tar -xzf %s' % lastest_file)
def up_cfg(self): """ 更新全局配置 """ _ssh.mkdir(CFG_PATH) cfg_local = path.join(dist_path, 'config', '*') _ssh.put(cfg_local, CFG_PATH)