-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.py
More file actions
123 lines (103 loc) · 3.4 KB
/
validate.py
File metadata and controls
123 lines (103 loc) · 3.4 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python3
"""
Simple validation script for Trading with Python application
Tests basic functionality without requiring API credentials
"""
import sys
import os
def test_imports():
"""Test if all required modules can be imported"""
print("Testing module imports...")
try:
import sqlite3
print("✓ sqlite3 - OK")
except ImportError as e:
print(f"✗ sqlite3 - FAILED: {e}")
return False
try:
import time
import threading
print("✓ time, threading - OK")
except ImportError as e:
print(f"✗ time/threading - FAILED: {e}")
return False
try:
from datetime import datetime, timedelta
print("✓ datetime - OK")
except ImportError as e:
print(f"✗ datetime - FAILED: {e}")
return False
try:
from dateutil.relativedelta import relativedelta
print("✓ dateutil - OK")
except ImportError as e:
print(f"✗ dateutil - FAILED: {e}")
print(" Run: pip install python-dateutil")
return False
try:
from kiteconnect import KiteConnect
print("✓ kiteconnect - OK")
except ImportError as e:
print(f"✗ kiteconnect - FAILED: {e}")
print(" Run: pip install kiteconnect")
return False
# Try tkinter (may not be available in headless environments)
try:
import tkinter
from tkinter import ttk
print("✓ tkinter - OK")
except ImportError as e:
print(f"⚠ tkinter - WARNING: {e}")
print(" This is expected in headless environments")
print(" Install tkinter for GUI support")
return True
def test_file_structure():
"""Test if required files exist"""
print("\nTesting file structure...")
required_files = [
"TRADING list/API.PY",
"README.md",
"requirements.txt"
]
all_found = True
for file_path in required_files:
if os.path.exists(file_path):
print(f"✓ {file_path} - Found")
else:
print(f"✗ {file_path} - Missing")
all_found = False
return all_found
def test_code_syntax():
"""Test if the main Python file has valid syntax"""
print("\nTesting code syntax...")
try:
with open("TRADING list/API.PY", "r") as f:
code = f.read()
compile(code, "API.PY", "exec")
print("✓ API.PY - Syntax OK")
return True
except SyntaxError as e:
print(f"✗ API.PY - Syntax Error: {e}")
return False
except FileNotFoundError:
print("✗ API.PY - File not found")
return False
def main():
print("=== Trading with Python - Validation Tests ===\n")
results = []
results.append(test_imports())
results.append(test_file_structure())
results.append(test_code_syntax())
print("\n=== Summary ===")
if all(results):
print("🎉 All tests passed! Application structure is valid.")
print("\nNext steps:")
print("1. Install missing dependencies: pip install -r requirements.txt")
print("2. Configure your Zerodha API credentials in API.PY")
print("3. Run the application: python 'TRADING list/API.PY'")
return 0
else:
print("❌ Some tests failed. Please fix the issues above.")
return 1
if __name__ == "__main__":
sys.exit(main())