From c12df6108875ff926700d61db82aee50d4ae79b4 Mon Sep 17 00:00:00 2001 From: bmarcote Date: Thu, 8 Dec 2022 16:53:30 +0100 Subject: [PATCH] Small touches in docs --- app.py | 21 +++++++++++++-------- evn_postprocess/environment.py | 6 +++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app.py b/app.py index 0d6ed42..d9b58e3 100644 --- a/app.py +++ b/app.py @@ -26,13 +26,13 @@ This program runs the full post-processing for a correlated EVN experiment until distribution, following the steps described in the EVN Post-Processing Guide, in a semi-automatic way. -The program would retrieve the experiment code from the current working directory, and the associated Support Scientist from the parent directory. Otherwise they need to be specified manually. +[dim]The program would retrieve the experiment code from the current working directory, and the associated Support Scientist from the parent directory. Otherwise they need to be specified manually. The user can also specify to run only some of the steps or to start the process from a given step (for those cases when the process has partially run previously). If the post-processing already run in teh past, it will automatically continue from the last successful step that run. -[italic]If the post-processing partially run before this execution, it will continue from the last successful step.[/italic] +[italic]If the post-processing partially run before this execution, it will continue from the last successful step.[/italic][/dim] """ help_calsources = 'Calibrator sources to use in standardplots (comma-separated, no spaces). ' \ @@ -306,10 +306,10 @@ def main(): formatter_class=RawTextRichHelpFormatter) # formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('-e', '--expname', type=str, default=None, - help='Name of the EVN experiment (case-insensitive).\nBy default recovered assuming you' \ - 'are running this from /data0/{supsci}/{EXPNAME}.') + help='Name of the EVN experiment (case-insensitive).\n[dim]By default recovered assuming you' \ + ' run this from /data0/{supsci}/{EXPNAME}.[/dim]') parser.add_argument('-jss', '--supsci', type=str, default=None, help='Surname of the EVN Support Scientist.\n' \ - 'By default recovered assuming you are running this from /data0/{supsci}/{EXPNAME}.') + '[dim]By default recovered assuming you run this from /data0/{supsci}/{EXPNAME}.[/dim]') parser.add_argument('--j2ms2par', type=str, default=None, help='Additional attributes for j2ms2 (like the fo:XXXXX).') parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(__version__)) @@ -338,9 +338,14 @@ def main(): if args.expname is None: args.expname = Path.cwd().name - assert env.grep_remote_file('jops@ccs', '/ccs/var/log2vex/MASTER_PROJECTS.LIS', args.expname.upper()) != '', \ - f"The experiment name {args.expname} is not recognized (not present in MASTER_PROJECTS). " \ - "You may need to manually specify with --expname" + try: + assert env.grep_remote_file('jops@ccs', '/ccs/var/log2vex/MASTER_PROJECTS.LIS', args.expname.upper()) != '', \ + f"The experiment name {args.expname} is not recognized (not present in MASTER_PROJECTS). " \ + "You may need to manually specify with --expname" + except ValueError as e: + rich.print(f"[italic red]The assumed eperiment code {args.expname} is not recognized.[/italic red]") + rich.print('\n' + description) + sys.exit(0) if args.supsci is None: args.supsci = Path.cwd().parent.name diff --git a/evn_postprocess/environment.py b/evn_postprocess/environment.py index a45fc2a..3331cac 100644 --- a/evn_postprocess/environment.py +++ b/evn_postprocess/environment.py @@ -83,16 +83,16 @@ def remote_file_exists(host, path): raise Exception(f"SSH connection to {host} failed.") -def grep_remote_file(host, file, word): +def grep_remote_file(host, remote_file, word): """Runs a grep in a file located in a remote host and returns it. It may raise ValueError if there is a problem accessing the host or file. """ - cmd = f"grep {word} {file}" + cmd = f"grep {word} {remote_file}" process = subprocess.Popen(["ssh", host, cmd], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = process.communicate()[0].decode('utf-8') if process.returncode != 0: - raise ValueError(f"Errorcode {process.returncode} when reading {file} from {host}.") + raise ValueError(f"Errorcode {process.returncode} when searching for {word} in {remote_file} from {host}.") return output