|
@@ -17,6 +17,8 @@ from dateutil.parser import parse
|
|
|
import pymysql
|
|
|
from typing import List, Literal
|
|
|
from random import shuffle
|
|
|
+from retry import retry
|
|
|
+
|
|
|
try:
|
|
|
from ..settings import MYSQL_AUTH_CONF, MYSQL_DATA_CONF
|
|
|
except:
|
|
@@ -31,18 +33,24 @@ class SpApiRequest:
|
|
|
# self.timezone = self.shopInfo['time_zone']
|
|
|
# self.profileid = '3006125408623189'
|
|
|
|
|
|
+ #
|
|
|
@classmethod
|
|
|
+ @retry(tries=3, delay=5, backoff=2, )
|
|
|
def mysql_connect_auth(cls): # AUTH
|
|
|
conn = pymysql.connect(**MYSQL_AUTH_CONF)
|
|
|
|
|
|
return conn
|
|
|
|
|
|
+
|
|
|
@classmethod
|
|
|
+ @retry(tries=3, delay=5, backoff=2, )
|
|
|
def mysql_connect_auth_lst(cls): # DATA
|
|
|
conn = pymysql.connect(**MYSQL_DATA_CONF)
|
|
|
return conn
|
|
|
|
|
|
+
|
|
|
@classmethod
|
|
|
+ @retry(tries=3, delay=5, backoff=2, )
|
|
|
def mysql_connect(cls): # local database
|
|
|
conn = pymysql.connect(user="huangyifan",
|
|
|
password="123456",
|
|
@@ -51,7 +59,9 @@ class SpApiRequest:
|
|
|
port=3306)
|
|
|
return conn
|
|
|
|
|
|
+
|
|
|
@staticmethod
|
|
|
+ @retry(tries=3, delay=5, backoff=2, )
|
|
|
def auth_info(): # get Auth-data from all of shops
|
|
|
auth_conn = SpApiRequest.mysql_connect_auth()
|
|
|
cursor = auth_conn.cursor()
|
|
@@ -63,6 +73,7 @@ class SpApiRequest:
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
+ @retry(tries=3, delay=5, backoff=2, )
|
|
|
def get_refreshtoken(cls): # accroding to differnt shop get diffrent refreshtoken
|
|
|
df = cls.auth_info()
|
|
|
refreshtoken_list = (df['refresh_token'].to_numpy().tolist())
|