Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -62,22 +62,27 @@ class Program
|
|
62 |
cs_path
|
63 |
]
|
64 |
|
|
|
65 |
compile_result = subprocess.run(compile_cmd, capture_output=True, text=True)
|
66 |
if compile_result.returncode != 0:
|
67 |
-
print(f"
|
68 |
return None
|
|
|
69 |
|
70 |
# Create ZIP
|
71 |
zip_cmd = ['zip', '-j', zip_path, exe_path]
|
|
|
72 |
zip_result = subprocess.run(zip_cmd, capture_output=True, text=True)
|
73 |
if zip_result.returncode != 0:
|
74 |
-
print(f"ZIP error: {zip_result.stderr}")
|
75 |
return None
|
|
|
76 |
|
77 |
# Cleanup temporary files
|
78 |
try:
|
79 |
os.remove(cs_path)
|
80 |
os.remove(exe_path)
|
|
|
81 |
except Exception as e:
|
82 |
print(f"Cleanup error: {e}")
|
83 |
|
@@ -86,13 +91,13 @@ class Program
|
|
86 |
if old_file != Path(zip_path):
|
87 |
try:
|
88 |
os.remove(old_file)
|
89 |
-
except:
|
90 |
-
|
91 |
|
92 |
return zip_path
|
93 |
|
94 |
except Exception as e:
|
95 |
-
print(f"
|
96 |
return None
|
97 |
|
98 |
def get_current_zip():
|
@@ -159,4 +164,3 @@ if __name__ == '__main__':
|
|
159 |
print("No existing ZIP file found, creating initial file...")
|
160 |
compile_and_zip()
|
161 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
162 |
-
|
|
|
62 |
cs_path
|
63 |
]
|
64 |
|
65 |
+
print(f"Running compile command: {' '.join(compile_cmd)}")
|
66 |
compile_result = subprocess.run(compile_cmd, capture_output=True, text=True)
|
67 |
if compile_result.returncode != 0:
|
68 |
+
print(f"Compilation failed with error: {compile_result.stderr}")
|
69 |
return None
|
70 |
+
print(f"Compilation succeeded. Executable created at: {exe_path}")
|
71 |
|
72 |
# Create ZIP
|
73 |
zip_cmd = ['zip', '-j', zip_path, exe_path]
|
74 |
+
print(f"Running ZIP command: {' '.join(zip_cmd)}")
|
75 |
zip_result = subprocess.run(zip_cmd, capture_output=True, text=True)
|
76 |
if zip_result.returncode != 0:
|
77 |
+
print(f"ZIP creation failed with error: {zip_result.stderr}")
|
78 |
return None
|
79 |
+
print(f"ZIP creation succeeded. File created at: {zip_path}")
|
80 |
|
81 |
# Cleanup temporary files
|
82 |
try:
|
83 |
os.remove(cs_path)
|
84 |
os.remove(exe_path)
|
85 |
+
print("Temporary files cleaned up.")
|
86 |
except Exception as e:
|
87 |
print(f"Cleanup error: {e}")
|
88 |
|
|
|
91 |
if old_file != Path(zip_path):
|
92 |
try:
|
93 |
os.remove(old_file)
|
94 |
+
except Exception as e:
|
95 |
+
print(f"Error removing old file {old_file}: {e}")
|
96 |
|
97 |
return zip_path
|
98 |
|
99 |
except Exception as e:
|
100 |
+
print(f"Unexpected error during compilation: {str(e)}")
|
101 |
return None
|
102 |
|
103 |
def get_current_zip():
|
|
|
164 |
print("No existing ZIP file found, creating initial file...")
|
165 |
compile_and_zip()
|
166 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
|