From 6cda7c1be79b8836baf177a04630c4cf65d3d59b Mon Sep 17 00:00:00 2001 From: Anne Philipp <anne.philipp@univie.ac.at> Date: Wed, 28 Nov 2018 00:48:40 +0100 Subject: [PATCH] moved check install coditions to install module --- source/python/_config.py | 2 ++ source/python/classes/ControlFile.py | 46 ------------------------ source/python/install.py | 53 +++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 47 deletions(-) diff --git a/source/python/_config.py b/source/python/_config.py index 1b9339e..4d037cc 100644 --- a/source/python/_config.py +++ b/source/python/_config.py @@ -31,6 +31,8 @@ _VERSION_STR = '7.1' QUEUES_LIST = ['ecgate', 'cca', 'ccb'] +INSTALL_TARGETS = ['local', 'ecgate', 'cca'] + # up-to-date available maximum level numbers at ECMWF, 05.10.2018 MAX_LEVEL_LIST = [16, 19, 31, 40, 50, 60, 62, 91, 137] diff --git a/source/python/classes/ControlFile.py b/source/python/classes/ControlFile.py index 447c299..26fc932 100644 --- a/source/python/classes/ControlFile.py +++ b/source/python/classes/ControlFile.py @@ -503,52 +503,6 @@ class ControlFile(object): return - def check_install_conditions(self): - '''Checks a couple of necessary attributes and conditions - for the installation such as if they exist and contain values. - Otherwise set default values. - - Parameters - ---------- - - Return - ------ - - ''' - - if self.install_target and \ - self.install_target not in ['local', 'ecgate', 'cca']: - print('ERROR: unknown or missing installation target ') - print('target: ', self.install_target) - print('please specify correct installation target ' + - '(local | ecgate | cca)') - print('use -h or --help for help') - sys.exit(1) - - if self.install_target and self.install_target != 'local': - if not self.ecgid or not self.ecuid or \ - not self.gateway or not self.destination: - print('Please enter your ECMWF user id and group id as well ' + - 'as the \nname of the local gateway and the ectrans ' + - 'destination ') - print('with command line options --ecuid --ecgid \ - --gateway --destination') - print('Try "' + sys.argv[0].split('/')[-1] + \ - ' -h" to print usage information') - print('Please consult ecaccess documentation or ECMWF user \ - support for further details') - sys.exit(1) - - if not self.flexpart_root_scripts: - self.flexpart_root_scripts = '${HOME}' - else: - self.flexpart_root_scripts = self.flexpart_root_scripts - else: # local - if not self.flexpart_root_scripts: - self.flexpart_root_scripts = _config.PATH_FLEXEXTRACT_DIR - - return - def to_list(self): '''Just generates a list of strings containing the attributes and assigned values except the attributes "_expanded", "exedir", diff --git a/source/python/install.py b/source/python/install.py index 823856b..4b7f74c 100755 --- a/source/python/install.py +++ b/source/python/install.py @@ -79,7 +79,7 @@ def main(): args = get_install_cmdline_arguments() c = ControlFile(args.controlfile) c.assign_args_to_control(args) - c.check_install_conditions() + check_install_conditions(c) install_via_gateway(c) @@ -218,6 +218,57 @@ def install_via_gateway(c): return +def check_install_conditions(c): + '''Checks a couple of necessary attributes and conditions + for the installation such as if they exist and contain values. + Otherwise set default values. + + Parameters + ---------- + c : :obj:`ControlFile` + Contains all the parameters of CONTROL file and + command line. + + + Return + ------ + + ''' + + if c.install_target and \ + c.install_target not in _config.INSTALL_TARGETS: + print('ERROR: unknown or missing installation target ') + print('target: ', c.install_target) + print('please specify correct installation target ' + + str(INSTALL_TARGETS)) + print('use -h or --help for help') + sys.exit(1) + + if c.install_target and c.install_target != 'local': + if not c.ecgid or not c.ecuid or \ + not c.gateway or not c.destination: + print('Please enter your ECMWF user id and group id as well ' + + 'as the \nname of the local gateway and the ectrans ' + + 'destination ') + print('with command line options --ecuid --ecgid \ + --gateway --destination') + print('Try "' + sys.argv[0].split('/')[-1] + \ + ' -h" to print usage information') + print('Please consult ecaccess documentation or ECMWF user \ + support for further details') + sys.exit(1) + + if not c.flexpart_root_scripts: + c.flexpart_root_scripts = '${HOME}' + else: + c.flexpart_root_scripts = c.flexpart_root_scripts + else: # local + if not c.flexpart_root_scripts: + c.flexpart_root_scripts = _config.PATH_FLEXEXTRACT_DIR + + return + + def mk_tarball(tarball_path, target): '''Creates a tarball with all necessary files which need to be sent to the installation directory. -- GitLab