isrpa 0.8.7__py3-none-any.whl → 0.8.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isrpa/credentials.py +99 -0
- isrpa/utils.py +0 -8
- {isrpa-0.8.7.dist-info → isrpa-0.8.8.dist-info}/METADATA +1 -1
- {isrpa-0.8.7.dist-info → isrpa-0.8.8.dist-info}/RECORD +6 -5
- {isrpa-0.8.7.dist-info → isrpa-0.8.8.dist-info}/WHEEL +0 -0
- {isrpa-0.8.7.dist-info → isrpa-0.8.8.dist-info}/top_level.txt +0 -0
isrpa/credentials.py
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
import requests
|
4
|
+
|
5
|
+
|
6
|
+
def store_key(key_name,key_value,user_name):
|
7
|
+
"""
|
8
|
+
用户凭证存储
|
9
|
+
key_name:凭证key
|
10
|
+
key_value:凭证value
|
11
|
+
user_name:用户名
|
12
|
+
|
13
|
+
"""
|
14
|
+
address = os.environ.get("address", "192.168.12.249")
|
15
|
+
url = f"http://{address}/console/api/user_credentials"
|
16
|
+
print(url)
|
17
|
+
headers = {
|
18
|
+
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
19
|
+
}
|
20
|
+
# 请求体的数据
|
21
|
+
data = {
|
22
|
+
'certificate_key': key_name,
|
23
|
+
'certificate_value': key_value,
|
24
|
+
'user_name': user_name
|
25
|
+
}
|
26
|
+
print(data)
|
27
|
+
requests.post(url, headers=headers, json=data)
|
28
|
+
|
29
|
+
def get_key(key_name, user_name):
|
30
|
+
"""
|
31
|
+
获取用户凭证
|
32
|
+
key_name:凭证key
|
33
|
+
user_name:用户名称
|
34
|
+
"""
|
35
|
+
address = os.environ.get("address", "192.168.12.249")
|
36
|
+
url = f"http://{address}/console/api/user_credentials?certificate_key={key_name}&user_name={user_name}"
|
37
|
+
print(url)
|
38
|
+
response = requests.get(url)
|
39
|
+
if response.status_code != 200:
|
40
|
+
print("请求失败,状态码:", response.status_code)
|
41
|
+
return "failure"
|
42
|
+
json = response.json()
|
43
|
+
|
44
|
+
return json['certificate_value']
|
45
|
+
|
46
|
+
def delete_key(key_name,user_name):
|
47
|
+
"""
|
48
|
+
删除凭证
|
49
|
+
key_name:凭证key
|
50
|
+
user_name:用户名称
|
51
|
+
"""
|
52
|
+
address = os.environ.get("address", "192.168.12.249")
|
53
|
+
url = f"http://{address}/console/api/user_credentials"
|
54
|
+
print(url)
|
55
|
+
headers = {
|
56
|
+
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
57
|
+
}
|
58
|
+
# 请求体的数据
|
59
|
+
data = {
|
60
|
+
'certificate_key': key_name,
|
61
|
+
'user_name': user_name
|
62
|
+
}
|
63
|
+
print(data)
|
64
|
+
requests.delete(url, headers=headers, json=data)
|
65
|
+
|
66
|
+
def list(user_name):
|
67
|
+
"""
|
68
|
+
获取所有凭证key
|
69
|
+
user_name:用户名称
|
70
|
+
"""
|
71
|
+
address = os.environ.get("address", "192.168.12.249")
|
72
|
+
url = f"http://{address}/console/api/user_credentials/list?user_name={user_name}"
|
73
|
+
print(url)
|
74
|
+
response = requests.get(url)
|
75
|
+
if response.status_code != 200:
|
76
|
+
print("请求失败,状态码:", response.status_code)
|
77
|
+
return "failure"
|
78
|
+
json = response.json()
|
79
|
+
|
80
|
+
return json
|
81
|
+
|
82
|
+
def exist(key_name, user_name):
|
83
|
+
"""
|
84
|
+
获取用户凭证
|
85
|
+
key_name:凭证key
|
86
|
+
user_name:用户名称
|
87
|
+
"""
|
88
|
+
address = os.environ.get("address", "192.168.12.249")
|
89
|
+
url = f"http://{address}/console/api/user_credentials?certificate_key={key_name}&user_name={user_name}"
|
90
|
+
print(url)
|
91
|
+
response = requests.get(url)
|
92
|
+
if response.status_code != 200:
|
93
|
+
return False
|
94
|
+
|
95
|
+
|
96
|
+
return True
|
97
|
+
|
98
|
+
if __name__ == '__main__':
|
99
|
+
print(exist("ccc","zhouly@i-search.com.cn"))
|
isrpa/utils.py
CHANGED
@@ -102,14 +102,6 @@ def save_file(url, cookies, file_path):
|
|
102
102
|
for item in cookies:
|
103
103
|
if top_level_domain in item.get("domain"):
|
104
104
|
cookie[item["name"]] = item["value"]
|
105
|
-
print("------top_level_domain------")
|
106
|
-
print(top_level_domain)
|
107
|
-
print("------raw cookies------")
|
108
|
-
print(cookies)
|
109
|
-
print("------cookie-----")
|
110
|
-
print(cookie)
|
111
|
-
print("------url-----")
|
112
|
-
print(url)
|
113
105
|
response = requests.get(url, cookies=cookie)
|
114
106
|
with open(file_path, 'wb') as file:
|
115
107
|
file.write(response.content)
|
@@ -2,9 +2,10 @@ isrpa/OCR.py,sha256=nSDmVLo_z9GV7GUY57xBh2kumERG5_xtpUPxeF6ziQE,2509
|
|
2
2
|
isrpa/Template.py,sha256=UP1uovLvJzXEPGo_hzLrIYOu3vZP8Cf6m3G2hGzQ6XA,1958
|
3
3
|
isrpa/Template_Exception.py,sha256=an6eQ1NMB8a9R-J0yyMdwHIZcZeDtdV5f7fWKZQsZ3s,819
|
4
4
|
isrpa/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
|
5
|
+
isrpa/credentials.py,sha256=4yIETA7XJOFZpMz7XWo8cRYtbUMHPEJqPDvmZgfOR18,2808
|
5
6
|
isrpa/message.py,sha256=N0s6hMaC5S-Pi4EhwcSp-ngfBTBQyW6ymU9sI9dUSeE,11329
|
6
|
-
isrpa/utils.py,sha256=
|
7
|
-
isrpa-0.8.
|
8
|
-
isrpa-0.8.
|
9
|
-
isrpa-0.8.
|
10
|
-
isrpa-0.8.
|
7
|
+
isrpa/utils.py,sha256=o4n_9NwhT-aqed5Bo3TokGBmpeXc3WhmlOjnHSa8N8M,51342
|
8
|
+
isrpa-0.8.8.dist-info/METADATA,sha256=LmZABjeu_Ctv7CzaBVgz1ZgE1A4_Ho6aHxlYmTMDZZk,511
|
9
|
+
isrpa-0.8.8.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
10
|
+
isrpa-0.8.8.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
|
11
|
+
isrpa-0.8.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|