添加2001 b_N上传方法
This commit is contained in:
parent
b02c12831c
commit
a87c754d5d
@ -17,22 +17,13 @@ class SS_Virtual_command:
|
||||
def __init__(self):
|
||||
self.ss_virtual_url = "http://10.10.3.14:8993/v1/ta/meta/prop/virtual/dict/create"
|
||||
self.method = "post"
|
||||
self.loginName = "root"
|
||||
self.password = "kingsome2016"
|
||||
|
||||
|
||||
def upload_gameid(self, filename):
|
||||
|
||||
projectId = int(19)
|
||||
createParam = {"commonHeader": {"projectId": 19},
|
||||
"mainColumn": {"property": {"columnName": "gameid", "tableType": 0}},
|
||||
"columns": [{"property": {"columnName": "gameid", "columnDesc": "主键ID", "selectType": "number"}},
|
||||
{"property": {"columnName": "gameid_china", "columnDesc": "china映射", "selectType": "string"}}]}
|
||||
loginName = "root"
|
||||
password = "kingsome2016"
|
||||
body = {"projectId": projectId, "createParam": createParam, "loginName": loginName, "password": password}
|
||||
quote_body = my_quote(body)
|
||||
|
||||
cmd = f"curl --header 'Accept: application/json' --form 'file=@{filename}' '{self.ss_virtual_url}?{quote_body}'"
|
||||
print(cmd)
|
||||
def run_cmd(cmd):
|
||||
import subprocess
|
||||
msg = "Starting run: %s " % cmd
|
||||
print("run_cmd {0}".format(msg))
|
||||
cmdref = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
output, error_info = cmdref.communicate()
|
||||
if cmdref.returncode != 0:
|
||||
@ -45,22 +36,52 @@ class SS_Virtual_command:
|
||||
print(f"Run Success,output was {output}")
|
||||
return True
|
||||
|
||||
# r = requests.post(url=self.ss_virtual_url, header="Accept: application/json", files=filename, data=quote_body)
|
||||
# if r.status_code == requests.codes.ok:
|
||||
# print(f"upload success,return={r.content}")
|
||||
# return True
|
||||
# else:
|
||||
# print(f"upload failed,return={r.content}")
|
||||
# return False
|
||||
|
||||
def upload_gameid(self):
|
||||
filename = "/data/git/ops_interface/ops/csv/gameid.csv"
|
||||
projectId = int(19)
|
||||
createParam = {"commonHeader": {"projectId": 19},
|
||||
"mainColumn": {"property": {"columnName": "gameid", "tableType": 0}},
|
||||
"columns": [{"property": {"columnName": "gameid", "columnDesc": "主键ID", "selectType": "number"}},
|
||||
{"property": {"columnName": "gameid_china", "columnDesc": "china映射", "selectType": "string"}}]}
|
||||
|
||||
body = {"projectId": projectId, "createParam": createParam, "loginName": self.loginName,
|
||||
"password": self.password}
|
||||
quote_body = my_quote(body)
|
||||
|
||||
cmd = f"curl --header 'Accept: application/json' --form 'file=@{filename}' '{self.ss_virtual_url}?{quote_body}'"
|
||||
print(cmd)
|
||||
if self.run_cmd(cmd):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def upload_2001_b_n(self):
|
||||
filename = "/data/git/ops_interface/ops/csv/2001_b_n.csv"
|
||||
projectId = int(21)
|
||||
createParam = {"commonHeader": {"projectId": 21},
|
||||
"mainColumn": {"property": {"columnName": "#vp@b_n", "tableType": 0, "subTableType": "vprop_sql"}},
|
||||
"columns": [{"property": {"columnName": "b_n", "columnDesc": "跳转appid", "selectType": "string"}},
|
||||
{"property": {"columnName": "b_n_china", "columnDesc": "跳转中文名", "selectType": "string"}}]}
|
||||
|
||||
body = {"projectId": projectId, "createParam": createParam, "loginName": self.loginName,
|
||||
"password": self.password}
|
||||
quote_body = my_quote(body)
|
||||
|
||||
cmd = f"curl --header 'Accept: application/json' --form 'file=@{filename}' '{self.ss_virtual_url}?{quote_body}'"
|
||||
print(cmd)
|
||||
if self.run_cmd(cmd):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
raise Exception("PLS input filename which need upload!")
|
||||
|
||||
filename = sys.argv[1]
|
||||
ss = SS_Virtual_command()
|
||||
ss.upload_gameid(filename)
|
||||
# ss.upload_gameid()
|
||||
ss.upload_2001_b_n()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user