def upload_base_files(item): '''上传基础文件''' # 执行上传文件操作 print('正在上传相关文件...') file_path = [ ('/Users/afa/my_company_db_info.json', '/root/my_company_db_info.json'), ('/Users/afa/my_username_and_passwd.json', '/root/my_username_and_passwd.json'), ('/Users/afa/myFiles/pwd/horocn_info.json', '/root/horocn_info.json'), ('/Users/afa/myFiles/pwd/zwm_pwd.json', '/root/zwm_pwd.json'), ('/Users/afa/myFiles/tmp/my_spider_logs.zip', '/root/myFiles/my_spider_logs.zip'), ('/Users/afa/myFiles/tmp/my_flask_server.zip', '/root/myFiles/python/my_flask_server.zip'), ('/Users/afa/myFiles/tmp/tri_party_agent_ip_pool.zip', '/root/myFiles/tri_party_agent_ip_pool.zip'), ] for i in file_path: upload_or_download_files(method='put', connect_object=item, local_file_path=i[0], remote_file_path=i[1]) return
def upload_and_replace_settings(item): '''上传替换settings.py''' # 替换原settings.py server_settings_file_path = [ ('/Users/afa/server_settings/{0}/settings.py', '/root/myFiles/python/my_flask_server/settings.py'), # 不进行替换, 已做系统兼容 # ('/Users/afa/server_settings/{0}/tri_ip_pool/settings.py', '/root/myFiles/tri_party_agent_ip_pool/settings.py') ] for e in server_settings_file_path: host_ip = item.host if host_ip == '118.31.39.97': r = (e[0].format(2), e[1]) elif host_ip.startswith('192'): r = (e[0].format(4), e[1]) else: r = (e[0].format(3), e[1]) # print(r) upload_or_download_files(method='put', connect_object=item, local_file_path=r[0], remote_file_path=r[1]) return
def upload_and_replace_settings(item): '''上传替换settings.py''' # 替换原settings.py server_settings_file_path = [ ('/Users/afa/server_settings/{0}/settings.py', '/root/myFiles/python/my_flask_server/settings.py'), ] for e in server_settings_file_path: if re.compile(r'118.31.39.97').findall(item.__repr__()) != []: r = (e[0].format(2), e[1]) else: r = (e[0].format(3), e[1]) upload_or_download_files(method='put', connect_object=item, local_file_path=r[0], remote_file_path=r[1]) return