-
Notifications
You must be signed in to change notification settings - Fork 0
/
ty2.py
69 lines (60 loc) · 2.09 KB
/
ty2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import json
import os
import time
import requests
from requests_toolbelt import MultipartEncoder
datanames = os.getcwd()
datanames2 = os.listdir(datanames)
os.mkdir("./output")
pt="./output"
SCKEY = os.environ["SCKEY"]
SCKEY2 = os.environ["SCKEY2"]
URLKEY = os.environ["URLKEY"]
def bulid():
id=''
for dataname in datanames2:
wenjiandizhi2=dataname
print("遍历文件夹")
if os.path.splitext(dataname)[1] == '.ISO': # 目录下包含.json的文件
print("没有manifest文件。。")
print("else-os.getcwd()。。"+str(os.getcwd()))
print("else-os.listdir(datanames)。。"+str(os.listdir(datanames)))
os.system('ls')
os.system('pwd')
url = URLKEY
# files = {'file': open(dizhi, 'rb')} #
# data = {
# "name": "ISO.ISO",
# "puid": SCKEY,
# "_token": SCKEY2,
# }
# r = requests.post(url, files=files, data=data, timeout=120)
m = MultipartEncoder(
fields={'name': dataname, 'puid': SCKEY,'_token': SCKEY2,
'file': (dataname, open(wenjiandizhi2, 'rb'))}
)
time.sleep(6)
headers = {
"Content-Type": m.content_type,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.63",
"Connection": 'close'
}
r = requests.post(url, data=m,
headers=headers, timeout=(7,12))
time.sleep(6)
res=r.text
# print(res)
jsonobj = json.loads(res)
msg=jsonobj['msg']
print(msg)
toCntPercent = jsonobj['objectId']
id=toCntPercent
with open('id.txt', 'a') as f:
f.write('\n')
f.write(toCntPercent)
print(toCntPercent)
else:
print("没文件")
return id
if __name__ == '__main__':
bulid()