-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cat-log - open job logs in editor #2260
Conversation
This will be a really useful feature! Just taking a quick glance through before review: Something which would make it more convenient is if the editor command is run in the background in the case that the PS: There is a typo in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a couple of typos (made in recent commits, as I know it was working earlier!)
bin/cylc-cat-log
Outdated
|
||
viewfile = NamedTemporaryFile( | ||
suffix='.' + os.path.basename(filename), | ||
prefix=suite + '.', dir=cylc_tmpdiir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo (diir
) - spotted by @oliver-sanders
bin/cylc-cat-log
Outdated
|
||
for line in lines: | ||
viewfile.write(line + '\n') | ||
viewfile.seek(0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation error - seek
after all lines written, not after each.
bin/cylc-cat-log
Outdated
'WARNING: YOU HAVE EDITED A TEMPORARY READ_ONLY COPY OF: ') | ||
print >> sys.stderr, filename | ||
else: | ||
print >> sys.stderr, 'NO CHANGES MADE TO: %s' % viewfile.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this line IMO.
The reason we block on the editor command is to check and warn if the user edited and force-saved the file, which suggests they thought they were editing the original file rather than a temporary read-only copy. (This is more important in
(most GUI editors - except for |
Made changes as suggested. |
bin/cylc-cat-log
Outdated
|
||
viewfile = NamedTemporaryFile( | ||
suffix='.' + os.path.basename(filename), | ||
prefix=suite + '.', dir=cylc_tmpdir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more problem found while testing: prefix=suite
doesn't work for suite names containing /
corresponding to the directory path under cylc-run/
- this makes the viewfile path refer to a non-existent directory. Can you change to this:
prefix=suite.replace('/','_') + '.'
- and also do the same for the original code in cylc view
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most GUI editors - except for gvim default behaviour - don't automatically background either btw
Good point, I'm too used to gvim
.
Looks good to me, only one comment:
bin/cylc-cat-log
Outdated
@@ -296,6 +335,10 @@ def main(): | |||
cmd_tmpl = str(GLOBAL_CFG.get_host_item( | |||
"local tail command template")) | |||
commands.append(shlex.split(cmd_tmpl % {"filename": filename})) | |||
elif options.geditor or options.editor: | |||
command_list = editor.split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be safer to do this with shlex.split
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@challurip - if you can make this change and push it up today, I'll merge this for the new release (tonight, if the anesthetic has worn off...)
cylc cat-log
- allow opening job logs in users' editor ( temporary read only copy ); same via gcylc.[not ready for review yet - coming soon]