sc-common-interface 2.9.7__tar.gz → 2.9.9__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.
Files changed (18) hide show
  1. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/PKG-INFO +1 -1
  2. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface/CommonOa.py +3 -2
  3. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface/LiveCommonInterface.py +64 -20
  4. sc_common_interface-2.9.9/sc_common_interface/OperaMysql.py +196 -0
  5. sc_common_interface-2.9.9/sc_common_interface/OperaRedis.py +43 -0
  6. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface/PostCommonInterface.py +0 -7
  7. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface/ScWebsocket.py +57 -33
  8. sc_common_interface-2.9.9/sc_common_interface/__init__.py +0 -0
  9. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/PKG-INFO +1 -1
  10. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/SOURCES.txt +3 -1
  11. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/requires.txt +1 -0
  12. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/setup.py +3 -2
  13. sc_common_interface-2.9.7/sc_common_interface/Platform.py +0 -7
  14. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface/McCommonInterface.py +0 -0
  15. /sc_common_interface-2.9.7/sc_common_interface/__init__.py → /sc_common_interface-2.9.9/sc_common_interface/ScPulsar.py +0 -0
  16. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/dependency_links.txt +0 -0
  17. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/top_level.txt +0 -0
  18. {sc_common_interface-2.9.7 → sc_common_interface-2.9.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc_common_interface
3
- Version: 2.9.7
3
+ Version: 2.9.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -69,15 +69,16 @@ def get_product(data):
69
69
  res = requests.get(url, headers=oa_headers).json()
70
70
  return res
71
71
 
72
-
73
72
  def edit_product_spu(data):
74
- """"编辑商品名称、隐藏价格、限购数量、预售时间,spu维度的编辑
73
+ """"
74
+ 编辑商品名称、隐藏价格、限购数量、预售时间,spu维度的编辑
75
75
  hide_price:false true
76
76
  隐藏商品/下架商品[status]: hidden、active、draft
77
77
  限购数量【max_order_quantity】:-1【不限购】
78
78
  商品名称格式:
79
79
  {'vi': '商品名称1734667300--多规格---编辑', 'th': '商品名称1734667300', 'zh-hant': '商品名称1734667300---编辑繁体', 'en': '商品名称1734667300-----编辑英文', 'id': '商品名称1734624132',
80
80
  'fr': '商品名称1734624132', 'zh-cn': '商品名称1734667300----多篇规格简体中文'}
81
+
81
82
  available_start_time 预购开始时间:格式:"2024-12-25T15:00:00.000+00:00"
82
83
  available_end_time 预购结束时间:用不过期为null
83
84
  ------无规格商品编辑商品预购库存、无限库存-------
@@ -8,6 +8,7 @@ import random
8
8
  import hmac
9
9
  from hashlib import sha1
10
10
  import random
11
+ import json,hashlib,hmac
11
12
 
12
13
 
13
14
  def delete_post(data):
@@ -18,7 +19,6 @@ def delete_post(data):
18
19
  res = requests.delete(url, headers=headers).json()
19
20
  return res
20
21
 
21
-
22
22
  def delete_relate_post(data):
23
23
  """删除串接的facebook或fb group 避免影响串接"""
24
24
  env = data["env"]
@@ -92,9 +92,6 @@ def delete_relate_post(data):
92
92
  if count>=len(id_list):
93
93
  return res
94
94
 
95
-
96
-
97
-
98
95
  def get_sales_id(data):
99
96
  """"查询返回指定直播间的salse_id
100
97
  status:准备中 0,直播中 1 已结束 2 断线中 4
@@ -143,16 +140,15 @@ def get_sales_id(data):
143
140
  else:
144
141
  return sales_id, response
145
142
 
146
-
147
143
  def create_activity(data):
148
144
  env = data["env"]
149
145
  headers = data["headers"]
150
146
  body = data["body"]
151
147
  sales_id = data["sales_id"]
152
148
  url = "%s/admin/api/bff-web/live/activity/%s"%(env,sales_id)
153
- platform = "FACEBOOK"
154
- if "platform" in data:
155
- platform = data["platform"].upper()
149
+ # platform = "FACEBOOK"
150
+ # if "platform" in data:
151
+ # platform = data["platform"].upper()
156
152
  response = requests.post(url,headers=headers,json=body)
157
153
  # print(response.json())
158
154
  if response.status_code==200:
@@ -222,7 +218,6 @@ def get_page_info(data):
222
218
  page_info["permalink_url"] = permalink_url
223
219
  return page_info
224
220
 
225
-
226
221
  def send__live_comment(data):
227
222
  env = data["env"]
228
223
  key = data["key"]
@@ -234,7 +229,6 @@ def send__live_comment(data):
234
229
  num = random.randint(100000, 999999)
235
230
  user_id = "488864%d" % int(time.time())
236
231
  name = "test live%d" % int(time.time())
237
-
238
232
  keyword = "接口测试普通留言"
239
233
  user_id = data.get("user_id", user_id)
240
234
  name = data.get("name", name)
@@ -278,8 +272,7 @@ def send__live_comment(data):
278
272
  body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
279
273
  "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
280
274
  "verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
281
-
282
- print(body)
275
+ # print(body)
283
276
  url = "%s/facebook/webhook" % env
284
277
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
285
278
  signData = sign_text.hexdigest()
@@ -342,6 +335,23 @@ def send_mc_message(data):
342
335
  # print(body)
343
336
  return user_id, name
344
337
 
338
+ def send_sl_comment(data):
339
+ env = data["env"]
340
+ headers = data["headers"]
341
+ sales_id = data["sales_id"]
342
+ url = "%s/api/posts/live/viewer/%s/send/comments"%(env,sales_id)
343
+ content = data.get("content","sl留言")
344
+ headers["content-type"] = "application/json"
345
+ body = {
346
+ "content": content
347
+ }
348
+ response = requests.post(url,headers=headers,json=body).json()
349
+ if response["code"]=="SUCCESS":
350
+ comment_id = response["data"]["comment_id"]
351
+ return comment_id
352
+ return response
353
+
354
+
345
355
 
346
356
 
347
357
  def get_live_info(data):
@@ -365,8 +375,6 @@ def get_live_info(data):
365
375
  return response.json()
366
376
 
367
377
 
368
-
369
-
370
378
  def get_activity_detail(data):
371
379
  """
372
380
  type:
@@ -495,7 +503,6 @@ def live_search_oa_product(data):
495
503
  return spu_id,sku_id,sku_id_quantity,product_info
496
504
 
497
505
 
498
-
499
506
  def get_merchant_info(data):
500
507
  env = data["env"]
501
508
  headers = data["headers"]
@@ -2445,18 +2452,55 @@ def add_product_to_live(data):
2445
2452
  return response
2446
2453
 
2447
2454
 
2448
- def get_merchant_currency(data):
2449
- env = data["env"]
2450
- headers = data["headers"]
2451
2455
 
2452
2456
 
2457
+ def send_comment():
2458
+ timStamp = int(time.time())
2459
+
2460
+ key = "a2f4cae7b637eb42967ef5ab6a6a3ff7"
2461
+ url = "https://front-service.shoplinestg.com/facebook/webhook"
2462
+ post_id = "119305964434044_9672903432799494"
2463
+ page_id = "119305964434044"
2464
+
2465
+ # message = "fb文3本消息%d"%timStamp
2466
+ # message = "%d" % random.randint(3, 999)
2467
+ message = "个哈哈哈"
2468
+
2469
+ #生产
2470
+ # key = 'a2f4cae7b637eb42967ef5ab6a6a3ff7'
2471
+ # url = 'https://front-admin.shoplineapp.com/facebook/webhook'
2472
+ # post_id = "107977035056574_1226869379002413"
2473
+ # page_id = "107977035056574"
2474
+
2475
+
2476
+ randnum = random.randint(1,1000)
2477
+ user_id = "4724508317%d%d" % (timStamp,randnum)
2478
+ # user_id = "47245083171744792310"0
2479
+ name = "️%d%dtest" % (randnum,timStamp)
2480
+ contentbody = {"entry": [{"id": page_id, "time": timStamp, "changes": [{"value": {
2481
+ "from": {"id": user_id, "name": name},
2482
+ "post": {"status_type": "added_video", "is_published": True, "updated_time": "2024-10-16T13:28:29+0000",
2483
+ "permalink_url": "https://www.facebook.com/161726309710099/videos/3266941630279674",
2484
+ "promotion_status": "inactive", "id": post_id}, "message": message, "post_id": post_id,
2485
+ "comment_id": "%s_350%d%d" % (page_id, int(time.time() * 1000),random.randint(4, 1000)), "created_time": timStamp, "item": "comment",
2486
+ "parent_id": post_id, "verb": "add"}, "field": "feed"}]}], "object": "page"}
2487
+ # print("contentbody", contentbody)
2488
+ # contentbody["entry"][0]["time"] = time
2453
2489
 
2490
+ signdata = hmac.new(key.encode('utf-8'), json.dumps(contentbody).encode('utf-8'), hashlib.sha1).hexdigest()
2491
+ signdata = signdata
2492
+ contentbody = json.dumps(contentbody)
2493
+ headers = {"Content-Type":"application/json","x-hub-signature":"sha1=%s"%signdata}
2494
+ res =requests.post(url,headers=headers,data=contentbody)
2495
+ print(res.content)
2454
2496
 
2455
2497
 
2456
2498
 
2457
2499
  if __name__=="__main__":
2458
- data = {'env': 'https://front-service.shoplinestg.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwMzkzZTdlODQ2MDMzZmUyOTViMjllY2I1OWVjOTgwOSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MjI5YTdiYWVhNzA2NDJhOGI2NWViZGEiLCJhcHBsaWNhdGlvbl9pZCI6IjYwZWVjNWViZjhkYzkyMDAwNjUyZTAwNiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMteXkuc2hvcGxpbmVzdGcuY29tIiwiYXVkIjpbXSwic3ViIjoiNjIyOWE3YmFlYTcwNjQyYThiNjVlYmRhIn0.pKkJD01uFDUfiVR2gBJQFd_EtIvQkHR2ScJzRTTOxxg', 'lang': 'en'}, 'sales_id': '90566', 'arr': 0}
2459
- add_product_set_to_live(data)
2500
+ # data = {"env":"https://front-service.shoplinestg.com","sales_id":"91371","headers":{"cookie":"viewerLogin_6229a7baea70642a8b65ebda=6998469593053840441"}}
2501
+ # res = send_sl_comment(data)
2502
+ # print(res)
2503
+ pass
2460
2504
 
2461
2505
 
2462
2506
 
@@ -0,0 +1,196 @@
1
+ import random
2
+ import time
3
+ import random
4
+ import secrets
5
+ import string
6
+ from datetime import datetime
7
+
8
+ import pymysql
9
+
10
+
11
+
12
+ class OperaMysql():
13
+ def __init__(self,host,username,password,db,port):
14
+ self.host= host
15
+ self.username = username
16
+ self.password = password
17
+ self.db = db
18
+ self.port = port
19
+ self.con = pymysql.connect(host=self.host,user=self.username,password=self.password,database=self.db,port=self.port)
20
+ #whatsapp 广播
21
+ def whatsapp_broadcast_update(self,num,merchantId,waba,phone,country_code="86",interaction_time=None):
22
+ """
23
+ :param num: 要插入的数据条数
24
+ :param merchantId:店铺ID
25
+ :param phone:插入的号码,插入的号码不能一样,所以会从这个递增
26
+ :param waba:店铺的wabaid
27
+ :return:
28
+ """
29
+ cur = self.con.cursor()
30
+ phone = phone
31
+ name = "jmeter压测%d"%int(time.time())
32
+ select_sql = """
33
+ select max(id) from sl_uc_test.whatsapp_contact;
34
+ """
35
+ cur.execute(select_sql)
36
+ id = cur.fetchone()[0]
37
+ # 准备批量插入的数据
38
+ insert_data = []
39
+ formatted_time =get_strf_time()
40
+ if interaction_time==None:
41
+ interaction_time = get_strf_time()
42
+ # print(id)
43
+ for i in range(num):
44
+ phone+=1
45
+ id+=1
46
+ phone_str = str(phone)
47
+ insert_data.append((
48
+ id,
49
+ merchantId,
50
+ waba,
51
+ name,
52
+ country_code,
53
+ phone_str,
54
+ phone_str,
55
+ phone_str,
56
+ 2,
57
+ interaction_time,
58
+ None,
59
+ None,
60
+ phone_str,
61
+ 1,
62
+ formatted_time,
63
+ formatted_time
64
+ ))
65
+
66
+ # 批量插入或更新
67
+ insert_sql = """
68
+ INSERT INTO sl_uc_test.whatsapp_contact
69
+ (id, merchant_id, merchant_waba_id, name, country_code, phone_number, display_phone_number, head_img, optin_status, interaction_time, customer_name, customer_id, waba_id, is_wabaaccount, update_time, create_time)
70
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
71
+ ON DUPLICATE KEY UPDATE
72
+ phone_number = VALUES(phone_number),
73
+ display_phone_number = VALUES(display_phone_number);
74
+ """
75
+ try:
76
+ # 开始事务
77
+ self.con.begin()
78
+ cur.executemany(insert_sql, insert_data)
79
+ # 提交事务
80
+ self.con.commit()
81
+ except Exception as e:
82
+ print(f"Error: {e}")
83
+ self.con.rollback() # 回滚事务
84
+ finally:
85
+ cur.close()
86
+ self.con.close()
87
+ #line、faceboook 、instagram 平台广播
88
+ def other_broadcast_update(self,num,page_id,platform,interaction_time=None):
89
+ """
90
+ page_id、platform 需要替换成自己店铺的数据,
91
+ num 为 插入的条数
92
+ """
93
+ if interaction_time==None:
94
+ interaction_time = get_strf_time()
95
+ cur = self.con.cursor()
96
+ select_sql = """
97
+ select max(id) from sl_uc_test.uc_user_interaction ;
98
+ """
99
+ cur.execute(select_sql)
100
+ id = cur.fetchone()[0]
101
+ # 准备批量插入的数据
102
+ formatted_time = get_strf_time()
103
+ insert_data = []
104
+ for i in range(num):
105
+ id+=1
106
+ user_id = '{}c4af{}k74{}9'.format(random.randint(100, 999), int(time.time()), generate_random_string(4))
107
+ insert_data.append((
108
+ id,
109
+ user_id,
110
+ page_id,
111
+ platform,
112
+ interaction_time,
113
+ formatted_time,
114
+ formatted_time
115
+ ))
116
+ # 批量插入或更新
117
+ insert_sql ="""
118
+ INSERT INTO sl_uc_test.uc_user_interaction
119
+ (id, platform_user_id, platform_channel_id, platform, interaction_time, create_time, update_time)
120
+ VALUES(%s, %s, %s, %s, %s, %s, %s);
121
+ """
122
+ try:
123
+ # 开始事务
124
+ self.con.begin()
125
+ cur.executemany(insert_sql, insert_data)
126
+ # 提交事务
127
+ self.con.commit()
128
+ except Exception as e:
129
+ print(f"Error: {e}")
130
+ self.con.rollback() # 回滚事务
131
+ finally:
132
+ cur.close()
133
+ self.con.close()
134
+
135
+ def select(self,select_sql):
136
+ # con = con_mysql()
137
+ cur = self.con.cursor()
138
+ cur.execute(select_sql)
139
+ data = cur.fetchall()
140
+ return data
141
+
142
+
143
+ def generate_random_string(length):
144
+ characters = string.ascii_letters + string.digits
145
+ return ''.join(secrets.choice(characters) for _ in range(length))
146
+
147
+ def get_strf_time():
148
+ # 获取当前时间
149
+ now = datetime.now()
150
+ # 格式化为字符串,确保微秒部分有 9 位数
151
+ formatted_time = now.strftime('%Y-%m-%d %H:%M:%S.%f')
152
+ # 将微秒部分填充到 9 位
153
+ formatted_time = formatted_time[:-3] + formatted_time[-3:].ljust(9, '0')
154
+ return formatted_time
155
+
156
+
157
+
158
+
159
+
160
+
161
+ if __name__=="__main__":
162
+ # host = "10.98.32.7"
163
+ # port = 6303
164
+ # db = "sl_sc_medium_test"
165
+ # username = "sl_sc2_backend"
166
+ # password = "XVPt6eS7r9nHZF8qlfoivy9u"
167
+
168
+ # host = "10.98.216.252"
169
+ # port = 3306
170
+ # db = "sl_uc_test"
171
+ # username = "admin"
172
+ # password = "p2qJrad0rr5AxfGGe3gN69fF"
173
+
174
+ host = "10.98.32.38"
175
+ port = 6304
176
+ db = "sl_uc_test"
177
+ username = "sl_sc_1_dev_test"
178
+ password = "VJ6H54iSPjStkFZqWiTYHJNe"
179
+ operaMysql = OperaMysql(host,username,password,db,port)
180
+ phone = 1827679999
181
+ num = 10
182
+ merchant_id = "613581c9820e260046693ef5"
183
+ waba = "102324679313339"
184
+ # operaMysql.whatsapp_broadcast_update(num,merchant_id,waba,phone)
185
+ # page_id = "110234798670383"
186
+ # platform = "FACEBOOK"
187
+ # ig
188
+ page_id = "17841453464121067"
189
+ platform = "INSTAGRAM"
190
+ operaMysql.other_broadcast_update(10,page_id,platform)
191
+
192
+
193
+
194
+
195
+
196
+
@@ -0,0 +1,43 @@
1
+ import redis
2
+ import time,random
3
+ import csv
4
+
5
+
6
+ class OperaRedis():
7
+ def __init__(self,redis_host,redis_port,redis_password = None):
8
+ self.redis_host = redis_host
9
+ self.redis_port = redis_port
10
+ self.redis_password = redis_password
11
+ self.connect = redis.Redis(host=redis_host, db=1, port=redis_port, password=redis_password)
12
+
13
+
14
+ def set_key(self,set_key,set_value):
15
+ try:
16
+ self.connect.set(set_key, set_value) # 设置键值对
17
+ except Exception as e:
18
+ print(f"Error: {e}")
19
+ finally:
20
+ self.connect.close()
21
+
22
+ def get_key(self,key):
23
+ try:
24
+ keys = self.connect.keys(key) # 设置键值对
25
+ data_list = []
26
+ for key in keys:
27
+ data = str(key.decode()).replace("_", "=").replace(":", "_")
28
+ data_list.append(data)
29
+ write_to_csv(data_list)
30
+ except Exception as e:
31
+ print(f"Error: {e}")
32
+ finally:
33
+ self.connect.close()
34
+
35
+
36
+ def write_to_csv(data,file_name = "../test_data/view_cookie.csv"):
37
+ with open(file_name, mode='w', newline='', encoding='utf-8') as file:
38
+ writer = csv.writer(file)
39
+ # 写入多行数据
40
+ writer.writerows(data)
41
+
42
+ if __name__=="__main__":
43
+ pass
@@ -35,7 +35,6 @@ def create_general_post(data):
35
35
  patternModel = "INCLUDE_MATCH"
