def __init__(self, path, extra_options={}, validate=True): """ initialize an easyconfig. path should be a path to a file that can be parsed extra_options is a dict of extra variables that can be set in this specific instance validate specifies whether validations should happen """ # perform a deepcopy of the default_config found in the easybuild.tools.easyblock module self.config = copy.deepcopy(self.default_config) self.config.update(extra_options) self.log = getLog("EasyBlock") # store toolkit self._toolkit = None if not os.path.isfile(path): self.log.error("EasyBlock __init__ expected a valid path") self.validations = {"moduleclass": self.validmoduleclasses, "stop": self.validstops} self.parse(path) # perform validations if validate: self.validate()
def __init__(self, name, version): """ Initialise toolkit variables.""" self.dependencies = [] self.vars = {} self.arch = None self.toolkit_deps = [] self.m32flag = '' # logger self.log = getLog('Toolkit') # option flags self.opts = { 'usempi': False, 'cciscxx': False, 'pic': False, 'opt': False, 'noopt': False, 'lowopt': False, 'debug': False, 'optarch':True, 'i8': False, 'unroll': False, 'verbose': False, 'cstd': None, 'shared': False, 'static': False, 'intel-static': False, 'loop': False, 'f2c': False, 'no-icc': False, 'packed-groups': False, '32bit' : False } self.name = name self.version = version # 32-bit toolkit have version that ends with '32bit' if self.version.endswith('32bit'): self.opts['32bit'] = True self.m32flag = " -m32"
def setUp(self): """ dynamically replace Modules class with MockModule """ # replace Modules class with something we have control over modules.Modules = MockModule build.Modules = MockModule self.log = getLog("RobotTest")
# # You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. ## """ Generating module files. """ import os import shutil import tempfile from easybuild.tools.build_log import getLog from easybuild.tools.config import installPath log = getLog('moduleGenerator') class ModuleGenerator: """ Class for generating module files. """ def __init__(self, application, fake=False): self.app = application self.fake = fake self.filename = None self.tmpdir = None def createFiles(self): """ Creates the absolute filename for the module.
import xml.dom.minidom as xml from datetime import datetime from optparse import OptionParser import easybuild import easybuild.tools.build_log as build_log import easybuild.tools.config as config import easybuild.tools.parallelbuild as parbuild import easybuild.tools.systemtools as systemtools from easybuild.tools.build_log import getLog, EasyBuildError, initLogger from easybuild.build import findEasyconfigs, processEasyconfig, resolveDependencies from easybuild.tools.filetools import modifyEnv # some variables used by different functions initLogger(filename=None, debug=True, typ=None) log = getLog("ParallelBuild") test_results = [] build_stopped = {} def main(): """ main entry point """ # assume default config path config.init('easybuild/easybuild_config.py') cur_dir = os.getcwd() # Option parsing parser = OptionParser() parser.add_option("--no-parallel", action="store_false", dest="parallel", default=True, help="specify this option if you want to prevent parallel build") parser.add_option("--output-dir", dest="directory", help="set output directory for test-run")
""" import os import re import shutil import signal import stat import subprocess import tempfile import time import easybuild.tools.environment as env from easybuild.tools.asyncprocess import Popen, PIPE, STDOUT, send_all, recv_some from easybuild.tools.build_log import getLog log = getLog('fileTools') errorsFoundInLog = 0 strictness = 'warn' def unpack(fn, dest, extra_options=None, overwrite=False): """ Given filename fn, try to unpack in directory dest - returns the directory name in case of success """ if not os.path.isfile(fn): log.error("Can't unpack file %s: no such file" % fn) if not os.path.isdir(dest): ## try to create it
We have a plain filesystem, an svn and a git repository """ import getpass import os import shutil import socket import tempfile import time import easybuild from easybuild.framework.easyblock import EasyBlock from easybuild.tools.build_log import getLog log = getLog('repo') try: import git from git import GitCommandError except ImportError: pass try: import pysvn #@UnusedImport from pysvn import ClientError #IGNORE:E0611 pysvn fails to recognize ClientError is available except ImportError: pass class Repository: """
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. ## """ EasyBuild configuration file. """ import os from easybuild.tools.build_log import getLog import easybuild.tools.config as config log = getLog('easybuild_config') # buildPath possibly overridden by EASYBUILDBUILDPATH # installPath possibly overridden by EASYBUILDINSTALLPATH # this should result in a MODULEPATH=($HOME/.local/easybuild|$EASYBUILDPREFIX)/install/modules/all buildDir = 'build' installDir = '' sourceDir = 'sources' if os.getenv('EASYBUILDPREFIX'): prefix = os.getenv('EASYBUILDPREFIX') else: prefix = os.path.join(os.getenv('HOME'), ".local", "easybuild") if not prefix:
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. ## """ EasyBuild configuration (paths, preferences, etc.) """ import os from easybuild.tools.build_log import getLog import easybuild.tools.repository as repo log = getLog('config') variables = {} requiredVariables = ['buildPath', 'installPath', 'sourcePath', 'logFormat', 'repository', 'repositoryPath'] environmentVariables = { 'buildPath': 'EASYBUILDBUILDPATH', 'installPath': 'EASYBUILDINSTALLPATH' } def init(filename, **kwargs): """ Gather all variables and check if they're valid Variables are read in this order of preference: CLI option > environment > config file """ variables.update(readConfiguration(filename)) # config file
# You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. ## """ Modules functionality: loading modules, checking for available modules, ... """ import os import re import subprocess import sys from easybuild.tools.build_log import getLog, EasyBuildError from easybuild.tools.filetools import convertName, run_cmd log = getLog('Modules') outputMatchers = { # matches whitespace and module-listing headers 'whitespace': re.compile(r"^\s*$|^(-+).*(-+)$"), # matches errors such as "cmdTrace.c(713):ERROR:104: 'asdfasdf' is an unrecognized subcommand" 'error': re.compile(r"^\S+:(?P<level>\w+):(?P<code>\d+):\s+(?P<msg>.*)$"), # matches modules such as "... ictce/3.2.1.015.u4(default) ..." 'available': re.compile(r"\b(?P<name>\S+?)/(?P<version>[^\(\s]+)(?P<default>\(default\))?(?:\s|$)") } class Modules: """ Interact with modules. """ def __init__(self, modulePath=None): self.modulePath = modulePath