You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This caused an issue in generating file paths with special characters and spaces in the filename.
File "/Users/tylerhall/Downloads/AIRTAGS/FindMyHistory-main/lib/log_manager.py", line 74, in _save_log
with open(path, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: "log/2023-08-23/MyName's iPhone iOS 7.1.1 (06/24/14)__NULL.csv"
Here is my proposed fix in log_manager.py's _save_log function.
Here's the modified log_manager.py file that includes the _sanitize_filename function to handle filenames with spaces and special characters:
` def sanitize_filename(self, name):
# Replace spaces and special characters with underscores
return name.replace(' ', '').replace('/', '').replace('\', '')
def _save_log(self, name, data):
log_folder = self._log_folder
if not self._no_date_folder:
log_folder = os.path.join(
log_folder, datetime.now().strftime(self._date_format))
if not os.path.exists(log_folder):
os.makedirs(log_folder)
sanitized_name = self._sanitize_filename(name)
path = os.path.join(log_folder, sanitized_name + '.csv')
if not os.path.exists(path):
with open(path, 'w') as f:
writer = csv.writer(f)
writer.writerow(self._keys)
with open(path, 'a') as f:
writer = csv.writer(f)
writer.writerow([data[k] for k in self._keys])
`
You can add the _sanitize_filename function to your existing LogManager class to handle filename sanitization. The function replaces spaces, slashes, and backslashes in the name with underscores to create a valid filename.
This modification should help you avoid issues with special characters and spaces in the filenames when creating the CSV files. Just ensure that this updated log_manager.py file is used in conjunction with the rest of your code.
The text was updated successfully, but these errors were encountered:
My device name was:
MyName's iPhone iOS 7.1.1 (06/24/14)
This caused an issue in generating file paths with special characters and spaces in the filename.
Here is my proposed fix in log_manager.py's
_save_log
function.Here's the modified log_manager.py file that includes the _sanitize_filename function to handle filenames with spaces and special characters:
` def sanitize_filename(self, name):
# Replace spaces and special characters with underscores
return name.replace(' ', '').replace('/', '').replace('\', '')
You can add the
_sanitize_filename
function to your existing LogManager class to handle filename sanitization. The function replaces spaces, slashes, and backslashes in the name with underscores to create a valid filename.This modification should help you avoid issues with special characters and spaces in the filenames when creating the CSV files. Just ensure that this updated
log_manager.py
file is used in conjunction with the rest of your code.The text was updated successfully, but these errors were encountered: