tianyun 2 tahun lalu
induk
melakukan
24aaba2b25
5 mengubah file dengan 100 tambahan dan 19 penghapusan
  1. 1 1
      invoke.py
  2. 23 0
      monitor_ip.py
  3. 18 13
      project-test/util.py
  4. 51 0
      project-test/大树-商机策略/tmp.py
  5. 7 5
      tmp2.py

+ 1 - 1
invoke.py

@@ -7,7 +7,7 @@ def exec(obj):
     return obj
 """
 
-print(requests.post("http://172.18.162.173:8000/exec", json={
+print(requests.post("http://172.18.176.53:8000/exec", json={
     "function_str": cmd_str,
     "call_str": "exec(obj)",
     "param_dict": {

+ 23 - 0
monitor_ip.py

@@ -0,0 +1,23 @@
+import socket
+import time
+
+# 定义要查询的域名和初始IP地址
+hostname = 'c27s3.jamjams.net'
+ip_address = None
+
+while True:
+    # 获取当前的IP地址
+    new_ip_address = socket.gethostbyname(hostname)
+
+    # 判断IP地址是否发生变化
+    if new_ip_address != ip_address:
+        if ip_address is not None:
+            print(f"The IP address for {hostname} has changed: {new_ip_address}")
+        else:
+            print(f"Initial IP address for {hostname}: {new_ip_address}")
+
+        # 更新IP地址
+        ip_address = new_ip_address
+
+    # 等待10秒钟
+    time.sleep(10)

+ 18 - 13
project-test/util.py

@@ -11,26 +11,31 @@ def print_json_plain(obj):
     print(json.dumps(obj, ensure_ascii=False))
 
 
-defaultHeader = {
-    "cookie": "lang=zh-CN; MJSESSIONID=YmQ1YTAyOTktMjBiMy00MmZhLWJmMmUtNjQyODJmYjU0ODM4; satoken-server=d6e42d1a-2372-4746-a032-f5690ff6fbbc"}
+def req(url, json_dict, headers=None):
+    res = requests.post(url, json=json_dict, headers=headers)
+    print_json_pretty(res.json())
+    return res.json()
+
+
+def reqGet(url, params, headers=None):
+    res = requests.get(url, params=params, headers=headers)
+    print_json_pretty(res.json())
+    return res.json()
 
 
-def req(url, json_dict):
-    res = requests.post(url, json=json_dict, headers=defaultHeader)
-    print_json_plain(json_dict)
+def reqForm(url, formData, headers=None):
+    res = requests.post(url, data=formData, headers=headers)
     print_json_pretty(res.json())
     return res.json()
 
 
-def reqGet(url, params):
-    res = requests.get(url, params=params, headers=defaultHeader)
-    # print_json_plain(params)
-    # print_json_pretty(res.json())
+def reqDelete(url, jsonData, headers=None):
+    res = requests.delete(url, json=jsonData, headers=headers)
+    print_json_pretty(res.json())
     return res.json()
 
 
-def reqForm(url, formData):
-    res = requests.post(url, data=formData, headers=defaultHeader)
-    # print_json_plain(formData)
-    # print_json_pretty(res.json())
+def reqPut(url, jsonData, headers=None):
+    res = requests.put(url, json=jsonData, headers=headers)
+    print_json_pretty(res.json())
     return res.json()

+ 51 - 0
project-test/大树-商机策略/tmp.py

@@ -0,0 +1,51 @@
+import unittest
+
+import requests
+
+from util import req, reqGet, reqForm, reqDelete, reqPut
+
+
+def get_token():
+    headers = {
+        'authority': 'edsp.rxdpdev.k5.bigtree.tech',
+        'accept': 'application/json, text/plain, */*',
+        'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
+    }
+
+    json_data = {
+        'username': 'yuyannan',
+        'password': 'Aa123456',
+        'token': True,
+    }
+
+    response = requests.post('https://edsp.rxdpdev.k5.bigtree.tech/api/rxdp-auth-web/auth/login', headers=headers, json=json_data)
+    return response.json()['token']
+
+
+class MyTest(unittest.TestCase):
+
+    def setUp(self) -> None:
+        self.host = "https://gateway.rxdpdev.k5.bigtree.tech/rxdp-tag/rxdp-tag-polymer"
+        # self.host = "http://127.1:8081/rxdp-tag-polymer"
+        self.head = {
+            "Access-Token": get_token()
+        }
+
+    # 分页
+    def test_page(self):
+        reqGet(self.host + "/page?page=1&limit=10", None, self.head)
+
+    # 删除
+    def test_del(self):
+        reqDelete(self.host + "/5", None, self.head)
+
+    # 更新状态
+    def test_update_state(self):
+        reqPut(self.host + "/state?id=6&tagState=1", None, self.head)
+
+    # 上传配置
+    def test_upload(self):
+        with open('/Users/alvin/Downloads/______.json', 'rb') as file:
+            files = {'file': file}
+            response = requests.post(self.host + "/importData", files=files, headers=self.head)
+            print(response.json())

+ 7 - 5
tmp2.py

@@ -1,6 +1,8 @@
-import redis
+import math
 
-r = redis.StrictRedis(host='redis-master.rxdpdev.svc.k5.bigtree.zone', port=6379, db=0, password='SB6vdem')
-r.set('foo', 'bar')
-print(r.get('foo'))
-print(r.keys())
+x = 1
+param = {
+    'large_amount_payment_v4': 6
+}
+a = 590 - 200 * math.log2((1 / (1 + math.exp(1.99530393989402 - 7.7 * x - 0.02 * param['large_amount_payment_v4']))) / ((1 - (1 / (1 + math.exp(1.99530393989402 - 7.7 * x - 0.02 * param['large_amount_payment_v4'])))) * 0.1936))
+print(a)