isrpa 0.8.7__tar.gz → 0.8.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: isrpa
3
- Version: 0.8.7
3
+ Version: 0.8.8
4
4
  Summary: isrpa package
5
5
  Home-page: https://github.com/yourusername/mypackage
6
6
  Author: ysq
@@ -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"))
@@ -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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: isrpa
3
- Version: 0.8.7
3
+ Version: 0.8.8
4
4
  Summary: isrpa package
5
5
  Home-page: https://github.com/yourusername/mypackage
6
6
  Author: ysq
@@ -4,6 +4,7 @@ isrpa/OCR.py
4
4
  isrpa/Template.py
5
5
  isrpa/Template_Exception.py
6
6
  isrpa/__init__.py
7
+ isrpa/credentials.py
7
8
  isrpa/message.py
8
9
  isrpa/utils.py
9
10
  isrpa.egg-info/PKG-INFO
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='isrpa',
5
- version='0.8.7',
5
+ version='0.8.8',
6
6
  packages=find_packages(),
7
7
  install_requires=["requests", "tldextract"],
8
8
  author='ysq',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes