migration-tools/0024-add-url-processing-function.patch

49 lines
1.3 KiB
Diff
Raw Normal View History

2024-11-05 15:55:39 +08:00
From b627e1aecff4edd096c4ce6cc04486adc04fe89e Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Fri, 10 Nov 2023 10:44:12 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0url=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
interaction.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 interaction.py
diff --git a/interaction.py b/interaction.py
new file mode 100644
index 0000000..e4016ab
--- /dev/null
+++ b/interaction.py
@@ -0,0 +1,25 @@
+import requests
+import json
+from sysmig_agent.share import getSysMigConf
+
+headers = {'content-type': 'application/json'}
+
+class Interaction:
+ def __init__(self, url, data):
+ self.url = url
+ self.data = data
+
+ def send_post_requests(self):
+ try:
+ r = requests.post(url=self.url, data=self.data, headers=headers, timeout=10)
+ except:
+ r = None
+ return r
+
+
+def splice_url(data, url, ip):
+ uos_sysmig_conf = json.loads(getSysMigConf(ip))
+ port = json.loads(uos_sysmig_conf).get('agentport').strip()[1:-1]
+ post_url = "http://" + ip + ":" + port + url
+ data = Interaction(post_url, data)
+ return data.send_post_requests()
\ No newline at end of file
--
2.20.1