Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -135,14 +135,14 @@ def load_client_api_keys():
|
|
| 135 |
|
| 136 |
|
| 137 |
def load_abacus_accounts():
|
| 138 |
-
"""Load Abacus accounts from
|
| 139 |
global ABACUS_ACCOUNTS
|
| 140 |
ABACUS_ACCOUNTS = []
|
| 141 |
try:
|
| 142 |
-
with open("
|
| 143 |
accounts = json.load(f)
|
| 144 |
if not isinstance(accounts, list):
|
| 145 |
-
print("Warning:
|
| 146 |
return
|
| 147 |
|
| 148 |
for acc in accounts:
|
|
@@ -160,9 +160,9 @@ def load_abacus_accounts():
|
|
| 160 |
})
|
| 161 |
print(f"Successfully loaded {len(ABACUS_ACCOUNTS)} Abacus accounts.")
|
| 162 |
except FileNotFoundError:
|
| 163 |
-
print("Error:
|
| 164 |
except Exception as e:
|
| 165 |
-
print(f"Error loading
|
| 166 |
|
| 167 |
|
| 168 |
def get_session_token(_u_p: str, _s_p: str) -> str:
|
|
@@ -1083,17 +1083,17 @@ if __name__ == "__main__":
|
|
| 1083 |
print("Debug mode enabled via environment variable")
|
| 1084 |
|
| 1085 |
# Create dummy files if they don't exist
|
| 1086 |
-
if not os.path.exists("
|
| 1087 |
-
print("Warning:
|
| 1088 |
dummy_data = [
|
| 1089 |
{
|
| 1090 |
"_u_p": "your_u_p_here",
|
| 1091 |
"_s_p": "your_s_p_here",
|
| 1092 |
}
|
| 1093 |
]
|
| 1094 |
-
with open("
|
| 1095 |
json.dump(dummy_data, f, indent=4)
|
| 1096 |
-
print("Created dummy
|
| 1097 |
|
| 1098 |
if not os.path.exists("client_api_keys.json"):
|
| 1099 |
print("Warning: client_api_keys.json not found. Creating a dummy file.")
|
|
@@ -1121,7 +1121,7 @@ if __name__ == "__main__":
|
|
| 1121 |
valid_accounts = sum(1 for acc in ABACUS_ACCOUNTS if acc["is_valid"])
|
| 1122 |
print(f"Valid Accounts: {valid_accounts}")
|
| 1123 |
else:
|
| 1124 |
-
print("Abacus Accounts: None loaded. Check
|
| 1125 |
|
| 1126 |
if ABACUS_MODELS:
|
| 1127 |
models = sorted([m.get("id", m.get("name", "unknown")) for m in ABACUS_MODELS])
|
|
|
|
| 135 |
|
| 136 |
|
| 137 |
def load_abacus_accounts():
|
| 138 |
+
"""Load Abacus accounts from abc.json"""
|
| 139 |
global ABACUS_ACCOUNTS
|
| 140 |
ABACUS_ACCOUNTS = []
|
| 141 |
try:
|
| 142 |
+
with open("abc.json", "r", encoding="utf-8") as f:
|
| 143 |
accounts = json.load(f)
|
| 144 |
if not isinstance(accounts, list):
|
| 145 |
+
print("Warning: abc.json should contain a list of account objects.")
|
| 146 |
return
|
| 147 |
|
| 148 |
for acc in accounts:
|
|
|
|
| 160 |
})
|
| 161 |
print(f"Successfully loaded {len(ABACUS_ACCOUNTS)} Abacus accounts.")
|
| 162 |
except FileNotFoundError:
|
| 163 |
+
print("Error: abc.json not found. API calls will fail.")
|
| 164 |
except Exception as e:
|
| 165 |
+
print(f"Error loading abc.json: {e}")
|
| 166 |
|
| 167 |
|
| 168 |
def get_session_token(_u_p: str, _s_p: str) -> str:
|
|
|
|
| 1083 |
print("Debug mode enabled via environment variable")
|
| 1084 |
|
| 1085 |
# Create dummy files if they don't exist
|
| 1086 |
+
if not os.path.exists("abc.json"):
|
| 1087 |
+
print("Warning: abc.json not found. Creating a dummy file.")
|
| 1088 |
dummy_data = [
|
| 1089 |
{
|
| 1090 |
"_u_p": "your_u_p_here",
|
| 1091 |
"_s_p": "your_s_p_here",
|
| 1092 |
}
|
| 1093 |
]
|
| 1094 |
+
with open("abc.json", "w", encoding="utf-8") as f:
|
| 1095 |
json.dump(dummy_data, f, indent=4)
|
| 1096 |
+
print("Created dummy abc.json. Please replace with valid Abacus data.")
|
| 1097 |
|
| 1098 |
if not os.path.exists("client_api_keys.json"):
|
| 1099 |
print("Warning: client_api_keys.json not found. Creating a dummy file.")
|
|
|
|
| 1121 |
valid_accounts = sum(1 for acc in ABACUS_ACCOUNTS if acc["is_valid"])
|
| 1122 |
print(f"Valid Accounts: {valid_accounts}")
|
| 1123 |
else:
|
| 1124 |
+
print("Abacus Accounts: None loaded. Check abc.json.")
|
| 1125 |
|
| 1126 |
if ABACUS_MODELS:
|
| 1127 |
models = sorted([m.get("id", m.get("name", "unknown")) for m in ABACUS_MODELS])
|