Skip to content

Commit

Permalink
Convert log paths between OSs (#1138)
Browse files Browse the repository at this point in the history
* Convert log paths between OSs

As windows job logs are now having their path saved to the database, the
GUI needs to be able to convert paths so that multiple OSs can read the
logs using the GUI

* pylint pass

* Apply suggestions from code review

Still using replace, but only targeting the first occurrence to avoid unintended substitutions

Added a macos example
  • Loading branch information
DiegoTavares committed May 25, 2022
1 parent 747c697 commit 4402c1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cuegui/cuegui/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,11 @@
'no licenses could be found', 'killMessage']
LOG_HIGHLIGHT_WARN = ['warning', 'not found']
LOG_HIGHLIGHT_INFO = ['info:', 'rqd cmd:']


LOG_ROOT_OS = {
"rhel7": "/shots",
"linux": "/shots",
"windows": "S:",
"mac": "/Users/shots"
}
15 changes: 13 additions & 2 deletions cuegui/cuegui/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,19 @@ def getResourceConfig(path=None):
################################################################################

def getFrameLogFile(job, frame):
"""Get the log file associated with a frame."""
return os.path.join(job.data.log_dir, "%s.%s.rqlog" % (job.data.name, frame.data.name))
"""Get the log file associated with a frame. Return path based on the
current OS path using Constants.LOG_ROOT_OS to translate paths."""
my_os = platform.system().lower()
job_os = job.data.os.lower()

log_dir = job.data.log_dir
if my_os != job_os and \
my_os in cuegui.Constants.LOG_ROOT_OS and \
job_os in cuegui.Constants.LOG_ROOT_OS:
log_dir = log_dir.replace(cuegui.Constants.LOG_ROOT_OS[job_os],
cuegui.Constants.LOG_ROOT_OS[my_os], 1)

return os.path.join(log_dir, "%s.%s.rqlog" % (job.data.name, frame.data.name))


def getFrameLLU(job, frame):
Expand Down

0 comments on commit 4402c1a

Please sign in to comment.