generated from root/miduo_client
81 lines
2.5 KiB
Python
81 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
import base64
|
|
import hashlib
|
|
import requests
|
|
import subprocess
|
|
import urllib3
|
|
import logging
|
|
import time
|
|
import random
|
|
import argparse
|
|
import json
|
|
from threading import Thread, current_thread
|
|
from concurrent.futures import ProcessPoolExecutor
|
|
|
|
|
|
class Local12_Upload():
|
|
linuxDir = "data/public/samba/public/jieling_dl/dev/assetBundles"
|
|
settingFile = "Setting.txt"
|
|
configFile = "config.txt"
|
|
versionFile = "version.txt"
|
|
|
|
|
|
def __init__(self, abDir, settingDir, changeVersion):
|
|
|
|
self.fileList = []
|
|
self.ab_dir = abDir
|
|
self.setting_dir = self.ab_dir + "/" + settingDir
|
|
self.change_version = changeVersion
|
|
self.change_file = self.setting_dir + "/__HotFixLog/" + changeVersion + ".log"
|
|
self.loadSetting()
|
|
self.user = "root"
|
|
self.pwd = "root.ljsd.COM@"
|
|
|
|
def loadSetting(self):
|
|
settingContent = open(self.setting_dir +"/"+ Local12_Upload.settingFile, "rb")
|
|
settingJson = json.load(settingContent)
|
|
self.linux_sub_dir = settingJson["dir"]
|
|
self.platform = settingJson["platform"]
|
|
|
|
def get_all_file(self):
|
|
print(self.change_file)
|
|
fo = open(self.change_file, "r")
|
|
files = fo.readlines()
|
|
for f in files:
|
|
file = f.strip()
|
|
self.fileList.append(file)
|
|
return self.fileList
|
|
|
|
|
|
def upload_file_to_local12(self, path, file):
|
|
local_file_path = path + file
|
|
local_file_path = local_file_path.replace("\\", "/").lstrip("/")
|
|
print(local_file_path)
|
|
command = "pscp -pw {6} {0} {1}@60.1.1.12:/{2}/{3}/{4}/{5}>>{7}".format(local_file_path, self.user, Local12_Upload.linuxDir, self.linux_sub_dir, self.platform, file, self.pwd, self.change_file)
|
|
# print(command)
|
|
subprocess.call(command, shell=True)
|
|
|
|
def up(self):
|
|
filelist = self.get_all_file()
|
|
pool = ProcessPoolExecutor(4)
|
|
for file in filelist:
|
|
self.upload_file_to_local12(self.ab_dir + "/" + self.platform + "/", file)
|
|
|
|
self.upload_file_to_local12(self.setting_dir +"/", Local12_Upload.configFile)
|
|
self.upload_file_to_local12(self.setting_dir +"/", Local12_Upload.versionFile)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if sys.argv.__len__() == 4:
|
|
t = Local12_Upload(sys.argv[1], sys.argv[2], sys.argv[3])
|
|
t.up()
|
|
else:
|
|
print("params error!")
|
|
|
|
# z = Local12_Upload("D:/HotFix/Root/mht_china/local", "D:/HotFix/Root/mht_china/local/cdn_v2", 'version_1')
|
|
# z.up()
|