def testTaggedDeps2(self): """ test equivalent to "setup --tag mine prod" where dependency is tagged "mine" """ # do some setup for this test pdir = os.path.join(testEupsStack, "Linux", "newprod") pdir10 = os.path.join(pdir, "1.0") pdir20 = os.path.join(pdir, "1.0") pdbdir = os.path.join(self.dbpath, "newprod") pupsdir = os.path.join(pdbdir, "Linux") ptble10 = os.path.join(pupsdir, "1.0.table") ptble20 = os.path.join(pupsdir, "2.0.table") newprodtable = \ """ setupRequired(python 2.5.2 [>= 2.5]) """ pyprod = self.eups.getProduct("python", "2.5.2") pytdir = pyprod.dir self.eups.declare("newprod", "1.0", pdir10, testEupsStack, tablefile=StringIO(newprodtable), tag="current") self.eups.declare("newprod", "2.0", pdir20, testEupsStack, tablefile=StringIO(newprodtable)) self.eups.declare("python", "test", pytdir, testEupsStack) self.eups.assignTag("rhl", "python", "test") # test the setup self.assert_(self.eups.findProduct("newprod", "1.0") is not None, "newprod 1.0 not declared") self.assert_(self.eups.findProduct("newprod", "2.0") is not None, "newprod 2.0 not declared") self.assert_(os.path.exists(ptble10), "Can't find newprod 1.0's table file") self.assert_(os.path.exists(ptble20), "Can't find newprod 2.0's table file") self.assert_(self.eups.findProduct("python", "test") is not None, "python test not declared") self.assertEquals(len(filter(lambda p: p[0] == "newprod", self.eups.uses("python"))), 2, "newprod does not depend on python") # now we are ready to go: request the beta version of newprod q = eups.Quiet(self.eups) eups.setup("newprod", prefTags="rhl", eupsenv=self.eups) del q prod = self.eups.findSetupProduct("newprod") self.assert_(prod is not None, "newprod not setup") self.assertEquals(prod.version, "1.0") self.assert_(os.environ.has_key("SETUP_NEWPROD"), "SETUP_NEWPROD not set") self.assert_(os.environ.has_key("NEWPROD_DIR"), "NEWPROD_DIR not set") self.assertEquals(os.environ["NEWPROD_DIR"], pdir20) prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEquals(prod.version, "test") # tagged rhl self.assert_(os.environ.has_key("SETUP_PYTHON"), "SETUP_PYTHON not set") self.assert_(os.environ.has_key("PYTHON_DIR"), "PYTHON_DIR not set") self.assertEquals(os.environ["PYTHON_DIR"], prod.dir)
def testTaggedDeps2(self): """ test equivalent to "setup --tag mine prod" where dependency is tagged "mine" """ # do some setup for this test pdir = os.path.join(testEupsStack, "Linux", "newprod") pdir10 = os.path.join(pdir, "1.0") pdir20 = os.path.join(pdir, "1.0") pdbdir = os.path.join(self.dbpath, "newprod") pupsdir = os.path.join(pdbdir, "Linux") ptble10 = os.path.join(pupsdir, "1.0.table") ptble20 = os.path.join(pupsdir, "2.0.table") newprodtable = \ """ setupRequired(python 2.5.2 [>= 2.5]) """ pyprod = self.eups.getProduct("python", "2.5.2") pytdir = pyprod.dir self.eups.declare("newprod", "1.0", pdir10, testEupsStack, tablefile=StringIO(newprodtable), tag="current") self.eups.declare("newprod", "2.0", pdir20, testEupsStack, tablefile=StringIO(newprodtable)) self.eups.declare("python", "test", pytdir, testEupsStack) self.eups.assignTag("rhl", "python", "test") # test the setup self.assert_(self.eups.findProduct("newprod", "1.0") is not None, "newprod 1.0 not declared") self.assert_(self.eups.findProduct("newprod", "2.0") is not None, "newprod 2.0 not declared") self.assert_(os.path.exists(ptble10), "Can't find newprod 1.0's table file") self.assert_(os.path.exists(ptble20), "Can't find newprod 2.0's table file") self.assert_(self.eups.findProduct("python", "test") is not None, "python test not declared") self.assertEquals(len(p for p in self.eups.uses("python") if p[0] == "newprod"), 2, "newprod does not depend on python") # now we are ready to go: request the beta version of newprod q = eups.Quiet(self.eups) eups.setup("newprod", prefTags="rhl", eupsenv=self.eups) del q prod = self.eups.findSetupProduct("newprod") self.assert_(prod is not None, "newprod not setup") self.assertEquals(prod.version, "1.0") self.assertIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") self.assertEquals(os.environ["NEWPROD_DIR"], pdir20) prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEquals(prod.version, "test") # tagged rhl self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEquals(os.environ["PYTHON_DIR"], prod.dir)
def testProductDir(self): if "PYTHON_DIR" in os.environ: del os.environ["PYTHON_DIR"] if "SETUP_PYTHON" in os.environ: del os.environ["SETUP_PYTHON"] self.assertTrue( eups.productDir("python") is None, "found unsetup product") pdir = os.path.join(testEupsStack, os.environ["EUPS_FLAVOR"], "python", "2.5.2") dir = eups.productDir("python", "2.5.2") self.assertEqual(dir, pdir) eups.setup("python", "2.5.2") dir = eups.productDir("python") self.assertEqual(dir, pdir)
def testProductDir(self): if "PYTHON_DIR" in os.environ: del os.environ["PYTHON_DIR"] if "SETUP_PYTHON" in os.environ: del os.environ["SETUP_PYTHON"] self.assert_(eups.productDir("python") is None, "found unsetup product") pdir = os.path.join(testEupsStack, os.environ["EUPS_FLAVOR"], "python", "2.5.2") dir = eups.productDir("python", "2.5.2") self.assertEquals(dir, pdir) eups.setup("python", "2.5.2") dir = eups.productDir("python") self.assertEquals(dir, pdir)
def testGetSetupVersion(self): self.assertRaises(eups.ProductNotFound, eups.getSetupVersion, "python") eups.setup("python", "2.5.2") version = eups.getSetupVersion("python") self.assertEqual(version, "2.5.2")
def testTaggedTarget(self): """ test equivalent to "setup --tag mine prod" where prod is tagged "mine" """ # do some setup for this test pdir = os.path.join(testEupsStack, "Linux", "newprod") pdir10 = os.path.join(pdir, "1.0") pdir20 = os.path.join(pdir, "1.0") pdbdir = os.path.join(self.dbpath, "newprod") pupsdir = os.path.join(pdbdir, "Linux") ptble10 = os.path.join(pupsdir, "1.0.table") ptble20 = os.path.join(pupsdir, "2.0.table") newprodtable = \ """ setupRequired(python) """ self.eups.declare("newprod", "1.0", pdir10, testEupsStack, tablefile=StringIO(newprodtable)) self.eups.declare("newprod", "2.0", pdir20, testEupsStack, tablefile=StringIO(newprodtable), tag="beta") # test the setup self.assert_( self.eups.findProduct("newprod", "1.0") is not None, "newprod 1.0 not declared") self.assert_( self.eups.findProduct("newprod", "2.0") is not None, "newprod 2.0 not declared") self.assert_(os.path.exists(ptble10), "Can't find newprod 1.0's table file") self.assert_(os.path.exists(ptble20), "Can't find newprod 2.0's table file") self.assertEqual( len(p for p in self.eups.uses("python") if p[0] == "newprod"), 2, "newprod does not depend on python") # now we are ready to go: request the beta version of newprod eups.setup("newprod", prefTags="beta") prod = self.eups.findSetupProduct("newprod") self.assert_(prod is not None, "newprod not setup") self.assertEqual(prod.version, "2.0") self.assertIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") self.assertEqual(os.environ["NEWPROD_DIR"], pdir20) prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEqual(prod.version, "2.5.2") # tagged current self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEqual(os.environ["PYTHON_DIR"], prod.dir) eups.unsetup("newprod") prod = self.eups.findSetupProduct("newprod") self.assert_(prod is None, "newprod is still setup") self.assertNotIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertNotIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") prod = self.eups.findSetupProduct("python") self.assert_(prod is None, "python is still setup") self.assertNotIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON is still set") self.assertNotIn("PYTHON_DIR", os.environ, "PYTHON_DIR is still set") # now test with dependent product with requested tag self.eups.assignTag("beta", "python", "2.6") eups.setup("newprod", prefTags="beta") prod = self.eups.findSetupProduct("newprod") self.assert_(prod is not None, "newprod not setup") self.assertEqual(prod.version, "2.0") self.assertIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") self.assertEqual(os.environ["NEWPROD_DIR"], pdir20) prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEqual(prod.version, "2.6") # tagged beta self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEqual(os.environ["PYTHON_DIR"], prod.dir) self.eups.unassignTag("beta", "python")
def testDefPrefTag(self): """ test equivalent to "setup prod" """ # test some assumptions preftags = self.eups.getPreferredTags() self.assertIn("current", preftags, "no python marked current") self.assertNotIn("SETUP_PYTHON", os.environ, "python already set") # setup the preferred (tagged current) version eups.setup("python") prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEqual(prod.version, "2.5.2") self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEqual(os.environ["PYTHON_DIR"], prod.dir) # check for dependent product prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is not None, "tcltk not setup") self.assertEqual(prod.version, "8.5a4") self.assertIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK not set") self.assertIn("TCLTK_DIR", os.environ, "TCLTK_DIR not set") self.assertEqual(os.environ["TCLTK_DIR"], prod.dir) eups.unsetup("python") prod = self.eups.findSetupProduct("python") self.assert_(prod is None, "python is still setup") self.assertNotIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON is still set") self.assertNotIn("PYTHON_DIR", os.environ, "PYTHON_DIR is still set") prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is None, "tcltk is still setup") self.assertNotIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK is still set") self.assertNotIn("TCLTK_DIR", os.environ, "TCLTK_DIR is still set") # set up an explicit version eups.setup("python", "2.5.2") prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEqual(prod.version, "2.5.2") self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEqual(os.environ["PYTHON_DIR"], prod.dir) # check for dependent product prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is not None, "tcltk not setup") self.assertEqual(prod.version, "8.5a4") self.assertIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK not set") self.assertIn("TCLTK_DIR", os.environ, "TCLTK_DIR not set") self.assertEqual(os.environ["TCLTK_DIR"], prod.dir) eups.unsetup("python") prod = self.eups.findSetupProduct("python") self.assert_(prod is None, "python is still setup") self.assertNotIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON is still set") self.assertNotIn("PYTHON_DIR", os.environ, "PYTHON_DIR is still set") prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is None, "tcltk is still setup") self.assertNotIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK is still set") self.assertNotIn("TCLTK_DIR", os.environ, "TCLTK_DIR is still set")
# if self.opts.productDir and not self.opts.tablefile and productName and versionName: prod = Eups.findProduct(productName, versionName) if not prod: self.err("Unable to find %s %s" % (productName, versionName)) return 3 tablefile = prod.tablefile else: tablefile = self.opts.tablefile cmds = eups.setup( productName, versionName, self.opts.tag, self.opts.productDir, Eups, fwd=not self.opts.unsetup, tablefile=tablefile, postTags=self.opts.postTag, ) except EupsException, e: e.status = 1 raise except Exception, e: e.status = -1 raise finally: lock.giveLocks(locks, self.opts.verbose) if Eups.verbose > 3:
def testDefPrefTag(self): """ test equivalent to "setup prod" """ # test some assumptions preftags = self.eups.getPreferredTags() self.assertIn("current", preftags, "no python marked current") self.assertNotIn("SETUP_PYTHON", os.environ, "python already set") # setup the preferred (tagged current) version eups.setup("python") prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEquals(prod.version, "2.5.2") self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEquals(os.environ["PYTHON_DIR"], prod.dir) # check for dependent product prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is not None, "tcltk not setup") self.assertEquals(prod.version, "8.5a4") self.assertIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK not set") self.assertIn("TCLTK_DIR", os.environ, "TCLTK_DIR not set") self.assertEquals(os.environ["TCLTK_DIR"], prod.dir) eups.unsetup("python") prod = self.eups.findSetupProduct("python") self.assert_(prod is None, "python is still setup") self.assertNotIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON is still set") self.assertNotIn("PYTHON_DIR", os.environ, "PYTHON_DIR is still set") prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is None, "tcltk is still setup") self.assertNotIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK is still set") self.assertNotIn("TCLTK_DIR", os.environ, "TCLTK_DIR is still set") # set up an explicit version eups.setup("python", "2.5.2") prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEquals(prod.version, "2.5.2") self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEquals(os.environ["PYTHON_DIR"], prod.dir) # check for dependent product prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is not None, "tcltk not setup") self.assertEquals(prod.version, "8.5a4") self.assertIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK not set") self.assertIn("TCLTK_DIR", os.environ, "TCLTK_DIR not set") self.assertEquals(os.environ["TCLTK_DIR"], prod.dir) eups.unsetup("python") prod = self.eups.findSetupProduct("python") self.assert_(prod is None, "python is still setup") self.assertNotIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON is still set") self.assertNotIn("PYTHON_DIR", os.environ, "PYTHON_DIR is still set") prod = self.eups.findSetupProduct("tcltk") self.assert_(prod is None, "tcltk is still setup") self.assertNotIn("SETUP_TCLTK", os.environ, "SETUP_TCLTK is still set") self.assertNotIn("TCLTK_DIR", os.environ, "TCLTK_DIR is still set")
def testGetSetupVersion(self): self.assertRaises(eups.ProductNotFound, eups.getSetupVersion, "python") eups.setup("python", "2.5.2") version = eups.getSetupVersion("python") self.assertEquals(version, "2.5.2")
def testTaggedTarget(self): """ test equivalent to "setup --tag mine prod" where prod is tagged "mine" """ # do some setup for this test pdir = os.path.join(testEupsStack, "Linux", "newprod") pdir10 = os.path.join(pdir, "1.0") pdir20 = os.path.join(pdir, "1.0") pdbdir = os.path.join(self.dbpath, "newprod") pupsdir = os.path.join(pdbdir, "Linux") ptble10 = os.path.join(pupsdir, "1.0.table") ptble20 = os.path.join(pupsdir, "2.0.table") newprodtable = \ """ setupRequired(python) """ self.eups.declare("newprod", "1.0", pdir10, testEupsStack, tablefile=StringIO(newprodtable)) self.eups.declare("newprod", "2.0", pdir20, testEupsStack, tablefile=StringIO(newprodtable), tag="beta") # test the setup self.assert_(self.eups.findProduct("newprod", "1.0") is not None, "newprod 1.0 not declared") self.assert_(self.eups.findProduct("newprod", "2.0") is not None, "newprod 2.0 not declared") self.assert_(os.path.exists(ptble10), "Can't find newprod 1.0's table file") self.assert_(os.path.exists(ptble20), "Can't find newprod 2.0's table file") self.assertEquals(len(p for p in self.eups.uses("python") if p[0] == "newprod"), 2, "newprod does not depend on python") # now we are ready to go: request the beta version of newprod eups.setup("newprod", prefTags="beta") prod = self.eups.findSetupProduct("newprod") self.assert_(prod is not None, "newprod not setup") self.assertEquals(prod.version, "2.0") self.assertIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") self.assertEquals(os.environ["NEWPROD_DIR"], pdir20) prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEquals(prod.version, "2.5.2") # tagged current self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEquals(os.environ["PYTHON_DIR"], prod.dir) eups.unsetup("newprod") prod = self.eups.findSetupProduct("newprod") self.assert_(prod is None, "newprod is still setup") self.assertNotIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertNotIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") prod = self.eups.findSetupProduct("python") self.assert_(prod is None, "python is still setup") self.assertNotIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON is still set") self.assertNotIn("PYTHON_DIR", os.environ, "PYTHON_DIR is still set") # now test with dependent product with requested tag self.eups.assignTag("beta", "python", "2.6") eups.setup("newprod", prefTags="beta") prod = self.eups.findSetupProduct("newprod") self.assert_(prod is not None, "newprod not setup") self.assertEquals(prod.version, "2.0") self.assertIn("SETUP_NEWPROD", os.environ, "SETUP_NEWPROD not set") self.assertIn("NEWPROD_DIR", os.environ, "NEWPROD_DIR not set") self.assertEquals(os.environ["NEWPROD_DIR"], pdir20) prod = self.eups.findSetupProduct("python") self.assert_(prod is not None, "python not setup") self.assertEquals(prod.version, "2.6") # tagged beta self.assertIn("SETUP_PYTHON", os.environ, "SETUP_PYTHON not set") self.assertIn("PYTHON_DIR", os.environ, "PYTHON_DIR not set") self.assertEquals(os.environ["PYTHON_DIR"], prod.dir) self.eups.unassignTag("beta", "python")
def execute(self): productName = versionName = None if len(self.args) > 0: productName = self.args[0] if len(self.args) > 1: versionName = self.args[1] if self.opts.unsetup: cmdName = "unsetup" else: cmdName = "setup" if not self.opts.noCallbacks: try: eups.commandCallbacks.apply(None, cmdName, self.opts, self.args) except eups.OperationForbidden as e: e.status = 255 raise except Exception as e: e.status = 9 raise if self.opts.exact_version and self.opts.inexact_version: self.err("Specifying --exact --inexact confuses me, so I'll ignore both") self.opts.exact_version = False self.opts.inexact_version = False if self.opts.tablefile: # we're setting up a product based only on a tablefile if self.opts.unsetup: self.err("Ignoring --table as I'm unsetting up a product") self.opts.tablefile = None else: if not os.path.exists(self.opts.tablefile) and self.opts.tablefile != "none": self.err("%s does not exist" % self.opts.tablefile) print(self.clo.get_usage(), file=utils.stderr) return 3 self.opts.tablefile = os.path.abspath(self.opts.tablefile) if not productName: self.opts.productDir = os.path.dirname(self.opts.tablefile) productName = os.path.splitext(os.path.basename(self.opts.tablefile))[0] if not self.opts.productDir and not productName: self.err("please specify at least a product name or use -r") print(self.clo.get_usage(), file=utils.stderr) return 3 if self.opts.productDir: self.opts.productDir = os.path.abspath(self.opts.productDir) try: productName = eups.utils.guessProduct(os.path.join(self.opts.productDir, "ups"), productName) except EupsException as e: e.status = 4 raise except RuntimeError as e: if self.opts.tablefile: pass # They explicitly listed the table file to use, so trust them else: e.status = 4 raise if not productName: self.err("Please specify a product") print(self.clo.get_usage(), file=utils.stderr) return 3 if self.opts.nodepend: if self.opts.max_depth > 0: self.err("You may not specify both --just and --max_depth") return 3 self.opts.max_depth = 0 path = eups.Eups.setEupsPath(self.opts.path, self.opts.dbz) locks = lock.takeLocks( "setup", path, lock.LOCK_SH, nolocks=self.opts.nolocks, verbose=self.opts.verbose - self.opts.quiet ) # # Do the work # status = 0 try: try: Eups = eups.Eups( flavor=self.opts.flavor, path=self.opts.path, dbz=self.opts.dbz, # root=self.opts.productDir, readCache=False, force=self.opts.force, quiet=self.opts.quiet, verbose=self.opts.verbose, noaction=self.opts.noaction, keep=self.opts.keep, ignore_versions=self.opts.ignoreVer, setupType=self.opts.setupType, max_depth=self.opts.max_depth, vro=self.opts.vro, exact_version=self.opts.exact_version, cmdName="setup", ) Eups._processDefaultTags(self.opts) if not self.opts.noCallbacks: try: eups.commandCallbacks.apply(Eups, cmdName, self.opts, self.args) except eups.OperationForbidden as e: e.status = 255 raise except Exception as e: e.status = 9 raise Eups.selectVRO( self.opts.tag, self.opts.productDir, versionName, self.opts.dbz, inexact_version=self.opts.inexact_version, postTag=self.opts.postTag, ) if self.opts.tag: for t in self.opts.tag: if Eups.isUserTag(t): break Eups.includeUserDataDirInPath() for user in Eups.tags.owners.values(): Eups.includeUserDataDirInPath(eups.utils.defaultUserDataDir(user)) # # If they specify a productDir in addition to a complete product + version specification # Use that product + version's expanded table file, but this directory # if self.opts.productDir and not self.opts.tablefile and productName and versionName: prod = Eups.findProduct(productName, versionName) if not prod: self.err("Unable to find %s %s" % (productName, versionName)) return 3 tablefile = prod.tablefile else: tablefile = self.opts.tablefile cmds = eups.setup( productName, versionName, self.opts.tag, self.opts.productDir, Eups, fwd=not self.opts.unsetup, tablefile=tablefile, postTags=self.opts.postTag, ) except EupsException as e: e.status = 1 raise except Exception as e: e.status = -1 raise finally: lock.giveLocks(locks, self.opts.verbose) if Eups.verbose > 3: print("\n\t".join(["Issuing commands:"] + cmds), file=sys.stderr) print(";\n".join(cmds)) return status
# if self.opts.productDir and not self.opts.tablefile and productName and versionName: prod = Eups.findProduct(productName, versionName) if not prod: self.err("Unable to find %s %s" % (productName, versionName)) return 3 tablefile = prod.tablefile else: tablefile = self.opts.tablefile cmds = eups.setup(productName, versionName, self.opts.tag, self.opts.productDir, Eups, fwd=not self.opts.unsetup, tablefile=tablefile, postTags=self.opts.postTag) except EupsException, e: e.status = 1 raise except Exception, e: e.status = -1 raise finally: lock.giveLocks(locks, self.opts.verbose) if Eups.verbose > 3: print >> sys.stderr, "\n\t".join(["Issuing commands:"] + cmds)
def execute(self): productName = versionName = None if len(self.args) > 0: productName = self.args[0] if len(self.args) > 1: versionName = self.args[1] if self.opts.unsetup: cmdName = "unsetup" else: cmdName = "setup" if not self.opts.noCallbacks: try: eups.commandCallbacks.apply(None, cmdName, self.opts, self.args) except eups.OperationForbidden as e: e.status = 255 raise except Exception as e: e.status = 9 raise if self.opts.exact_version and self.opts.inexact_version: self.err("Specifying --exact --inexact confuses me, so I'll ignore both") self.opts.exact_version = False self.opts.inexact_version = False if self.opts.tablefile: # we're setting up a product based only on a tablefile if self.opts.unsetup: self.err("Ignoring --table as I'm unsetting up a product") self.opts.tablefile = None else: if not os.path.exists(self.opts.tablefile) and self.opts.tablefile != "none": self.err("%s does not exist" % self.opts.tablefile) print(self.clo.get_usage(), file=utils.stderr) return 3 self.opts.tablefile = os.path.abspath(self.opts.tablefile) if not productName: self.opts.productDir = os.path.dirname(self.opts.tablefile) productName = os.path.splitext(os.path.basename(self.opts.tablefile))[0] if not self.opts.productDir and not productName: self.err("please specify at least a product name or use -r") print(self.clo.get_usage(), file=utils.stderr) return 3 if self.opts.productDir: self.opts.productDir = os.path.abspath(self.opts.productDir) try: productName = eups.utils.guessProduct(os.path.join(self.opts.productDir, "ups"), productName) except EupsException as e: e.status = 4 raise except RuntimeError as e: if self.opts.tablefile: pass # They explicitly listed the table file to use, so trust them else: e.status = 4 raise if not productName: self.err("Please specify a product") print(self.clo.get_usage(), file=utils.stderr) return 3 if self.opts.nodepend: if self.opts.max_depth > 0: self.err("You may not specify both --just and --max_depth") return 3 self.opts.max_depth = 0 path = eups.Eups.setEupsPath(self.opts.path, self.opts.dbz) locks = lock.takeLocks("setup", path, lock.LOCK_SH, nolocks=self.opts.nolocks, verbose=self.opts.verbose - self.opts.quiet) # # Do the work # status = 0 try: try: Eups = eups.Eups(flavor=self.opts.flavor, path=self.opts.path, dbz=self.opts.dbz, # root=self.opts.productDir, readCache=False, force=self.opts.force, quiet=self.opts.quiet, verbose=self.opts.verbose, noaction=self.opts.noaction, keep=self.opts.keep, ignore_versions=self.opts.ignoreVer, setupType=self.opts.setupType, max_depth=self.opts.max_depth, vro=self.opts.vro, exact_version=self.opts.exact_version, cmdName="setup") Eups._processDefaultTags(self.opts) if not self.opts.noCallbacks: try: eups.commandCallbacks.apply(Eups, cmdName, self.opts, self.args) except eups.OperationForbidden as e: e.status = 255 raise except Exception as e: e.status = 9 raise Eups.selectVRO(self.opts.tag, self.opts.productDir, versionName, self.opts.dbz, inexact_version=self.opts.inexact_version, postTag=self.opts.postTag) if self.opts.tag: for t in self.opts.tag: if Eups.isUserTag(t): break Eups.includeUserDataDirInPath() for user in Eups.tags.owners.values(): Eups.includeUserDataDirInPath(eups.utils.defaultUserDataDir(user)) # # If they specify a productDir in addition to a complete product + version specification # Use that product + version's expanded table file, but this directory # if self.opts.productDir and not self.opts.tablefile and productName and versionName: prod = Eups.findProduct(productName, versionName) if not prod: self.err("Unable to find %s %s" % (productName, versionName)) return 3 tablefile = prod.tablefile else: tablefile=self.opts.tablefile cmds = eups.setup(productName, versionName, self.opts.tag, self.opts.productDir, Eups, fwd=not self.opts.unsetup, tablefile=tablefile, postTags=self.opts.postTag) except EupsException as e: e.status = 1 raise except Exception as e: e.status = -1 raise finally: lock.giveLocks(locks, self.opts.verbose) if Eups.verbose > 3: print("\n\t".join(["Issuing commands:"] + cmds), file=sys.stderr) print(";\n".join(cmds)) return status