ImperialCollegeLondon / FINESSE

A graphical user interface for controlling and monitoring an interferometer device
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Log menu #524

Closed CWestICL closed 9 months ago

CWestICL commented 9 months ago

Logs added to the main window toolbar menu with two options:

Closes #434

codecov[bot] commented 9 months ago

Codecov Report

Attention: Patch coverage is 48.38710% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 82.45%. Comparing base (a46e81e) to head (5c3238f). Report is 13 commits behind head on main.

Files Patch % Lines
finesse/gui/logs_view.py 55.55% 8 Missing :warning:
finesse/gui/main_window.py 14.28% 6 Missing :warning:
finesse/logger.py 66.66% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #524 +/- ## ========================================== - Coverage 82.53% 82.45% -0.09% ========================================== Files 62 66 +4 Lines 3144 3214 +70 ========================================== + Hits 2595 2650 +55 - Misses 549 564 +15 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

CWestICL commented 9 months ago

I'm assuming the functionality for opening files/folders is OS agnostic but would be good to check! Works as expected on Windows.

jamesturner246 commented 9 months ago

Hi @CWestICL. Just quickly before I review, just had an error loading the log file on Linux:

Traceback (most recent call last):
  File "/home/jpturner/workspace/FINESSE/FINESSE/finesse/gui/logs_view.py", line 29, in open_log
    self.log = max(self.files, key=os.path.getctime)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen genericpath>", line 65, in getctime
FileNotFoundError: [Errno 2] No such file or directory: '/home/jpturner/.local/state/FINESSE/log\\20240215_16-17-26.log'

Looks like a Windows backslash file delimiter after FINESSE/log. Works if I change back to the OS's file delimiter.

CWestICL commented 9 months ago

Ah ok, I've replaced the backslash. Could you check if it's working now?

dc2917 commented 9 months ago

Also, you mention in the PR description that it opens the log file in the default text editor - do you mean web browser?

CWestICL commented 9 months ago

When I was researching how to open a file in the OS's text editor, I found a StackExchange post saying webbrowser.open() would work. And it does open NotePad on my Windows PC.

However I've just seen this in the Python docs: Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program. However, this is neither supported nor portable. So probably worth a check if it works on other OSs.

dc2917 commented 9 months ago

When I was researching how to open a file in the OS's text editor, I found a StackExchange post saying webbrowser.open() would work. And it does open NotePad on my Windows PC.

However I've just seen this in the Python docs: Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program. However, this is neither supported nor portable. So probably worth a check if it works on other OSs.

It opens in my web browser. Seems weird that a something called webbrowser.open() opens a file in a text editor 😅 Does it at least open as read-only?

CWestICL commented 9 months ago

It does not 😅 I might have to go back and find another way of doing this