RHESSysWorkflows  1.33
Variables
ImportRHESSysSource Namespace Reference

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...

Variables

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)
 

Detailed Description

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:

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

  1. Configuration file must define the following sections and values: 'GRASS', 'GISBASE' 'RHESSYS', 'PATH_OF_GIT' 'RHESSYS', 'PATH_OF_MAKE'
  2. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: rhessys_dir

Post conditions

  1. Will import/copy source code into src directory of rhessys_dir
  2. Will compile g2w (including rat), cf, and rhessys binaries into bin directory of rhessys_dir
  3. 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

Variable Documentation

tuple ImportRHESSysSource.ALLOMETRIC_PATH = os.path.join('allometry', 'allometric.txt')
tuple ImportRHESSysSource.allometricPath = os.path.join(paramDBPath, ALLOMETRIC_PATH)
tuple ImportRHESSysSource.args = parser.parse_args()
list ImportRHESSysSource.branches = []
tuple ImportRHESSysSource.branchRegex = re.compile('^\s*origin/(.+)$')
tuple ImportRHESSysSource.buildPath = os.path.join(paths.RHESSYS_SRC, 'g2w')
ImportRHESSysSource.cfBin = None
tuple ImportRHESSysSource.cfBinRegex = re.compile('^cf.+$')
tuple ImportRHESSysSource.cfDest = os.path.join(paths.RHESSYS_BIN, cfBin)
tuple ImportRHESSysSource.cfSrc = os.path.join(args.sourceDir, 'cf')
tuple ImportRHESSysSource.cmdline = RHESSysMetadata.getCommandLine()
ImportRHESSysSource.configFile = None
tuple ImportRHESSysSource.contents = os.listdir(paramDBPath)
tuple ImportRHESSysSource.context = Context(args.projectDir, configFile)
tuple ImportRHESSysSource.dest = os.path.join(paths.RHESSYS_BIN, 'lairead')
ImportRHESSysSource.found = False
tuple ImportRHESSysSource.g2wDest = os.path.join(paths.RHESSYS_BIN, 'g2w')
tuple ImportRHESSysSource.g2wSrc = os.path.join(args.sourceDir, 'g2w')
  1. Import code from local disk, or from GitHub
tuple ImportRHESSysSource.gisBase = context.config.get('GRASS', 'GISBASE')
string ImportRHESSysSource.gitCommand = "%s clone %s %s"
  1. Fetch ParamDB
tuple ImportRHESSysSource.gitPath = context.config.get('RHESSYS', 'PATH_OF_GIT')
ImportRHESSysSource.gitSHA1Command = None
tuple ImportRHESSysSource.group = parser.add_mutually_exclusive_group()
string ImportRHESSysSource.help = 'The configuration file.'
tuple ImportRHESSysSource.m = branchRegex.match(line)
ImportRHESSysSource.makeCommand = makePath
tuple ImportRHESSysSource.makePath = context.config.get('RHESSYS', 'PATH_OF_MAKE')
tuple ImportRHESSysSource.metadata = RHESSysMetadata.readRHESSysEntries(context)
tuple ImportRHESSysSource.modelSrc = os.path.join(args.sourceDir, 'rhessys')
string ImportRHESSysSource.PARAM_DB_REPO_URL = 'https://github.com/RHESSys/ParamDB.git'
tuple ImportRHESSysSource.paramDB = os.path.join(paramDBPath, paramDBName)
string ImportRHESSysSource.paramDBDir = 'ParamDB'
string ImportRHESSysSource.paramDBName = 'params.sqlite'
tuple ImportRHESSysSource.paramDBPath = os.path.join(paths.DB_DIR, paramDBDir)
tuple ImportRHESSysSource.parser = argparse.ArgumentParser(description='Import RHESSys source code into project directory')
tuple ImportRHESSysSource.paths = RHESSysPaths(args.projectDir, metadata['rhessys_dir'])
ImportRHESSysSource.permissions = stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR
  1. Compile code Set GISBASE (needed to compile g2w, cf, lairead)
tuple ImportRHESSysSource.process = Popen(gitCommand, shell=True, stdout=PIPE, cwd=paramDBPath)
tuple ImportRHESSysSource.ratDest = os.path.join(paths.RHESSYS_BIN, 'rat')
tuple ImportRHESSysSource.ratSrc = os.path.join(buildPath, 'AverageTables_Unix', 'rat')
tuple ImportRHESSysSource.returnCode = os.system(gitCommand)
string ImportRHESSysSource.RHESSYS_REPO_URL = 'https://github.com/RHESSys/RHESSys.git'
ImportRHESSysSource.rhessysBin = None
tuple ImportRHESSysSource.rhessysBinRegex = re.compile('^rhessys.+$')
tuple ImportRHESSysSource.rhessysDest = os.path.join(paths.RHESSYS_BIN, rhessysBin)
tuple ImportRHESSysSource.rhessysSrc = os.path.join(buildPath, rhessysBin)
tuple ImportRHESSysSource.sha = processStdout.splitlines()
string ImportRHESSysSource.sha1Identifier = 'HEAD'
tuple ImportRHESSysSource.src = os.path.join(buildPath, 'lairead')
list ImportRHESSysSource.tags = []
tuple ImportRHESSysSource.TEMPLATE_PATH = os.path.join('templates', 'template.template')
tuple ImportRHESSysSource.templatePath = os.path.join(paramDBPath, TEMPLATE_PATH)
tuple ImportRHESSysSource.toDelete = os.path.join(paramDBPath, entry)