Update utils.py
Browse files
utils.py
CHANGED
|
@@ -158,6 +158,11 @@ def formatera_historik_html(historik: list) -> str:
|
|
| 158 |
|
| 159 |
def spara_nedladdning(innehall: str) -> Optional[str]:
|
| 160 |
"""Save text file for download"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
try:
|
| 162 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 163 |
path = os.path.join(Config.TEMP_DIR, f"vips_anteckning_{timestamp}.txt")
|
|
@@ -169,7 +174,6 @@ def spara_nedladdning(innehall: str) -> Optional[str]:
|
|
| 169 |
logger.error(f"Error saving text file: {e}")
|
| 170 |
return None
|
| 171 |
|
| 172 |
-
|
| 173 |
def exportera_csv(alla_resultat: list) -> Optional[str]:
|
| 174 |
"""Export all results as CSV"""
|
| 175 |
if not alla_resultat:
|
|
|
|
| 158 |
|
| 159 |
def spara_nedladdning(innehall: str) -> Optional[str]:
|
| 160 |
"""Save text file for download"""
|
| 161 |
+
# Check if input is valid
|
| 162 |
+
if not innehall or not isinstance(innehall, str):
|
| 163 |
+
logger.warning("Invalid input for file download")
|
| 164 |
+
return None
|
| 165 |
+
|
| 166 |
try:
|
| 167 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 168 |
path = os.path.join(Config.TEMP_DIR, f"vips_anteckning_{timestamp}.txt")
|
|
|
|
| 174 |
logger.error(f"Error saving text file: {e}")
|
| 175 |
return None
|
| 176 |
|
|
|
|
| 177 |
def exportera_csv(alla_resultat: list) -> Optional[str]:
|
| 178 |
"""Export all results as CSV"""
|
| 179 |
if not alla_resultat:
|