Skip to content

Commit

Permalink
Add check for clearing log only on linux
Browse files Browse the repository at this point in the history
The log file cannot be cleaned when on Windows, because due
to file locks, cannot open file when it is being used by Mantid
to write to it.

The best solution for now is to clean the file when on Unix system.
On windows the log file will still be produced, but will contain the logs
of all times the routines were run.
  • Loading branch information
GuiMacielPereira committed Jan 17, 2025
1 parent 8cb3330 commit 9a58efb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mvesuvio/main/run_routine.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
import dill # To convert constraints to string
import re
import os


class Runner:
Expand Down Expand Up @@ -83,8 +84,10 @@ def run(self):
return

# Erase previous log
with open(self.mantid_log_file, 'w') as file:
file.write('')
# Not working on Windows due to shared file locks
if os.name == 'posix':
with open(self.mantid_log_file, 'w') as file:
file.write('')

# If any ws for y fit already loaded
wsInMtd = [ws in mtd for ws in self.ws_to_fit_y_space] # Bool list
Expand Down

0 comments on commit 9a58efb

Please sign in to comment.