Spaces:
Sleeping
Sleeping
Replaced the cleaning of temp
Browse files
app.py
CHANGED
|
@@ -209,7 +209,20 @@ def reduce_and_convert(input_folder):
|
|
| 209 |
|
| 210 |
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
def ui(input_files):
|
|
|
|
| 213 |
output_zip = "./output.zip"
|
| 214 |
if os.path.exists(output_zip):
|
| 215 |
os.remove(output_zip)
|
|
@@ -229,18 +242,6 @@ def ui(input_files):
|
|
| 229 |
return output_zip
|
| 230 |
|
| 231 |
|
| 232 |
-
def clear_gradio_temp():
|
| 233 |
-
temp_dir = tempfile.gettempdir() # Get system temp directory
|
| 234 |
-
for folder in os.listdir(temp_dir):
|
| 235 |
-
folder_path = os.path.join(temp_dir, folder)
|
| 236 |
-
if "gradio" in folder_path.lower(): # Identify Gradio temp folders
|
| 237 |
-
try:
|
| 238 |
-
shutil.rmtree(folder_path) # Remove folder and contents
|
| 239 |
-
print(f"Deleted: {folder_path}")
|
| 240 |
-
except Exception as e:
|
| 241 |
-
print(f"Failed to delete {folder_path}: {e}")
|
| 242 |
-
|
| 243 |
-
|
| 244 |
|
| 245 |
with gr.Blocks() as appli:
|
| 246 |
gr.Markdown("## CBCR PDF to Excel Conversion Tool")
|
|
@@ -250,6 +251,5 @@ with gr.Blocks() as appli:
|
|
| 250 |
|
| 251 |
process_button.click(fn=ui, inputs=input_files, outputs=download_link)
|
| 252 |
|
| 253 |
-
clear_gradio_temp()
|
| 254 |
appli.launch()
|
| 255 |
|
|
|
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
+
|
| 213 |
+
def clear_gradio_temp():
|
| 214 |
+
temp_dir = tempfile.gettempdir() # Get system temp directory
|
| 215 |
+
for folder in os.listdir(temp_dir):
|
| 216 |
+
folder_path = os.path.join(temp_dir, folder)
|
| 217 |
+
if "gradio" in folder_path.lower(): # Identify Gradio temp folders
|
| 218 |
+
try:
|
| 219 |
+
shutil.rmtree(folder_path) # Remove folder and contents
|
| 220 |
+
print(f"Deleted: {folder_path}")
|
| 221 |
+
except Exception as e:
|
| 222 |
+
print(f"Failed to delete {folder_path}: {e}")
|
| 223 |
+
|
| 224 |
def ui(input_files):
|
| 225 |
+
clear_gradio_temp()
|
| 226 |
output_zip = "./output.zip"
|
| 227 |
if os.path.exists(output_zip):
|
| 228 |
os.remove(output_zip)
|
|
|
|
| 242 |
return output_zip
|
| 243 |
|
| 244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
with gr.Blocks() as appli:
|
| 247 |
gr.Markdown("## CBCR PDF to Excel Conversion Tool")
|
|
|
|
| 251 |
|
| 252 |
process_button.click(fn=ui, inputs=input_files, outputs=download_link)
|
| 253 |
|
|
|
|
| 254 |
appli.launch()
|
| 255 |
|