From 52c246cf07e40d3b5f1996479ca209732cf8f5e4 Mon Sep 17 00:00:00 2001 From: hiiragi Date: Wed, 14 Dec 2022 16:44:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E8=AF=BB=E5=8F=96=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E8=A7=A3=E5=86=B3=E8=AF=BB=E5=8F=96?= =?UTF-8?q?token=E6=97=B6=E8=87=AA=E5=B8=A6=E6=8D=A2=E8=A1=8C=E7=AC=A6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bgmTVApi.py | 6 ++++-- generateMailContent.py | 4 +++- loadYaml.py | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bgmTVApi.py b/bgmTVApi.py index 90093dc..afaf26f 100644 --- a/bgmTVApi.py +++ b/bgmTVApi.py @@ -1,11 +1,13 @@ +import os import requests from requests import exceptions # 消除ssl告警 requests.packages.urllib3.disable_warnings() -tokenFile = open('accessToken', encoding = "utf-8") -token = tokenFile.read() +currentPath = os.path.dirname(__file__) +tokenFile = open(os.path.join(currentPath, 'accessToken'), encoding = "utf-8") +token = tokenFile.read().splitlines()[0] tokenFile.close() headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json', 'User-Agent': 'Hiiragi/bangumi-mail-notification' } diff --git a/generateMailContent.py b/generateMailContent.py index 446d55a..a07dc7f 100644 --- a/generateMailContent.py +++ b/generateMailContent.py @@ -1,8 +1,10 @@ +import os import re from functools import partial def getTemplate(filePath): - file = open(filePath, encoding='utf-8') + currentPath = os.path.dirname(__file__) + file = open(os.path.join(currentPath, filePath), encoding='utf-8') fileData = file.read() file.close() return fileData diff --git a/loadYaml.py b/loadYaml.py index 6718a86..09abe41 100644 --- a/loadYaml.py +++ b/loadYaml.py @@ -1,7 +1,9 @@ import yaml +import os def loadYaml(path): - file = open(path, encoding='utf-8') + currentPath = os.path.dirname(__file__) + file = open(os.path.join(currentPath, path), encoding='utf-8') configData = file.read() file.close()