Skip to content

Commit

Permalink
✨ Update disable.py: customize ip&port
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreo authored and Oreo committed Dec 7, 2021
1 parent d3d3655 commit 71d8654
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Scripts/py/disable.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
# logger.addHandler(logging.FileHandler(filename="text.log", mode="w")) # 添加文件日志


ip = "localhost"
ipport = os.getenv("IPPORT")
if not ipport:
logger.info(
"如果报错请在环境变量中添加你的真实 IP:端口\n名称:IPPORT\t值:127.0.0.1:5700\n或在 config.sh 中添加 export IPPORT='127.0.0.1:5700'"
)
ipport = "localhost:5700"
else:
ipport = ipport.lstrip("http://").rstrip("/")
sub_str = os.getenv("RES_SUB", "Aaron-lv_sync")
sub_list = sub_str.split("&")
res_only = os.getenv("RES_ONLY", True)
Expand All @@ -47,7 +54,7 @@ def load_send() -> None:
def get_tasklist() -> list:
tasklist = []
t = round(time.time() * 1000)
url = f"http://{ip}:5700/api/crons?searchValue=&t={t}"
url = f"http://{ipport}/api/crons?searchValue=&t={t}"
response = requests.get(url=url, headers=headers)
datas = json.loads(response.content.decode("utf-8"))
if datas.get("code") == 200:
Expand Down Expand Up @@ -135,7 +142,7 @@ def reserve_task_only(

def disable_duplicate_tasks(ids: list) -> None:
t = round(time.time() * 1000)
url = f"http://{ip}:5700/api/crons/disable?t={t}"
url = f"http://{ipport}/api/crons/disable?t={t}"
data = json.dumps(ids)
headers["Content-Type"] = "application/json;charset=UTF-8"
response = requests.put(url=url, headers=headers, data=data)
Expand Down

0 comments on commit 71d8654

Please sign in to comment.