36
36
  if "patternModel" in data:
37
37
  patternModel = data["patternModel"]
38
- headers = data["headers"]
39
38
  title = "接口自动化创建的普通贴文%d"%int(time.time())
40
39
  if "title" in data:
41
40
  title = data["title"]
@@ -424,8 +423,6 @@ def get_page_post(data):
424
423
  return response
425
424
 
426
425
 
427
-
428
-
429
426
  def relate_post(data):
430
427
  """
431
428
  链接贴文,只链接返回的第一个可链接的贴文
@@ -819,8 +816,6 @@ def send_post_comment(data):
819
816
  response = requests.post(url, headers=header, data=json.dumps(body))
820
817
  return user_id,name,comment_id
821
818
 
822
-
823
-
824
819
  def get_payment(data):
825
820
  """
826
821
  获取店铺的付款方式,默认查询10条
@@ -913,7 +908,6 @@ def post_edit_cart(data):
913
908
  response = requests.post(url, headers=headers, json=body).json()
914
909
  return response
915
910
 
916
-
917
911
  def search_customer(data):
918
912
  env = data["env"]
919
913
  headers = data["headers"]
@@ -964,7 +958,6 @@ def merge_customer(data):
964
958
  customer_id = response.json()["data"]["id"]
965
959
  return response,customer_id
