From 3dee6a37ebee40959531c92b8e32efdde39d5f4a Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Mon, 28 Jul 2025 21:10:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E5=B9=B6=E7=A7=BB=E9=99=A4=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=EF=BC=9B=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?general=E4=BF=A1=E6=81=AF=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- general.py | 19 +++++-------------- main.py | 8 ++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/general.py b/general.py index 4e76100..0caa9bc 100644 --- a/general.py +++ b/general.py @@ -1,7 +1,5 @@ import csv from datetime import datetime -import time -import schedule import requests PHASE_URL = "https://backend.dexrp.io/general/phase" @@ -23,8 +21,10 @@ def save_to_csv(filename, data): with open(filename, "a", newline="") as f: writer = csv.writer(f) if f.tell() == 0: # Write header if file is empty - writer.writerow(data.keys()) - writer.writerow(data.values()) + writer.writerow(["datetime"] + list(data.keys())) + writer.writerow( + [datetime.now().strftime("%Y-%m-%d %H:%M:%S")] + list(data.values()) + ) except Exception as e: print(f"Error saving to {filename}: {e}") @@ -52,14 +52,5 @@ def job(): save_to_csv("general.csv", filtered_general) -def main(): - schedule.every(10).minutes.do(job) - job() # Run immediately first time - - while True: - schedule.run_pending() - time.sleep(1) - - if __name__ == "__main__": - main() + job() diff --git a/main.py b/main.py index ed93100..b816e73 100644 --- a/main.py +++ b/main.py @@ -162,6 +162,13 @@ def git_commit_and_push(): except subprocess.CalledProcessError as e: LOGGER.error("Git操作失败: %s", e) +def general_info(): + """获取general信息""" + LOGGER.info("获取general信息") + try: + subprocess.run(["python", "general.py"], check=True) + except subprocess.CalledProcessError as e: + LOGGER.error("获取general信息失败: %s", e) def load_processed_hashes(): """Load processed transaction hashes from file.""" @@ -219,6 +226,7 @@ def main(): current_time = time.time() if current_time - last_git_time >= GIT_INTERVAL: + general_info() git_commit_and_push() last_git_time = current_time