init xiaoxiang project
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
import datetime
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
WORK_ID_ENV = "ELEPHANT_WORKID"
|
||||
SHOP_IDS_ENV = "ELEPHANT_SHOP_IDS"
|
||||
SHOP_ID_LIST = [
|
||||
10000439,
|
||||
10000900,
|
||||
10000880,
|
||||
10000665,
|
||||
10000839,
|
||||
10000519,
|
||||
10001060,
|
||||
10000163,
|
||||
10000952,
|
||||
10000956,
|
||||
10001084,
|
||||
10001075,
|
||||
10001107,
|
||||
10001195,
|
||||
10001222,
|
||||
10001400,
|
||||
10001506,
|
||||
10001575,
|
||||
]
|
||||
|
||||
|
||||
def get_workid():
|
||||
format_today = str(datetime.date.today()).replace("-", "")
|
||||
# format_today = '第二次测试'
|
||||
return os.environ.get(WORK_ID_ENV, format_today)
|
||||
|
||||
|
||||
def run_script(script_name, workid, shop_id_list):
|
||||
script_path = BASE_DIR / script_name
|
||||
env = os.environ.copy()
|
||||
env[WORK_ID_ENV] = workid
|
||||
env[SHOP_IDS_ENV] = ",".join(map(str, shop_id_list))
|
||||
print(f"开始运行: {script_name}")
|
||||
subprocess.run([sys.executable, str(script_path)], check=True, env=env)
|
||||
print(f"运行完成: {script_name}")
|
||||
|
||||
|
||||
def main():
|
||||
workid = get_workid()
|
||||
print(f"本次 workid: {workid}")
|
||||
run_script("小象超市分类请求部分.py", workid, SHOP_ID_LIST)
|
||||
run_script("小象超市详情列表请求部分.py", workid, SHOP_ID_LIST)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user