Update app.py
Browse files
app.py
CHANGED
|
@@ -14,26 +14,26 @@ csv_file_path = os.path.join(csv_dir, "mos_scores.csv")
|
|
| 14 |
|
| 15 |
def submit(intelligibility, naturalness, expressiveness):
|
| 16 |
debug_info = []
|
| 17 |
-
debug_info.append(f"Current working directory: {os.getcwd()}")
|
| 18 |
-
debug_info.append(f"Target directory: {csv_dir}")
|
| 19 |
-
debug_info.append(f"Target file: {csv_file_path}")
|
| 20 |
|
| 21 |
try:
|
| 22 |
# Create directory if it doesn't exist
|
| 23 |
-
debug_info.append("Trying to create directory...")
|
| 24 |
os.makedirs(csv_dir, exist_ok=True)
|
| 25 |
-
debug_info.append(f"Directory created or already exists: {os.path.exists(csv_dir)}")
|
| 26 |
|
| 27 |
# List directory contents
|
| 28 |
if os.path.exists(csv_dir):
|
| 29 |
-
debug_info.append(f"Directory contents: {os.listdir(csv_dir)}")
|
| 30 |
|
| 31 |
# Check if file exists to add headers if new
|
| 32 |
file_exists = os.path.isfile(csv_file_path)
|
| 33 |
-
debug_info.append(f"File exists: {file_exists}")
|
| 34 |
|
| 35 |
# Try writing to the file
|
| 36 |
-
debug_info.append("Attempting to write to file...")
|
| 37 |
with open(csv_file_path, "a", newline="") as f:
|
| 38 |
writer = csv.writer(f)
|
| 39 |
|
|
@@ -46,16 +46,16 @@ def submit(intelligibility, naturalness, expressiveness):
|
|
| 46 |
os.fsync(f.fileno()) # Ensure it's written to the physical disk
|
| 47 |
|
| 48 |
# Verify the file was written
|
| 49 |
-
debug_info.append(f"File exists after write: {os.path.isfile(csv_file_path)}")
|
| 50 |
if os.path.isfile(csv_file_path):
|
| 51 |
-
debug_info.append(f"File size: {os.path.getsize(csv_file_path)} bytes")
|
| 52 |
|
| 53 |
# Read and display CSV content
|
| 54 |
csv_content = ""
|
| 55 |
if os.path.isfile(csv_file_path):
|
| 56 |
with open(csv_file_path, "r") as f:
|
| 57 |
csv_content = f.read()
|
| 58 |
-
debug_info.append(f"\nCSV Content:\n{csv_content}")
|
| 59 |
|
| 60 |
return "Thank you for your feedback! Data saved successfully.\n\nDebug info:\n" + "\n".join(debug_info)
|
| 61 |
|
|
|
|
| 14 |
|
| 15 |
def submit(intelligibility, naturalness, expressiveness):
|
| 16 |
debug_info = []
|
| 17 |
+
# debug_info.append(f"Current working directory: {os.getcwd()}")
|
| 18 |
+
# debug_info.append(f"Target directory: {csv_dir}")
|
| 19 |
+
# debug_info.append(f"Target file: {csv_file_path}")
|
| 20 |
|
| 21 |
try:
|
| 22 |
# Create directory if it doesn't exist
|
| 23 |
+
# debug_info.append("Trying to create directory...")
|
| 24 |
os.makedirs(csv_dir, exist_ok=True)
|
| 25 |
+
# debug_info.append(f"Directory created or already exists: {os.path.exists(csv_dir)}")
|
| 26 |
|
| 27 |
# List directory contents
|
| 28 |
if os.path.exists(csv_dir):
|
| 29 |
+
# debug_info.append(f"Directory contents: {os.listdir(csv_dir)}")
|
| 30 |
|
| 31 |
# Check if file exists to add headers if new
|
| 32 |
file_exists = os.path.isfile(csv_file_path)
|
| 33 |
+
# debug_info.append(f"File exists: {file_exists}")
|
| 34 |
|
| 35 |
# Try writing to the file
|
| 36 |
+
# debug_info.append("Attempting to write to file...")
|
| 37 |
with open(csv_file_path, "a", newline="") as f:
|
| 38 |
writer = csv.writer(f)
|
| 39 |
|
|
|
|
| 46 |
os.fsync(f.fileno()) # Ensure it's written to the physical disk
|
| 47 |
|
| 48 |
# Verify the file was written
|
| 49 |
+
# debug_info.append(f"File exists after write: {os.path.isfile(csv_file_path)}")
|
| 50 |
if os.path.isfile(csv_file_path):
|
| 51 |
+
# debug_info.append(f"File size: {os.path.getsize(csv_file_path)} bytes")
|
| 52 |
|
| 53 |
# Read and display CSV content
|
| 54 |
csv_content = ""
|
| 55 |
if os.path.isfile(csv_file_path):
|
| 56 |
with open(csv_file_path, "r") as f:
|
| 57 |
csv_content = f.read()
|
| 58 |
+
# debug_info.append(f"\nCSV Content:\n{csv_content}")
|
| 59 |
|
| 60 |
return "Thank you for your feedback! Data saved successfully.\n\nDebug info:\n" + "\n".join(debug_info)
|
| 61 |
|