def _process(self): confdir = fixpath(self.area.config()) conf = join(confdir, "toolbox", environ["SCRAM_ARCH"]) toolbox = self.toolbox logging.debug("confdir: {0},\n conf: {1}, \n toolbox: {2}".format( confdir, conf, toolbox)) if isdir(toolbox): if isdir(toolbox + "/tools"): adddir(conf + "/tools") copydir(toolbox + "/tools/selected", conf + "/tools/selected") copydir(toolbox + "/tools/available", conf + "/tools/available") else: die("Project creating error. Missing directory \"{toolbox}/tools\" in the toolbox." " Please fix file \"{boot}\" and set a valid toolbox directory." .format(toolbox=toolbox, boot=self.file_to_parse)) else: die("Project creating error. Missing directory \"{toolbox}/\". Please fix file \"{boot}\" " "and set a valid toolbox directory.".format( toolbox=toolbox, boot=self.file_to_parse)) self.area.configchksum(self.area.calchksum()) if not isfile(confdir + "/scram_version"): try: with open(confdir + "/scram_version", 'w+') as f: f.write(environ["SCRAM_VERSION"] + "\n") except IOError: die("ERROR: Can not open {confdir}/scram_version file for writing." .format(confdir=confdir)) self.area.save()
def satellite(self, location, areaname=None, symlink=0, localarea=None): relloc = self.location() sat = ConfigArea(environ['SCRAM_ARCH']) sat.name(self.name()) sat.version(self.version()) sat.configurationdir(self.configurationdir()) sat.sourcedir(self.sourcedir()) sat.tmp(self.tmp()) sat.releasetop(relloc) sat.configchksum(self.configchksum()) sat.setup(location, areaname, symlink, localarea) devconf = join(sat.location(), sat.configurationdir()) relconf = join(self.location(), self.configurationdir()) if not isdir(devconf): copydir(relconf, devconf) else: adddir(join(devconf, 'toolbox')) copydir(join(relconf, 'toolbox', self.arch()), join(devconf, 'toolbox', self.arch())) adddir(join(sat.location(), sat.sourcedir())) if exists(self.toolcachename()): copydir(self.toolcachename(), sat.archdir()) copydir(join(self.archdir(), 'timestamps'), join(sat.archdir(), 'timestamps')) envfile = join(sat.archdir(), 'Environment') with open(envfile, 'w') as ref: ref.write('RELEASETOP=%s\n' % relloc) chkarch = join(sat.archdir(), 'chkarch') ref = open(chkarch, 'w') ref.close() envfile = join(sat.location(), sat.admindir(), 'Environment') if not exists(envfile): sat.save() return sat
def _save(self): filename = join(environ['SCRAM_LOOKUPDB_WRITE'], self.scramrc) adddir(filename) filename = self._getLinkDBFile(filename) with open(filename, 'w') as ref: for db in self.LocalLinks: if db: ref.write(db + "\n") chmod(filename, 0o644) return
def _update_json(self, tooljson, dump=True): if exists(tooljson): old_contents = load(open(tooljson)) if old_contents == loads(dumps(self.xml.contents)): utime(tooljson, None) return False if not exists(self.area.toolcachename()): adddir(self.area.toolcachename()) self.xml.save_json(tooljson) utime(self.area.toolcachename(), None) if not dump: return True printmsg("\n%s\n" % ("+" * 40)) if self.xml.warnings: printmsg('%s' % '\n'.join(self.xml.warnings)) printmsg("Name : %s" % self.xml.contents['TOOLNAME']) printmsg("Version : %s" % self.xml.contents['TOOLVERSION']) tooldata = ToolFile.summarize_tool(self.xml.contents) for tag in sorted(tooldata): printmsg('%s=%s' % (tag, tooldata[tag])) return True
def setup(self, location, areaname=None, symlink=0, localarea=None): if not areaname: areaname = self.version() self.location(join(location, areaname)) self.symlinks(symlink) if self.configchksum(): envfile = join(self.location(), self.admindir(), 'Environment') if (not localarea) and exists(envfile): localarea = ConfigArea() localarea.bootstrapfromlocation(self.location()) if localarea and localarea.configchksum() != self.configchksum(): err = "ERROR: Can not setup your current working area for " \ "SCRAM_ARCH: $ENV{SCRAM_ARCH}\n" err += "Your current development area ${location}/${" \ "areaname}\n" err += "is using a different ${areaname}/config then the " \ "one used for\n" err += self.releasetop() print(err, file=stderr) exit(1) adddir(self.archdir()) return
from os import environ environ['SCRAM_ARCH'] = "SCRAM_ARCH" environ['SCRAM_VERSION'] = "SCRAM_VERSION" environ['SCRAM_DEBUG'] = "True" from SCRAM.Configuration.BootStrapProject import BootStrapProject from SCRAM.Utilities.AddDir import adddir filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'resource', 'CMSSW_bootsrc_2.xml') os.chdir(os.path.join(os.path.abspath(os.path.dirname(__file__)), "../")) # go to project root tools_path = "/tmp/SCRAM_TEST_src/toolbox/tools" # Cleanup for path_to_remove in ['/tmp/SCRAM_TEST', '/tmp/SCRAM_TEST_src']: try: shutil.rmtree(path_to_remove) except BaseException: pass # no directory to remove # Setup adddir(tools_path + "/selected") adddir(tools_path + "/available") with open(tools_path + "/selected/f", 'w') as f: f.write("111\n111\n111\n111\n") with open(tools_path + "/available/f", 'w') as f: f.write("111\n111\n111\n111\n") project = BootStrapProject("/tmp/SCRAM_TEST/path/to/something") project.parse(filename)