gitarsenal-cli 1.3.6 โ 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
Binary file
|
@@ -41,12 +41,12 @@ def fetch_tokens_from_proxy(proxy_url=None, api_key=None):
|
|
41
41
|
# Check if we have the necessary information
|
42
42
|
if not proxy_url:
|
43
43
|
print("โ No proxy URL provided or found in environment")
|
44
|
-
print("๐ก Set MODAL_PROXY_URL environment variable or use --proxy-url argument")
|
44
|
+
# print("๐ก Set MODAL_PROXY_URL environment variable or use --proxy-url argument")
|
45
45
|
return None, None
|
46
46
|
|
47
47
|
if not api_key:
|
48
48
|
print("โ No API key provided or found in environment")
|
49
|
-
print("๐ก Set MODAL_PROXY_API_KEY environment variable or use --proxy-api-key argument")
|
49
|
+
# print("๐ก Set MODAL_PROXY_API_KEY environment variable or use --proxy-api-key argument")
|
50
50
|
return None, None
|
51
51
|
|
52
52
|
# Ensure the URL ends with a slash
|
@@ -103,7 +103,7 @@ def get_tokens():
|
|
103
103
|
# Set the tokens in environment variables
|
104
104
|
os.environ["MODAL_TOKEN_ID"] = token_id
|
105
105
|
os.environ["MODAL_TOKEN_SECRET"] = token_secret
|
106
|
-
print(f"โ
Set MODAL_TOKEN_ID and MODAL_TOKEN_SECRET environment variables")
|
106
|
+
# print(f"โ
Set MODAL_TOKEN_ID and MODAL_TOKEN_SECRET environment variables")
|
107
107
|
|
108
108
|
return token_id, token_secret
|
109
109
|
|
@@ -119,25 +119,25 @@ if __name__ == "__main__":
|
|
119
119
|
# Set proxy URL and API key in environment variables if provided
|
120
120
|
if args.proxy_url:
|
121
121
|
os.environ["MODAL_PROXY_URL"] = args.proxy_url
|
122
|
-
print(f"โ
Set MODAL_PROXY_URL from command line")
|
122
|
+
# print(f"โ
Set MODAL_PROXY_URL from command line")
|
123
123
|
|
124
124
|
if args.proxy_api_key:
|
125
125
|
os.environ["MODAL_PROXY_API_KEY"] = args.proxy_api_key
|
126
|
-
print(f"โ
Set MODAL_PROXY_API_KEY from command line")
|
126
|
+
# print(f"โ
Set MODAL_PROXY_API_KEY from command line")
|
127
127
|
|
128
128
|
# Get tokens
|
129
129
|
token_id, token_secret = get_tokens()
|
130
|
-
print(f"Token ID: [HIDDEN]")
|
131
|
-
print(f"Token Secret: [HIDDEN]")
|
132
|
-
|
133
|
-
# Check if tokens are set in environment variables
|
134
|
-
print(f"\n๐ DEBUG: Checking environment variables")
|
135
|
-
print(f"๐ MODAL_TOKEN_ID exists: {'Yes' if os.environ.get('MODAL_TOKEN_ID') else 'No'}")
|
136
|
-
print(f"๐ MODAL_TOKEN_SECRET exists: {'Yes' if os.environ.get('MODAL_TOKEN_SECRET') else 'No'}")
|
137
|
-
if os.environ.get('MODAL_TOKEN_ID'):
|
138
|
-
|
139
|
-
if os.environ.get('MODAL_TOKEN_SECRET'):
|
140
|
-
|
130
|
+
# print(f"Token ID: [HIDDEN]")
|
131
|
+
# print(f"Token Secret: [HIDDEN]")
|
132
|
+
|
133
|
+
# # Check if tokens are set in environment variables
|
134
|
+
# print(f"\n๐ DEBUG: Checking environment variables")
|
135
|
+
# print(f"๐ MODAL_TOKEN_ID exists: {'Yes' if os.environ.get('MODAL_TOKEN_ID') else 'No'}")
|
136
|
+
# print(f"๐ MODAL_TOKEN_SECRET exists: {'Yes' if os.environ.get('MODAL_TOKEN_SECRET') else 'No'}")
|
137
|
+
# if os.environ.get('MODAL_TOKEN_ID'):
|
138
|
+
# print(f"๐ MODAL_TOKEN_ID length: {len(os.environ.get('MODAL_TOKEN_ID'))}")
|
139
|
+
# if os.environ.get('MODAL_TOKEN_SECRET'):
|
140
|
+
# print(f"๐ MODAL_TOKEN_SECRET length: {len(os.environ.get('MODAL_TOKEN_SECRET'))}")
|
141
141
|
|
142
142
|
# Write the tokens to a file for use by other scripts
|
143
143
|
tokens_file = Path(__file__).parent / "modal_tokens.json"
|
@@ -24,24 +24,22 @@ try:
|
|
24
24
|
# First, try to import the fetch_modal_tokens module
|
25
25
|
from fetch_modal_tokens import get_tokens
|
26
26
|
TOKEN_ID, TOKEN_SECRET = get_tokens()
|
27
|
-
print(f"โ
Using tokens from proxy server or defaults")
|
27
|
+
# print(f"โ
Using tokens from proxy server or defaults")
|
28
28
|
except ImportError:
|
29
29
|
# If the module is not available, use hardcoded tokens
|
30
|
-
|
31
|
-
TOKEN_SECRET = "as-fPzD0Zm0dl6IFAEkhaH9pq" # Real token secret from fr8mafia profile
|
32
|
-
print(f"โ ๏ธ Using default tokens")
|
30
|
+
# print(f"โ ๏ธ Using default tokens")
|
33
31
|
|
34
|
-
print("๐ง Advanced Modal Token Fixer")
|
32
|
+
# print("๐ง Advanced Modal Token Fixer")
|
35
33
|
|
36
34
|
# Approach 1: Set environment variables
|
37
|
-
print("\n๐ Approach 1: Setting environment variables")
|
35
|
+
# print("\n๐ Approach 1: Setting environment variables")
|
38
36
|
os.environ["MODAL_TOKEN_ID"] = TOKEN_ID
|
39
37
|
os.environ["MODAL_TOKEN_SECRET"] = TOKEN_SECRET
|
40
|
-
print(f"โ
Set MODAL_TOKEN_ID = [HIDDEN]")
|
41
|
-
print(f"โ
Set MODAL_TOKEN_SECRET = [HIDDEN]")
|
38
|
+
# print(f"โ
Set MODAL_TOKEN_ID = [HIDDEN]")
|
39
|
+
# print(f"โ
Set MODAL_TOKEN_SECRET = [HIDDEN]")
|
42
40
|
|
43
41
|
# Approach 2: Create token files in various formats
|
44
|
-
print("\n๐ Approach 2: Creating token files in various formats")
|
42
|
+
# print("\n๐ Approach 2: Creating token files in various formats")
|
45
43
|
modal_dir = Path.home() / ".modal"
|
46
44
|
modal_dir.mkdir(exist_ok=True)
|
47
45
|
|
@@ -53,7 +51,7 @@ with open(token_file, 'w') as f:
|
|
53
51
|
"token_secret": TOKEN_SECRET
|
54
52
|
}
|
55
53
|
json.dump(token_data, f)
|
56
|
-
print(f"โ
Created token file at {token_file}")
|
54
|
+
# print(f"โ
Created token file at {token_file}")
|
57
55
|
|
58
56
|
# Format 2: Alternative token.json format
|
59
57
|
token_file_alt = modal_dir / "token_alt.json"
|
@@ -63,14 +61,14 @@ with open(token_file_alt, 'w') as f:
|
|
63
61
|
"secret": TOKEN_SECRET
|
64
62
|
}
|
65
63
|
json.dump(token_data_alt, f)
|
66
|
-
print(f"โ
Created alternative token file at {token_file_alt}")
|
64
|
+
# print(f"โ
Created alternative token file at {token_file_alt}")
|
67
65
|
|
68
66
|
# Format 3: Create .modalconfig file
|
69
67
|
modalconfig_file = Path.home() / ".modalconfig"
|
70
68
|
with open(modalconfig_file, 'w') as f:
|
71
69
|
f.write(f"token_id = {TOKEN_ID}\n")
|
72
70
|
f.write(f"token_secret = {TOKEN_SECRET}\n")
|
73
|
-
print(f"โ
Created .modalconfig file at {modalconfig_file}")
|
71
|
+
# print(f"โ
Created .modalconfig file at {modalconfig_file}")
|
74
72
|
|
75
73
|
# Format 4: Create config.json file
|
76
74
|
config_file = modal_dir / "config.json"
|
@@ -80,10 +78,10 @@ with open(config_file, 'w') as f:
|
|
80
78
|
"token_secret": TOKEN_SECRET
|
81
79
|
}
|
82
80
|
json.dump(config_data, f)
|
83
|
-
print(f"โ
Created config.json file at {config_file}")
|
81
|
+
# print(f"โ
Created config.json file at {config_file}")
|
84
82
|
|
85
83
|
# Approach 3: Use Modal CLI to set token
|
86
|
-
print("\n๐ Approach 3: Using Modal CLI")
|
84
|
+
# print("\n๐ Approach 3: Using Modal CLI")
|
87
85
|
try:
|
88
86
|
# Use the CLI to set the token directly
|
89
87
|
result = subprocess.run(
|
@@ -92,17 +90,17 @@ try:
|
|
92
90
|
)
|
93
91
|
|
94
92
|
if result.returncode == 0:
|
95
|
-
print(f"โ
Successfully set token via Modal CLI")
|
93
|
+
# print(f"โ
Successfully set token via Modal CLI")
|
96
94
|
else:
|
97
|
-
print(f"โ Failed to set token via Modal CLI: {result.stderr}")
|
95
|
+
# print(f"โ Failed to set token via Modal CLI: {result.stderr}")
|
98
96
|
except Exception as e:
|
99
|
-
print(f"โ Error using Modal CLI: {e}")
|
97
|
+
# print(f"โ Error using Modal CLI: {e}")
|
100
98
|
|
101
99
|
# Approach 4: Use Modal Python API to set token
|
102
|
-
print("\n๐ Approach 4: Using Modal Python API")
|
100
|
+
# print("\n๐ Approach 4: Using Modal Python API")
|
103
101
|
try:
|
104
102
|
import modal
|
105
|
-
print(f"โ
Successfully imported Modal")
|
103
|
+
# print(f"โ
Successfully imported Modal")
|
106
104
|
|
107
105
|
# Try to set token directly in Modal's config
|
108
106
|
try:
|
@@ -114,49 +112,49 @@ try:
|
|
114
112
|
if hasattr(modal.config, '_auth_config'):
|
115
113
|
modal.config._auth_config.token_id = TOKEN_ID
|
116
114
|
modal.config._auth_config.token_secret = TOKEN_SECRET
|
117
|
-
print(f"โ
Set tokens via _auth_config")
|
115
|
+
# print(f"โ
Set tokens via _auth_config")
|
118
116
|
except Exception as e:
|
119
|
-
print(f"โ Error setting tokens via _auth_config: {e}")
|
117
|
+
# print(f"โ Error setting tokens via _auth_config: {e}")
|
120
118
|
|
121
119
|
try:
|
122
120
|
# Approach 4.2: Set token via set_token() if it exists
|
123
121
|
if hasattr(modal.config, 'set_token'):
|
124
122
|
modal.config.set_token(TOKEN_ID, TOKEN_SECRET)
|
125
|
-
print(f"โ
Set tokens via set_token()")
|
123
|
+
# print(f"โ
Set tokens via set_token()")
|
126
124
|
except Exception as e:
|
127
|
-
print(f"โ Error setting tokens via set_token(): {e}")
|
125
|
+
# print(f"โ Error setting tokens via set_token(): {e}")
|
128
126
|
|
129
127
|
try:
|
130
128
|
# Approach 4.3: Set token via Config
|
131
129
|
if hasattr(modal.config, 'Config'):
|
132
130
|
modal.config.Config.token_id = TOKEN_ID
|
133
131
|
modal.config.Config.token_secret = TOKEN_SECRET
|
134
|
-
print(f"โ
Set tokens via Config")
|
132
|
+
# print(f"โ
Set tokens via Config")
|
135
133
|
except Exception as e:
|
136
|
-
print(f"โ Error setting tokens via Config: {e}")
|
134
|
+
# print(f"โ Error setting tokens via Config: {e}")
|
137
135
|
|
138
136
|
# Approach 4.4: Inspect modal.config and try to find token-related attributes
|
139
|
-
print("\n๐ Inspecting modal.config for token-related attributes...")
|
137
|
+
# print("\n๐ Inspecting modal.config for token-related attributes...")
|
140
138
|
for name in dir(modal.config):
|
141
139
|
if "token" in name.lower() or "auth" in name.lower():
|
142
|
-
print(f"Found potential token-related attribute: {name}")
|
140
|
+
# print(f"Found potential token-related attribute: {name}")
|
143
141
|
try:
|
144
142
|
attr = getattr(modal.config, name)
|
145
143
|
if hasattr(attr, "token_id"):
|
146
|
-
print(f" - Setting token_id in {name}")
|
144
|
+
# print(f" - Setting token_id in {name}")
|
147
145
|
setattr(attr, "token_id", TOKEN_ID)
|
148
146
|
if hasattr(attr, "token_secret"):
|
149
|
-
print(f" - Setting token_secret in {name}")
|
147
|
+
# print(f" - Setting token_secret in {name}")
|
150
148
|
setattr(attr, "token_secret", TOKEN_SECRET)
|
151
149
|
except Exception as e:
|
152
|
-
print(f" - Error setting tokens in {name}: {e}")
|
150
|
+
# print(f" - Error setting tokens in {name}: {e}")
|
153
151
|
except Exception as e:
|
154
|
-
print(f"โ Error setting tokens in Modal config: {e}")
|
152
|
+
# print(f"โ Error setting tokens in Modal config: {e}")
|
155
153
|
except Exception as e:
|
156
154
|
print(f"โ Error importing Modal: {e}")
|
157
155
|
|
158
156
|
# Approach 5: Monkey-patch Modal's authentication system
|
159
|
-
print("\n๐ Approach 5: Monkey-patching Modal's authentication system")
|
157
|
+
# print("\n๐ Approach 5: Monkey-patching Modal's authentication system")
|
160
158
|
try:
|
161
159
|
import modal
|
162
160
|
|
@@ -174,7 +172,7 @@ try:
|
|
174
172
|
try:
|
175
173
|
module = getattr(modal, module_name)
|
176
174
|
auth_related.append((module_name, module))
|
177
|
-
print(f"Found potential auth-related module: {module_name}")
|
175
|
+
# print(f"Found potential auth-related module: {module_name}")
|
178
176
|
except Exception:
|
179
177
|
pass
|
180
178
|
|
@@ -187,25 +185,25 @@ try:
|
|
187
185
|
try:
|
188
186
|
original_func = getattr(module, func_name)
|
189
187
|
if callable(original_func):
|
190
|
-
print(f" - Patching {name}.{func_name} to return token_id")
|
188
|
+
# print(f" - Patching {name}.{func_name} to return token_id")
|
191
189
|
setattr(module, func_name, get_token_id)
|
192
190
|
except Exception as e:
|
193
|
-
print(f" - Error patching {name}.{func_name}: {e}")
|
191
|
+
# print(f" - Error patching {name}.{func_name}: {e}")
|
194
192
|
elif "token_secret" in func_name.lower() or "token" in func_name.lower():
|
195
193
|
try:
|
196
194
|
original_func = getattr(module, func_name)
|
197
195
|
if callable(original_func):
|
198
|
-
print(f" - Patching {name}.{func_name} to return token_secret")
|
196
|
+
# print(f" - Patching {name}.{func_name} to return token_secret")
|
199
197
|
setattr(module, func_name, get_token_secret)
|
200
198
|
except Exception as e:
|
201
|
-
print(f" - Error patching {name}.{func_name}: {e}")
|
199
|
+
# print(f" - Error patching {name}.{func_name}: {e}")
|
202
200
|
|
203
|
-
print(f"โ
Monkey-patching completed")
|
201
|
+
# print(f"โ
Monkey-patching completed")
|
204
202
|
except Exception as e:
|
205
|
-
print(f"โ Error during monkey-patching: {e}")
|
203
|
+
# print(f"โ Error during monkey-patching: {e}")
|
206
204
|
|
207
205
|
# Approach 6: Test Modal authentication
|
208
|
-
print("\n๐ Approach 6: Testing Modal authentication")
|
206
|
+
# print("\n๐ Approach 6: Testing Modal authentication")
|
209
207
|
try:
|
210
208
|
import modal
|
211
209
|
|
@@ -217,14 +215,14 @@ try:
|
|
217
215
|
return "Hello, world!"
|
218
216
|
|
219
217
|
# Try to run the function to test authentication
|
220
|
-
print("Creating a test Modal app...")
|
218
|
+
# print("Creating a test Modal app...")
|
221
219
|
with app.run() as running_app:
|
222
|
-
print("Running the test function...")
|
220
|
+
# print("Running the test function...")
|
223
221
|
result = running_app.hello.remote()
|
224
|
-
print(f"โ
Successfully ran Modal function: {result}")
|
225
|
-
print("๐ Modal authentication is working!")
|
222
|
+
# print(f"โ
Successfully ran Modal function: {result}")
|
223
|
+
# print("๐ Modal authentication is working!")
|
226
224
|
|
227
225
|
except Exception as e:
|
228
|
-
print(f"โ Error testing Modal authentication: {e}")
|
226
|
+
# print(f"โ Error testing Modal authentication: {e}")
|
229
227
|
|
230
|
-
print("\nโ
Done fixing Modal token. Please try your command again.")
|
228
|
+
# print("\nโ
Done fixing Modal token. Please try your command again.")
|
@@ -27,19 +27,19 @@ args, unknown = parser.parse_known_args()
|
|
27
27
|
# Set proxy URL and API key in environment variables if provided
|
28
28
|
if args.proxy_url:
|
29
29
|
os.environ["MODAL_PROXY_URL"] = args.proxy_url
|
30
|
-
print(f"โ
Set MODAL_PROXY_URL from command line")
|
30
|
+
# print(f"โ
Set MODAL_PROXY_URL from command line")
|
31
31
|
|
32
32
|
if args.proxy_api_key:
|
33
33
|
os.environ["MODAL_PROXY_API_KEY"] = args.proxy_api_key
|
34
|
-
print(f"โ
Set MODAL_PROXY_API_KEY from command line")
|
34
|
+
# print(f"โ
Set MODAL_PROXY_API_KEY from command line")
|
35
35
|
|
36
36
|
# First, try to fetch tokens from the proxy server
|
37
37
|
try:
|
38
38
|
# Import the fetch_modal_tokens module
|
39
|
-
print("๐ Fetching tokens from proxy server...")
|
39
|
+
# print("๐ Fetching tokens from proxy server...")
|
40
40
|
from fetch_modal_tokens import get_tokens
|
41
41
|
token_id, token_secret = get_tokens()
|
42
|
-
print(f"โ
Tokens fetched successfully")
|
42
|
+
# print(f"โ
Tokens fetched successfully")
|
43
43
|
|
44
44
|
# Explicitly set the environment variables again to be sure
|
45
45
|
os.environ["MODAL_TOKEN_ID"] = token_id
|
@@ -56,26 +56,26 @@ except Exception as e:
|
|
56
56
|
# Apply the comprehensive Modal token solution as fallback
|
57
57
|
try:
|
58
58
|
# Import the comprehensive solution module
|
59
|
-
print("๐ Applying comprehensive Modal token solution...")
|
59
|
+
# print("๐ Applying comprehensive Modal token solution...")
|
60
60
|
import modal_token_solution
|
61
|
-
print("โ
Comprehensive Modal token solution applied")
|
61
|
+
# print("โ
Comprehensive Modal token solution applied")
|
62
62
|
|
63
63
|
# Set token variables for later use
|
64
64
|
token = modal_token_solution.TOKEN_ID # For backward compatibility
|
65
65
|
except Exception as e:
|
66
|
-
print(f"โ ๏ธ Error applying comprehensive Modal token solution: {e}")
|
66
|
+
# print(f"โ ๏ธ Error applying comprehensive Modal token solution: {e}")
|
67
67
|
|
68
68
|
# Fall back to the authentication patch
|
69
69
|
try:
|
70
70
|
# Import the patch module
|
71
|
-
print("๐ Falling back to Modal authentication patch...")
|
71
|
+
# print("๐ Falling back to Modal authentication patch...")
|
72
72
|
import modal_auth_patch
|
73
|
-
print("โ
Modal authentication patch applied")
|
73
|
+
# print("โ
Modal authentication patch applied")
|
74
74
|
|
75
75
|
# Set token variables for later use
|
76
76
|
token = modal_auth_patch.TOKEN_ID # For backward compatibility
|
77
77
|
except Exception as e:
|
78
|
-
print(f"โ ๏ธ Error applying Modal authentication patch: {e}")
|
78
|
+
# print(f"โ ๏ธ Error applying Modal authentication patch: {e}")
|
79
79
|
|
80
80
|
# Fall back to fix_modal_token.py
|
81
81
|
try:
|
@@ -115,17 +115,17 @@ except Exception as e:
|
|
115
115
|
token = "ak-sLhYqCjkvixiYcb9LAuCHp" # Default token ID
|
116
116
|
|
117
117
|
# Print debug info
|
118
|
-
print(f"๐ DEBUG: Checking environment variables")
|
119
|
-
print(f"๐ Token ID exists: {'Yes' if os.environ.get('MODAL_TOKEN_ID') else 'No'}")
|
120
|
-
print(f"๐ Token secret exists: {'Yes' if os.environ.get('MODAL_TOKEN_SECRET') else 'No'}")
|
121
|
-
print(f"๐ Token exists: {'Yes' if os.environ.get('MODAL_TOKEN') else 'No'}")
|
122
|
-
if os.environ.get('MODAL_TOKEN_ID'):
|
123
|
-
|
124
|
-
if os.environ.get('MODAL_TOKEN_SECRET'):
|
125
|
-
|
126
|
-
if os.environ.get('MODAL_TOKEN'):
|
127
|
-
|
128
|
-
print(f"โ
Token setup completed")
|
118
|
+
# print(f"๐ DEBUG: Checking environment variables")
|
119
|
+
# print(f"๐ Token ID exists: {'Yes' if os.environ.get('MODAL_TOKEN_ID') else 'No'}")
|
120
|
+
# print(f"๐ Token secret exists: {'Yes' if os.environ.get('MODAL_TOKEN_SECRET') else 'No'}")
|
121
|
+
# print(f"๐ Token exists: {'Yes' if os.environ.get('MODAL_TOKEN') else 'No'}")
|
122
|
+
# if os.environ.get('MODAL_TOKEN_ID'):
|
123
|
+
# print(f"๐ Token ID length: {len(os.environ.get('MODAL_TOKEN_ID'))}")
|
124
|
+
# if os.environ.get('MODAL_TOKEN_SECRET'):
|
125
|
+
# print(f"๐ Token secret length: {len(os.environ.get('MODAL_TOKEN_SECRET'))}")
|
126
|
+
# if os.environ.get('MODAL_TOKEN'):
|
127
|
+
# print(f"๐ Token length: {len(os.environ.get('MODAL_TOKEN'))}")
|
128
|
+
# print(f"โ
Token setup completed")
|
129
129
|
|
130
130
|
# Import modal after token setup
|
131
131
|
import modal
|
@@ -2025,7 +2025,7 @@ cd "{current_dir}"
|
|
2025
2025
|
print("โณ Sandbox will remain running until you terminate it with:")
|
2026
2026
|
print(f"modal sandbox terminate {sandbox_id}")
|
2027
2027
|
|
2028
|
-
# Try to open a new terminal window and connect to the
|
2028
|
+
# Try to open a new terminal window and connect to the containera
|
2029
2029
|
if container_id:
|
2030
2030
|
print("๐ฅ๏ธ Attempting to open new terminal window...")
|
2031
2031
|
# Use osascript to open a new terminal with the modal shell command
|
@@ -2559,198 +2559,128 @@ def create_modal_ssh_container(gpu_type, repo_url=None, repo_name=None, setup_co
|
|
2559
2559
|
return None
|
2560
2560
|
|
2561
2561
|
def fetch_setup_commands_from_api(repo_url):
|
2562
|
-
"""
|
2562
|
+
"""Generate setup commands locally using GitIngest analysis without API calls."""
|
2563
2563
|
import tempfile
|
2564
2564
|
import subprocess
|
2565
2565
|
import os
|
2566
2566
|
import shutil
|
2567
2567
|
import json
|
2568
2568
|
|
2569
|
-
|
2569
|
+
print(f"๐ Analyzing repository: {repo_url}")
|
2570
2570
|
|
2571
|
-
|
2572
|
-
|
2573
|
-
# Check if gitingest command line tool is available - try multiple possible command names
|
2574
|
-
has_gitingest_cli = False
|
2575
|
-
gitingest_cmd_name = None
|
2576
|
-
|
2577
|
-
# Try the standard command name first
|
2571
|
+
# Check if gitingest command line tool is available
|
2578
2572
|
try:
|
2579
2573
|
print(f"๐ Checking for GitIngest CLI tool...")
|
2580
2574
|
result = subprocess.run(["gitingest", "--help"], check=True, capture_output=True, text=True)
|
2581
|
-
has_gitingest_cli = True
|
2582
|
-
gitingest_cmd_name = "gitingest"
|
2583
2575
|
print(f"โ
GitIngest CLI tool found")
|
2584
2576
|
except (subprocess.SubprocessError, FileNotFoundError) as e:
|
2585
|
-
print(f"
|
2577
|
+
print(f"โ GitIngest CLI tool not found: {str(e)}")
|
2578
|
+
return generate_fallback_commands(None)
|
2586
2579
|
|
2587
2580
|
# Create a temporary directory for output
|
2588
2581
|
temp_dir = tempfile.mkdtemp(prefix="repo_analysis_")
|
2589
2582
|
output_file = os.path.join(temp_dir, "digest.json")
|
2590
2583
|
|
2591
2584
|
try:
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
# Run gitingest command with proper parameters
|
2603
|
-
gitingest_run_cmd = [
|
2604
|
-
gitingest_cmd_name,
|
2605
|
-
repo_url,
|
2606
|
-
"-o", output_file, # Use -o for output file
|
2607
|
-
]
|
2608
|
-
|
2609
|
-
print(f"๐ Executing: {' '.join(gitingest_run_cmd)}")
|
2610
|
-
|
2611
|
-
result = subprocess.run(gitingest_run_cmd, capture_output=True, text=True)
|
2612
|
-
|
2613
|
-
if result.returncode != 0:
|
2614
|
-
print(f"โ ๏ธ GitIngest CLI failed with exit code {result.returncode}")
|
2615
|
-
print(f"โ ๏ธ Error output: {result.stderr}")
|
2616
|
-
print("Falling back to basic analysis")
|
2617
|
-
gitingest_data = generate_basic_repo_analysis_from_url(repo_url)
|
2618
|
-
else:
|
2619
|
-
print(f"โ
GitIngest analysis completed successfully")
|
2620
|
-
|
2621
|
-
# Read the output file - note that the default format might not be JSON
|
2622
|
-
try:
|
2623
|
-
# First try to parse as JSON
|
2624
|
-
try:
|
2625
|
-
with open(output_file, 'r', encoding='utf-8') as f:
|
2626
|
-
content = f.read()
|
2627
|
-
try:
|
2628
|
-
gitingest_data = json.loads(content)
|
2629
|
-
print(f"โ
GitIngest data loaded as JSON from {output_file}")
|
2630
|
-
except json.JSONDecodeError:
|
2631
|
-
# If not JSON, convert the text output to a basic structure
|
2632
|
-
print(f"โ ๏ธ GitIngest output is not in JSON format, converting text to structure")
|
2633
|
-
gitingest_data = {
|
2634
|
-
"system_info": {
|
2635
|
-
"detected_language": "Unknown",
|
2636
|
-
"detected_technologies": [],
|
2637
|
-
},
|
2638
|
-
"repository_analysis": {
|
2639
|
-
"summary": content[:5000], # First 5000 chars as summary
|
2640
|
-
"content_preview": content[:10000] # First 10000 chars as preview
|
2641
|
-
},
|
2642
|
-
"success": True
|
2643
|
-
}
|
2644
|
-
except FileNotFoundError:
|
2645
|
-
print(f"โ ๏ธ Output file not found at {output_file}")
|
2646
|
-
gitingest_data = generate_basic_repo_analysis_from_url(repo_url)
|
2647
|
-
except Exception as e:
|
2648
|
-
print(f"โ ๏ธ Error reading GitIngest output: {e}")
|
2649
|
-
gitingest_data = generate_basic_repo_analysis_from_url(repo_url)
|
2650
|
-
else:
|
2651
|
-
# Fall back to basic analysis if gitingest CLI is not available
|
2652
|
-
gitingest_data = generate_basic_repo_analysis_from_url(repo_url)
|
2653
|
-
|
2654
|
-
# Prepare the request payload with GitIngest data
|
2655
|
-
payload = {
|
2656
|
-
"repoUrl": repo_url,
|
2657
|
-
"gitingestData": gitingest_data,
|
2658
|
-
"userRequest": "Setup and run the repository"
|
2659
|
-
}
|
2585
|
+
# Use gitingest CLI tool to analyze the repository directly from URL
|
2586
|
+
print(f"๐ Running GitIngest analysis on {repo_url}...")
|
2587
|
+
|
2588
|
+
# Run gitingest command with proper parameters
|
2589
|
+
gitingest_run_cmd = [
|
2590
|
+
"gitingest",
|
2591
|
+
repo_url,
|
2592
|
+
"-o", output_file,
|
2593
|
+
]
|
2660
2594
|
|
2661
|
-
print(f"
|
2595
|
+
print(f"๐ Executing: {' '.join(gitingest_run_cmd)}")
|
2662
2596
|
|
2663
|
-
|
2664
|
-
|
2597
|
+
result = subprocess.run(gitingest_run_cmd, capture_output=True, text=True)
|
2598
|
+
|
2599
|
+
if result.returncode != 0:
|
2600
|
+
print(f"โ ๏ธ GitIngest CLI failed with exit code {result.returncode}")
|
2601
|
+
print(f"โ ๏ธ Error output: {result.stderr}")
|
2602
|
+
print("Falling back to basic analysis")
|
2603
|
+
return generate_fallback_commands(None)
|
2604
|
+
|
2605
|
+
print(f"โ
GitIngest analysis completed successfully")
|
2606
|
+
|
2607
|
+
# Read the output file - GitIngest outputs structured text, not JSON
|
2665
2608
|
try:
|
2666
|
-
|
2609
|
+
with open(output_file, 'r', encoding='utf-8') as f:
|
2610
|
+
content = f.read()
|
2611
|
+
|
2612
|
+
# Process the text output into a structured format
|
2613
|
+
print(f"๐ Processing GitIngest text output")
|
2614
|
+
|
2615
|
+
# Extract key information from the text output
|
2616
|
+
import re
|
2617
|
+
|
2618
|
+
# Try to identify language
|
2619
|
+
language_match = re.search(r"(?i)language[s]?:?\s*(\w+)", content)
|
2620
|
+
detected_language = language_match.group(1) if language_match else "Unknown"
|
2621
|
+
|
2622
|
+
# Try to identify technologies
|
2623
|
+
tech_patterns = {
|
2624
|
+
"python": r"(?i)(python|\.py\b|pip\b|requirements\.txt|setup\.py)",
|
2625
|
+
"javascript": r"(?i)(javascript|\.js\b|node|npm|yarn|package\.json)",
|
2626
|
+
"typescript": r"(?i)(typescript|\.ts\b|tsc\b|tsconfig\.json)",
|
2627
|
+
"go": r"(?i)(\bgo\b|golang|\.go\b|go\.mod|go\.sum)",
|
2628
|
+
"rust": r"(?i)(rust|\.rs\b|cargo|Cargo\.toml)",
|
2629
|
+
"java": r"(?i)(java\b|\.java\b|maven|gradle|pom\.xml)",
|
2630
|
+
"c++": r"(?i)(c\+\+|\.cpp\b|\.hpp\b|cmake\b|CMakeLists\.txt)",
|
2631
|
+
"pytorch": r"(?i)(pytorch|torch\b|nn\.Module)",
|
2632
|
+
"tensorflow": r"(?i)(tensorflow|tf\.|keras\b)",
|
2633
|
+
}
|
2667
2634
|
|
2668
|
-
|
2635
|
+
detected_technologies = []
|
2636
|
+
for tech, pattern in tech_patterns.items():
|
2637
|
+
if re.search(pattern, content):
|
2638
|
+
detected_technologies.append(tech)
|
2669
2639
|
|
2670
|
-
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2676
|
-
|
2677
|
-
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
except Exception as e:
|
2698
|
-
print(f"โ ๏ธ Error finding entry point: {e}")
|
2699
|
-
|
2700
|
-
# Print the fixed commands
|
2701
|
-
print("\n๐ Fixed commands:")
|
2702
|
-
for i, cmd in enumerate(fixed_commands, 1):
|
2703
|
-
print(f" {i}. {cmd}")
|
2704
|
-
|
2705
|
-
return fixed_commands
|
2706
|
-
else:
|
2707
|
-
print("โ ๏ธ API response did not contain setupInstructions.commands field")
|
2708
|
-
print("๐ Available fields in response:")
|
2709
|
-
for key in data.keys():
|
2710
|
-
print(f" - {key}")
|
2711
|
-
# Return fallback commands
|
2712
|
-
return generate_fallback_commands(gitingest_data)
|
2713
|
-
except json.JSONDecodeError as e:
|
2714
|
-
print(f"โ Failed to parse API response as JSON: {e}")
|
2715
|
-
print(f"Raw response: {response.text[:500]}...")
|
2716
|
-
# Return fallback commands
|
2717
|
-
return generate_fallback_commands(gitingest_data)
|
2718
|
-
elif response.status_code == 504:
|
2719
|
-
print(f"โ API request timed out (504 Gateway Timeout)")
|
2720
|
-
print("โ ๏ธ The server took too long to respond. Using fallback commands instead.")
|
2721
|
-
# Return fallback commands
|
2722
|
-
return generate_fallback_commands(gitingest_data)
|
2723
|
-
else:
|
2724
|
-
print(f"โ API request failed with status code: {response.status_code}")
|
2725
|
-
print(f"Error response: {response.text[:500]}...")
|
2726
|
-
# Return fallback commands
|
2727
|
-
return generate_fallback_commands(gitingest_data)
|
2728
|
-
except requests.exceptions.Timeout:
|
2729
|
-
print("โ API request timed out after 60 seconds")
|
2730
|
-
print("โ ๏ธ Using fallback commands instead")
|
2731
|
-
# Return fallback commands
|
2732
|
-
return generate_fallback_commands(gitingest_data)
|
2733
|
-
except requests.exceptions.ConnectionError:
|
2734
|
-
print(f"โ Connection error: Could not connect to {api_url}")
|
2735
|
-
print("โ ๏ธ Using fallback commands instead")
|
2736
|
-
# Return fallback commands
|
2737
|
-
return generate_fallback_commands(gitingest_data)
|
2738
|
-
except Exception as e:
|
2739
|
-
print(f"โ Error fetching setup commands from API: {e}")
|
2740
|
-
import traceback
|
2741
|
-
traceback.print_exc()
|
2742
|
-
# Return fallback commands
|
2743
|
-
return generate_fallback_commands(None)
|
2640
|
+
# Create a structured representation
|
2641
|
+
gitingest_data = {
|
2642
|
+
"system_info": {
|
2643
|
+
"detected_language": detected_language,
|
2644
|
+
"detected_technologies": detected_technologies,
|
2645
|
+
},
|
2646
|
+
"repository_analysis": {
|
2647
|
+
"summary": content[:1000], # First 1000 chars as summary
|
2648
|
+
"content_preview": content[:5000] # First 5000 chars as preview
|
2649
|
+
},
|
2650
|
+
"raw_text": content[:10000], # Include a portion of the raw text
|
2651
|
+
"success": True
|
2652
|
+
}
|
2653
|
+
|
2654
|
+
print(f"๐ Processed GitIngest output: Detected language: {detected_language}, Technologies: {', '.join(detected_technologies) if detected_technologies else 'None'}")
|
2655
|
+
|
2656
|
+
# Generate commands locally based on the analysis
|
2657
|
+
print(f"๐ง Generating setup commands locally based on repository analysis")
|
2658
|
+
setup_commands = generate_fallback_commands(gitingest_data)
|
2659
|
+
return setup_commands
|
2660
|
+
|
2661
|
+
except FileNotFoundError:
|
2662
|
+
print(f"โ ๏ธ Output file not found at {output_file}")
|
2663
|
+
return generate_fallback_commands(None)
|
2664
|
+
except Exception as e:
|
2665
|
+
print(f"โ ๏ธ Error processing GitIngest output: {e}")
|
2666
|
+
return generate_fallback_commands(None)
|
2744
2667
|
finally:
|
2745
|
-
# Clean up
|
2668
|
+
# Clean up temporary directory
|
2746
2669
|
print(f"๐งน Cleaning up temporary directory...")
|
2747
|
-
|
2670
|
+
try:
|
2671
|
+
shutil.rmtree(temp_dir)
|
2672
|
+
except Exception as e:
|
2673
|
+
print(f"โ ๏ธ Error cleaning up temporary directory: {e}")
|
2674
|
+
|
2675
|
+
# If all else fails, return basic setup commands
|
2676
|
+
return [
|
2677
|
+
"apt-get update -y",
|
2678
|
+
"apt-get install -y git curl wget",
|
2679
|
+
"pip install --upgrade pip setuptools wheel"
|
2680
|
+
]
|
2748
2681
|
|
2749
2682
|
def generate_fallback_commands(gitingest_data):
|
2750
2683
|
"""Generate fallback setup commands based on repository analysis"""
|
2751
|
-
print("\n" + "="*80)
|
2752
|
-
print("๐ GENERATING FALLBACK SETUP COMMANDS")
|
2753
|
-
print("="*80)
|
2754
2684
|
print("Using basic repository analysis to generate setup commands")
|
2755
2685
|
|
2756
2686
|
# Default commands that work for most repositories
|
@@ -2770,6 +2700,28 @@ def generate_fallback_commands(gitingest_data):
|
|
2770
2700
|
detected_technologies = gitingest_data.get("system_info", {}).get("detected_technologies", [])
|
2771
2701
|
primary_package_manager = gitingest_data.get("system_info", {}).get("primary_package_manager", "Unknown")
|
2772
2702
|
|
2703
|
+
# Extract more information from raw text if available
|
2704
|
+
if "raw_text" in gitingest_data and gitingest_data["raw_text"]:
|
2705
|
+
raw_text = gitingest_data["raw_text"]
|
2706
|
+
|
2707
|
+
# Look for additional technologies in raw text
|
2708
|
+
import re
|
2709
|
+
tech_patterns = {
|
2710
|
+
"python": r"(?i)(python|\.py\b|pip\b|requirements\.txt|setup\.py)",
|
2711
|
+
"javascript": r"(?i)(javascript|\.js\b|node|npm|yarn|package\.json)",
|
2712
|
+
"typescript": r"(?i)(typescript|\.ts\b|tsc\b|tsconfig\.json)",
|
2713
|
+
"go": r"(?i)(\bgo\b|golang|\.go\b|go\.mod|go\.sum)",
|
2714
|
+
"rust": r"(?i)(rust|\.rs\b|cargo|Cargo\.toml)",
|
2715
|
+
"java": r"(?i)(java\b|\.java\b|maven|gradle|pom\.xml)",
|
2716
|
+
"c++": r"(?i)(c\+\+|\.cpp\b|\.hpp\b|cmake\b|CMakeLists\.txt)",
|
2717
|
+
"pytorch": r"(?i)(pytorch|torch\b|nn\.Module)",
|
2718
|
+
"tensorflow": r"(?i)(tensorflow|tf\.|keras\b)",
|
2719
|
+
}
|
2720
|
+
|
2721
|
+
for tech, pattern in tech_patterns.items():
|
2722
|
+
if re.search(pattern, raw_text) and tech.lower() not in [t.lower() for t in detected_technologies]:
|
2723
|
+
detected_technologies.append(tech)
|
2724
|
+
|
2773
2725
|
# Add language-specific commands
|
2774
2726
|
language_commands = []
|
2775
2727
|
|
@@ -2777,12 +2729,21 @@ def generate_fallback_commands(gitingest_data):
|
|
2777
2729
|
print(f"๐ Detected technologies: {', '.join(detected_technologies) if detected_technologies else 'None'}")
|
2778
2730
|
print(f"๐ Detected package manager: {primary_package_manager}")
|
2779
2731
|
|
2732
|
+
# Check for specific technologies and add appropriate commands
|
2733
|
+
has_python = any(tech.lower() == "python" for tech in detected_technologies) or detected_language.lower() == "python"
|
2734
|
+
has_js = any(tech.lower() in ["javascript", "node", "nodejs"] for tech in detected_technologies)
|
2735
|
+
has_ts = any(tech.lower() == "typescript" for tech in detected_technologies)
|
2736
|
+
has_go = any(tech.lower() in ["go", "golang"] for tech in detected_technologies)
|
2737
|
+
has_pytorch = any(tech.lower() in ["pytorch", "torch"] for tech in detected_technologies)
|
2738
|
+
has_tensorflow = any(tech.lower() == "tensorflow" for tech in detected_technologies)
|
2739
|
+
|
2780
2740
|
# Python-specific commands
|
2781
|
-
if
|
2741
|
+
if has_python:
|
2782
2742
|
print("๐ฆ Adding Python-specific setup commands")
|
2743
|
+
language_commands.append("apt-get install -y python3 python3-pip python3-dev")
|
2783
2744
|
|
2784
2745
|
# Check for requirements.txt
|
2785
|
-
|
2746
|
+
language_commands.extend([
|
2786
2747
|
"if [ -f requirements.txt ]; then",
|
2787
2748
|
" echo 'Installing from requirements.txt'",
|
2788
2749
|
" pip install -r requirements.txt",
|
@@ -2790,72 +2751,56 @@ def generate_fallback_commands(gitingest_data):
|
|
2790
2751
|
" echo 'Installing from setup.py'",
|
2791
2752
|
" pip install -e .",
|
2792
2753
|
"fi"
|
2793
|
-
]
|
2794
|
-
language_commands.extend(requirements_check)
|
2795
|
-
|
2796
|
-
# Add common Python packages
|
2797
|
-
language_commands.append("pip install pytest numpy pandas matplotlib")
|
2754
|
+
])
|
2798
2755
|
|
2799
2756
|
# JavaScript/Node.js specific commands
|
2800
|
-
|
2757
|
+
if has_js or has_ts:
|
2801
2758
|
print("๐ฆ Adding JavaScript/Node.js-specific setup commands")
|
2759
|
+
language_commands.append("curl -fsSL https://deb.nodesource.com/setup_18.x | bash -")
|
2760
|
+
language_commands.append("apt-get install -y nodejs")
|
2802
2761
|
|
2803
|
-
# Install
|
2804
|
-
|
2762
|
+
# Install TypeScript if detected
|
2763
|
+
if has_ts:
|
2764
|
+
language_commands.append("npm install -g typescript ts-node")
|
2805
2765
|
|
2806
2766
|
# Check for package.json
|
2807
|
-
|
2767
|
+
language_commands.extend([
|
2808
2768
|
"if [ -f package.json ]; then",
|
2809
|
-
" echo 'Installing
|
2769
|
+
" echo 'Installing npm dependencies'",
|
2810
2770
|
" npm install",
|
2811
2771
|
"fi"
|
2812
|
-
]
|
2813
|
-
language_commands.extend(package_json_check)
|
2814
|
-
|
2815
|
-
# Java specific commands
|
2816
|
-
elif detected_language == "Java" or primary_package_manager in ["maven", "gradle"]:
|
2817
|
-
print("๐ฆ Adding Java-specific setup commands")
|
2818
|
-
|
2819
|
-
language_commands.append("apt-get install -y openjdk-11-jdk maven gradle")
|
2820
|
-
|
2821
|
-
# Check for Maven or Gradle
|
2822
|
-
build_check = [
|
2823
|
-
"if [ -f pom.xml ]; then",
|
2824
|
-
" echo 'Building with Maven'",
|
2825
|
-
" mvn clean install -DskipTests",
|
2826
|
-
"elif [ -f build.gradle ]; then",
|
2827
|
-
" echo 'Building with Gradle'",
|
2828
|
-
" gradle build --no-daemon",
|
2829
|
-
"fi"
|
2830
|
-
]
|
2831
|
-
language_commands.extend(build_check)
|
2772
|
+
])
|
2832
2773
|
|
2833
|
-
# Go
|
2834
|
-
|
2774
|
+
# Go-specific commands
|
2775
|
+
if has_go:
|
2835
2776
|
print("๐ฆ Adding Go-specific setup commands")
|
2836
|
-
|
2837
|
-
language_commands.
|
2838
|
-
|
2777
|
+
language_commands.append("apt-get install -y golang")
|
2778
|
+
language_commands.extend([
|
2779
|
+
"if [ -f go.mod ]; then",
|
2780
|
+
" echo 'Installing Go dependencies'",
|
2781
|
+
" go mod download",
|
2782
|
+
"fi"
|
2783
|
+
])
|
2839
2784
|
|
2840
|
-
#
|
2841
|
-
|
2842
|
-
print("๐ฆ Adding
|
2843
|
-
|
2844
|
-
language_commands.append("curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y")
|
2845
|
-
language_commands.append("source $HOME/.cargo/env")
|
2846
|
-
language_commands.append("cargo build")
|
2785
|
+
# PyTorch-specific commands
|
2786
|
+
if has_pytorch:
|
2787
|
+
print("๐ฆ Adding PyTorch-specific setup commands")
|
2788
|
+
language_commands.append("pip install torch torchvision torchaudio")
|
2847
2789
|
|
2848
|
-
#
|
2849
|
-
|
2790
|
+
# TensorFlow-specific commands
|
2791
|
+
if has_tensorflow:
|
2792
|
+
print("๐ฆ Adding TensorFlow-specific setup commands")
|
2793
|
+
language_commands.append("pip install tensorflow tensorflow-gpu")
|
2850
2794
|
|
2851
|
-
#
|
2852
|
-
|
2795
|
+
# Combine default commands with language-specific commands
|
2796
|
+
all_commands = default_commands + language_commands
|
2853
2797
|
|
2798
|
+
# Print the generated commands
|
2854
2799
|
print("\n๐ Generated fallback setup commands:")
|
2855
|
-
for i, cmd in enumerate(
|
2800
|
+
for i, cmd in enumerate(all_commands, 1):
|
2856
2801
|
print(f" {i}. {cmd}")
|
2857
2802
|
|
2858
|
-
return
|
2803
|
+
return all_commands
|
2859
2804
|
|
2860
2805
|
def generate_basic_repo_analysis_from_url(repo_url):
|
2861
2806
|
"""Generate basic repository analysis data from a repository URL."""
|
@@ -3309,24 +3254,24 @@ def cleanup_modal_token():
|
|
3309
3254
|
# Remove token from environment variables
|
3310
3255
|
if "MODAL_TOKEN_ID" in os.environ:
|
3311
3256
|
del os.environ["MODAL_TOKEN_ID"]
|
3312
|
-
print("โ
Removed token ID from environment")
|
3257
|
+
# print("โ
Removed token ID from environment")
|
3313
3258
|
|
3314
3259
|
if "MODAL_TOKEN" in os.environ:
|
3315
3260
|
del os.environ["MODAL_TOKEN"]
|
3316
|
-
print("โ
Removed token from environment")
|
3261
|
+
# print("โ
Removed token from environment")
|
3317
3262
|
|
3318
3263
|
if "MODAL_TOKEN_SECRET" in os.environ:
|
3319
3264
|
del os.environ["MODAL_TOKEN_SECRET"]
|
3320
|
-
print("โ
Removed token secret from environment")
|
3265
|
+
# print("โ
Removed token secret from environment")
|
3321
3266
|
|
3322
3267
|
# Delete ~/.modal.toml file
|
3323
3268
|
home_dir = os.path.expanduser("~")
|
3324
3269
|
modal_toml = os.path.join(home_dir, ".modal.toml")
|
3325
3270
|
if os.path.exists(modal_toml):
|
3326
3271
|
os.remove(modal_toml)
|
3327
|
-
print(f"โ
Deleted token file at {modal_toml}")
|
3272
|
+
# print(f"โ
Deleted token file at {modal_toml}")
|
3328
3273
|
|
3329
|
-
print("โ
Token cleanup completed successfully")
|
3274
|
+
# print("โ
Token cleanup completed successfully")
|
3330
3275
|
except Exception as e:
|
3331
3276
|
print(f"โ Error during token cleanup: {e}")
|
3332
3277
|
|
@@ -3492,12 +3437,12 @@ if __name__ == "__main__":
|
|
3492
3437
|
ssh_password=ssh_password
|
3493
3438
|
)
|
3494
3439
|
except KeyboardInterrupt:
|
3495
|
-
print("\n\n๐ Execution interrupted")
|
3496
|
-
print("๐งน Cleaning up resources...")
|
3440
|
+
# print("\n\n๐ Execution interrupted")
|
3441
|
+
# print("๐งน Cleaning up resources...")
|
3497
3442
|
cleanup_modal_token()
|
3498
3443
|
sys.exit(1)
|
3499
3444
|
except Exception as e:
|
3500
|
-
print(f"\nโ Error: {e}")
|
3501
|
-
print("๐งน Cleaning up resources...")
|
3445
|
+
# print(f"\nโ Error: {e}")
|
3446
|
+
# print("๐งน Cleaning up resources...")
|
3502
3447
|
cleanup_modal_token()
|
3503
3448
|
sys.exit(1)
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
"""
|
3
|
-
This script removes emojis from the test_modalSandboxScript.py file to fix syntax errors.
|
4
|
-
"""
|
5
|
-
|
6
|
-
import re
|
7
|
-
import sys
|
8
|
-
import shutil
|
9
|
-
from pathlib import Path
|
10
|
-
|
11
|
-
def remove_emojis(script_path):
|
12
|
-
"""
|
13
|
-
Remove emojis from the Python script to fix syntax errors.
|
14
|
-
"""
|
15
|
-
print(f"Removing emojis from {script_path}...")
|
16
|
-
|
17
|
-
# Make a backup of the original file
|
18
|
-
backup_path = f"{script_path}.emoji_backup"
|
19
|
-
shutil.copy2(script_path, backup_path)
|
20
|
-
|
21
|
-
# Read the file
|
22
|
-
with open(script_path, 'r', encoding='utf-8', errors='ignore') as f:
|
23
|
-
content = f.read()
|
24
|
-
|
25
|
-
# Emoji pattern - matches most common emoji characters
|
26
|
-
emoji_pattern = re.compile(
|
27
|
-
"["
|
28
|
-
"\U0001F1E0-\U0001F1FF" # flags (iOS)
|
29
|
-
"\U0001F300-\U0001F5FF" # symbols & pictographs
|
30
|
-
"\U0001F600-\U0001F64F" # emoticons
|
31
|
-
"\U0001F680-\U0001F6FF" # transport & map symbols
|
32
|
-
"\U0001F700-\U0001F77F" # alchemical symbols
|
33
|
-
"\U0001F780-\U0001F7FF" # Geometric Shapes
|
34
|
-
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
|
35
|
-
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
|
36
|
-
"\U0001FA00-\U0001FA6F" # Chess Symbols
|
37
|
-
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
|
38
|
-
"\U00002702-\U000027B0" # Dingbats
|
39
|
-
"\U000024C2-\U0001F251"
|
40
|
-
"]+", flags=re.UNICODE)
|
41
|
-
|
42
|
-
# Simply remove all emojis
|
43
|
-
content = emoji_pattern.sub('', content)
|
44
|
-
|
45
|
-
# Fix common syntax issues after emoji removal
|
46
|
-
content = re.sub(r'print\(\s*\)', r'print()', content)
|
47
|
-
content = re.sub(r'print\(\s*"', r'print("', content)
|
48
|
-
|
49
|
-
# Fix specific syntax errors
|
50
|
-
content = re.sub(r'print\(\s*container\'s', r'print("container\'s', content)
|
51
|
-
|
52
|
-
# Write the modified content back to the file
|
53
|
-
with open(script_path, 'w', encoding='utf-8') as f:
|
54
|
-
f.write(content)
|
55
|
-
|
56
|
-
print(f"Emoji removal complete. Original file backed up to {backup_path}")
|
57
|
-
return True
|
58
|
-
|
59
|
-
def main():
|
60
|
-
"""
|
61
|
-
Main entry point for the script.
|
62
|
-
"""
|
63
|
-
# Get the path to the script
|
64
|
-
script_dir = Path(__file__).parent
|
65
|
-
script_path = script_dir / "test_modalSandboxScript.py"
|
66
|
-
|
67
|
-
if not script_path.exists():
|
68
|
-
print(f"Error: Script not found at {script_path}")
|
69
|
-
return 1
|
70
|
-
|
71
|
-
try:
|
72
|
-
remove_emojis(script_path)
|
73
|
-
return 0
|
74
|
-
except Exception as e:
|
75
|
-
print(f"Error removing emojis: {e}")
|
76
|
-
return 1
|
77
|
-
|
78
|
-
if __name__ == "__main__":
|
79
|
-
sys.exit(main())
|