Browse Source

增加if条件

liuyuqi-dellpc 9 months ago
parent
commit
92e6c02d5b
1 changed files with 13 additions and 10 deletions
  1. 13 10
      main.py

+ 13 - 10
main.py

@@ -13,13 +13,16 @@ if __name__=='__main__':
     
     # current_run_path = os.path.dirname(os.path.realpath(__file__))   错误: windows exe 定位到 temp目录
     current_run_path = sys.path[0]
-    with open(os.path.join(current_run_path,"account.json"), "r") as file:
-        data = json.load(file)
-        owner=data["owner"]
-        token=data["token"]
-        repo = data["repo"]
-        github_api = GithubApi(owner=owner, token=token, repo=repo)
-        for i in data["secret"]:
-            key=i["key"]
-            value=i["value"]
-            github_api.set_update_github_secret(key, value)
+    if os.path.exists("account.json"):
+        with open("account.json", "r") as file:
+            data = json.load(file)
+            owner=data["owner"]
+            token=data["token"]
+            repo = data["repo"]
+            github_api = GithubApi(owner=owner, token=token, repo=repo)
+            for i in data["secret"]:
+                key=i["key"]
+                value=i["value"]
+                github_api.set_update_github_secret(key, value)
+    else:
+        print(f"account.json not found, current path: {current_run_path}")