-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_all.py
More file actions
47 lines (37 loc) · 1.26 KB
/
Copy pathrun_all.py
File metadata and controls
47 lines (37 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Automation script to run all data processing tasks sequentially.
This script executes the following tasks in order:
1. Fetch bank data
2. Export transactions to Google Sheets
3. Send Telegram notifications about new transactions
"""
import os
import subprocess
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Set Django settings module environment variable
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "coin_counter.settings")
def run_command(cmd):
"""
Execute a command and print its output.
Args:
cmd (list): Command and arguments to execute.
"""
print(f"\n==> Running: {' '.join(cmd)}\n")
result = subprocess.run(
cmd,
capture_output=True,
text=True,
encoding='utf-8',
errors='replace'
)
print(result.stdout)
if result.stderr:
print("WARNING: Error output:\n", result.stderr)
if __name__ == "__main__":
# 1. Fetch bank data
run_command([sys.executable, "manage.py", "fetch_bank_data"])
# 2. Export transactions to Google Sheets
run_command([sys.executable, "manage.py", "export_transactions_to_sheets"])
# 3. Send Telegram notifications about new transactions
run_command([sys.executable, "manage.py", "notify_about_new_transactions"])