Import RHESSys source code into project directory; Will import either from the Git repository hosted on GitHub, from a local copy of the source tree.
More...
|
string | PARAM_DB_REPO_URL = 'https://github.com/RHESSys/ParamDB.git' |
|
string | paramDBDir = 'ParamDB' |
|
string | paramDBName = 'params.sqlite' |
|
tuple | TEMPLATE_PATH = os.path.join('templates', 'template.template') |
|
tuple | ALLOMETRIC_PATH = os.path.join('allometry', 'allometric.txt') |
|
string | RHESSYS_REPO_URL = 'https://github.com/RHESSys/RHESSys.git' |
|
tuple | parser = argparse.ArgumentParser(description='Import RHESSys source code into project directory') |
|
string | help = 'The configuration file.' |
|
tuple | group = parser.add_mutually_exclusive_group() |
|
tuple | args = parser.parse_args() |
|
tuple | cmdline = RHESSysMetadata.getCommandLine() |
|
| configFile = None |
|
tuple | context = Context(args.projectDir, configFile) |
|
tuple | gisBase = context.config.get('GRASS', 'GISBASE') |
|
tuple | gitPath = context.config.get('RHESSYS', 'PATH_OF_GIT') |
|
tuple | makePath = context.config.get('RHESSYS', 'PATH_OF_MAKE') |
|
tuple | metadata = RHESSysMetadata.readRHESSysEntries(context) |
|
tuple | paths = RHESSysPaths(args.projectDir, metadata['rhessys_dir']) |
|
tuple | paramDBPath = os.path.join(paths.DB_DIR, paramDBDir) |
|
tuple | contents = os.listdir(paramDBPath) |
|
tuple | toDelete = os.path.join(paramDBPath, entry) |
|
string | gitCommand = "%s clone %s %s" |
|
string | sha1Identifier = 'HEAD' |
|
tuple | returnCode = os.system(gitCommand) |
|
tuple | process = Popen(gitCommand, shell=True, stdout=PIPE, cwd=paramDBPath) |
|
tuple | sha = processStdout.splitlines() |
|
| found = False |
|
tuple | paramDB = os.path.join(paramDBPath, paramDBName) |
|
tuple | templatePath = os.path.join(paramDBPath, TEMPLATE_PATH) |
|
tuple | allometricPath = os.path.join(paramDBPath, ALLOMETRIC_PATH) |
|
tuple | g2wSrc = os.path.join(args.sourceDir, 'g2w') |
|
tuple | cfSrc = os.path.join(args.sourceDir, 'cf') |
|
tuple | modelSrc = os.path.join(args.sourceDir, 'rhessys') |
|
| gitSHA1Command = None |
|
tuple | branchRegex = re.compile('^\s*origin/(.+)$') |
|
list | branches = [] |
|
tuple | m = branchRegex.match(line) |
|
list | tags = [] |
|
| permissions = stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR |
|
tuple | buildPath = os.path.join(paths.RHESSYS_SRC, 'g2w') |
|
| makeCommand = makePath |
|
tuple | g2wDest = os.path.join(paths.RHESSYS_BIN, 'g2w') |
|
tuple | ratSrc = os.path.join(buildPath, 'AverageTables_Unix', 'rat') |
|
tuple | ratDest = os.path.join(paths.RHESSYS_BIN, 'rat') |
|
tuple | cfBinRegex = re.compile('^cf.+$') |
|
| cfBin = None |
|
tuple | cfDest = os.path.join(paths.RHESSYS_BIN, cfBin) |
|
tuple | src = os.path.join(buildPath, 'lairead') |
|
tuple | dest = os.path.join(paths.RHESSYS_BIN, 'lairead') |
|
tuple | rhessysBinRegex = re.compile('^rhessys.+$') |
|
| rhessysBin = None |
|
tuple | rhessysSrc = os.path.join(buildPath, rhessysBin) |
|
tuple | rhessysDest = os.path.join(paths.RHESSYS_BIN, rhessysBin) |
|
Import RHESSys source code into project directory; Will import either from the Git repository hosted on GitHub, from a local copy of the source tree.
The local source tree must be root of the RHESSys source tree and contain the following source sub-directories: cf, g2w, and rhessys. Will also import RHESSys ParamDB from GitHub.
This software is provided free of charge under the New BSD License. Please see the following license information:
Copyright (c) 2013, University of North Carolina at Chapel Hill All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the University of North Carolina at Chapel Hill nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- Author
- Brian Miles brian.nosp@m._mil.nosp@m.es@un.nosp@m.c.ed.nosp@m.u
Pre conditions
- Configuration file must define the following sections and values: 'GRASS', 'GISBASE' 'RHESSYS', 'PATH_OF_GIT' 'RHESSYS', 'PATH_OF_MAKE'
- The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: rhessys_dir
Post conditions
- Will import/copy source code into src directory of rhessys_dir
- Will compile g2w (including rat), cf, and rhessys binaries into bin directory of rhessys_dir
- Will write the following entry(ies) to the RHESSys section of metadata associated with the project directory: rhessys_src rhessys_branch or rhessys_tag (if specified) rhessys_sha (if ImportRHESSysSource fetched source from Git repository) paramdb_src paramdb_sha paramdb_dir paramdb template_template exec_dir (directory within project directory containing executables) rhessys_bin cf_bin rat_bin g2w_bin lairead_bin allometric_table
Usage:
1 ImportRHESSysSource.py -p /path/to/project_dir