966
960
 
967
-
968
961
  def manual_order(data):
969
962
  """
970
963
  创建会员,若存在则合并会员
@@ -2,16 +2,13 @@ import json
2
2
  import ssl
3
3
  import time
4
4
 
5
+ import websockets
6
+ import asyncio
5
7
  import requests
6
- # from cryptography.hazmat.primitives import hashes
7
- # from cryptography.hazmat.primitives.asymmetric import rsa, padding
8
- # from cryptography.hazmat.primitives import serialization
9
- # from cryptography.hazmat.backends import default_backend
10
- import base64
11
8
  import websocket
12
9
 
13
10
  # 定义回调函数
14
- class WebSocketClient:
11
+ class WebSocketClient():
15
12
  def __init__(self, url,admin_url, sales_id):
16
13
  self.url = url
17
14
  self.admin_url = admin_url
@@ -66,6 +63,7 @@ class WebSocketClient:
66
63
 
67
64
  def run(self):
68
65
  self.ws.run_forever()
66
+
69
67
  def close(self):
70
68
  print("主动关闭")
71
69
  self.ws.close()
@@ -82,39 +80,65 @@ def get_imtoken(admin_url,sales_id):
82
80
  return subscribeToken,userToken
83
81
 
84
82
 
83
+ async def client(url,message):
84
+ async with websockets.connect(url) as websocket:
85
+ for msg in message:
86
+ await websocket.send(json.dumps(msg))
87
+ response = await websocket.recv()
88
+ print(response)
89
+
90
+ async def live_view_client(socket_url,admin_url,sales_id):
91
+ subscribeToken, userToken = get_imtoken(admin_url, sales_id)
92
+ message = []
93
+ stamp = int(time.time() * 1000)
94
+ reqid = "53%d" % stamp
95
+ #绑定设备
96
+ device = {
97
+ "version": 1,
98
+ "reqid": reqid,
99
+ "payload": {
100
+ "appid": "SL101-web",
101
+ "devid": "7ecce8fc-44af-4c65-b75b-aa84b%d" % stamp,
102
+ "sdkver": "1.1.0"
103
+ },
104
+ "type": "REQUEST",
105
+ "url": "ap://auth/device",
106
+ "sign": "TDbwNFgmAPEPG5VGn5ozdSShpPPHK8PVsir9VXQ1ygx/RaeKjJ8lRnWf+gZ9wUH72EkgjSFGHaisv77wE8sgBBxxUud81V19t/mJY03MUwPQLSxJEY0hPPPr4mGhDK4IxYx154OJieyiDKNR5zO3jiGrEFWSn1Ft/0uMugkHQe8="
107
+ }
108
+ # 订阅 将消息转换为 JSON 格式并发送
109
+
110
+ subscribe = {
111
+ "version": 1,
112
+ "reqid": reqid,
113
+ "payload": {
114
+ "groups": [
115
+ "POST_%d" % sales_id,
116
+ "VIEW_ONLINE_%d" % sales_id
117
+ ],
118
+ "token": subscribeToken
119
+ },
120
+ "type": "REQUEST",
121
+ "url": "http://broadcast/broadcast/subscribe",
122
+ "sign": "gaoLzQ6q1+Fn5uq0UqHAamaKJieEvMXRqo+rwR0u9WZnBhJ27StRlWohqCsO89/QyJvxupaGPuCwLpPji/xfMpeHacmodUrWO3J/EffRX0lGeIo+Zz35XjqleFruaXmu1GGkCQ82SZmNdaAo6YrGN//twyiIPNH3KZ7xNRO/+dI="
123
+ }
124
+ message.append(device)
125
+ message.append(subscribe)
126
+ await client(socket_url,message)
127
+
85
128
 
86
- # def sign(msg, private_key):
87
- # # 将消息编码为字节
88
- # # 从 字符串加载私钥
89
- # loaded_private_key = load_private_key(private_key)
90
- # message_bytes = msg.encode('utf-8')
91
- # # 使用私钥进行签名
92
- # signature = loaded_private_key.sign(
93
- # message_bytes,
94
- # padding.PKCS1v15(),
95
- # hashes.SHA1()
96
- # )
97
- # # 将签名转换为 Base64 编码
98
- # return base64.b64encode(signature).decode('utf-8')
99
- #
100
- # def load_private_key(pri_key_str):
101
- # # 从 PEM 格式字符串加载私钥
102
- # return serialization.load_pem_private_key(
103
- # pri_key_str.encode(),
104
- # password=None,
105
- # backend=default_backend()
106
- # )
107
129
 
108
130
 
109
131
  if __name__=="__main__":
132
+ pass
110
133
  # admin_url = "https://front-service.shoplinestg.com"
111
134
  # url = "ws://service-websocket.myshoplinestg.com/"
112
135
  # url = "ws://api-webservice-preview.myshopline.com"
113
- url = "ws://api-webservice.myshopline.com"
114
- admin_url = "https://front-admin.shoplineapp.com"
115
-
116
- webSocketClient = WebSocketClient(url,admin_url,561242)
117
- webSocketClient.run()
118
- webSocketClient.close()
136
+ # url = "ws://api-webservice.myshopline.com"
137
+ # admin_url = "https://front-admin.shoplineapp.com"
138
+ # webSocketClient = WebSocketClient(url,admin_url,561242)
139
+ # webSocketClient.run()
140
+ # webSocketClient.close()
141
+ # asyncio.run(live_view_client(url,admin_url,561242))
142
+ #启用多个客户端
119
143
 
120
144
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.9.7
3
+ Version: 2.9.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,8 +2,10 @@ setup.py
2
2
  sc_common_interface/CommonOa.py
3
3
  sc_common_interface/LiveCommonInterface.py
4
4
  sc_common_interface/McCommonInterface.py
5
- sc_common_interface/Platform.py
5
+ sc_common_interface/OperaMysql.py
6
+ sc_common_interface/OperaRedis.py
6
7
  sc_common_interface/PostCommonInterface.py
8
+ sc_common_interface/ScPulsar.py
7
9
  sc_common_interface/ScWebsocket.py
8
10
  sc_common_interface/__init__.py
9
11
  sc_common_interface.egg-info/PKG-INFO
@@ -1,3 +1,4 @@
1
1
  requests>=2.0.0
2
2
  jsonpath>=0.82
3
3
  websocket-client>=1.6.1
4
+ websockets>=15.0.1
@@ -2,14 +2,15 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc_common_interface',
5
- version='2.9.7',
5
+ version='2.9.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),
9
9
  install_requires=[
10
10
  "requests>=2.0.0",
11
11
  "jsonpath>=0.82",
12
- "websocket-client>=1.6.1"
12
+ "websocket-client>=1.6.1",
13
+ "websockets>=15.0.1"
13
14
  ]
14
15
  )
15
16
 
@@ -1,7 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class Platform(Enum):
5
- FACEBOOK = 1
6
- INSTAGRAM = 2
7
- FB_GROUP = 3