Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,10 +109,23 @@ def extract_stock_info(text):
|
|
| 109 |
def save_cookies(file):
|
| 110 |
if file is None:
|
| 111 |
return None
|
|
|
|
| 112 |
temp_path = tempfile.mktemp(suffix=".txt")
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
# ✅ Full pipeline with error traceback
|
| 118 |
|
|
|
|
| 109 |
def save_cookies(file):
|
| 110 |
if file is None:
|
| 111 |
return None
|
| 112 |
+
|
| 113 |
temp_path = tempfile.mktemp(suffix=".txt")
|
| 114 |
+
|
| 115 |
+
try:
|
| 116 |
+
# Handle both file-like object and NamedString
|
| 117 |
+
if hasattr(file, "read"): # File-like
|
| 118 |
+
with open(temp_path, "wb") as f:
|
| 119 |
+
f.write(file.read())
|
| 120 |
+
else: # NamedString (str path)
|
| 121 |
+
shutil.copy(file, temp_path)
|
| 122 |
+
|
| 123 |
+
return temp_path
|
| 124 |
+
|
| 125 |
+
except Exception as e:
|
| 126 |
+
print(f"❌ Failed to handle cookies.txt: {e}")
|
| 127 |
+
return None
|
| 128 |
+
|
| 129 |
|
| 130 |
# ✅ Full pipeline with error traceback
|
| 131 |
|