コード例 #1
0
    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)

        known_tags = ["prod"]

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        allvers = {}

        for tag in known_tags:
            tmplist = []
            for p in sorted(self.mConfDB.listTag(tag.upper())):
                tmplist.append(p)
            allvers[tag] = tmplist

        import json
        print json.dumps(allvers, indent=2)
コード例 #2
0
class LbSdbDeleteVersion(Script):
    """ Delete information about a project / version """
    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest="debug",
                          action="store_true",
                          help="Display debug output")

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()
        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 2:
            self.log.error("Not enough arguments")
            sys.exit(1)
        else:
            project = args[0].upper()
            version = args[1]

            # Connect to the ConfDB to update the platform
            self.mConfDB = SoftConfDB()
            self.mConfDB.deletePV(project, version)
コード例 #3
0
    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 2:
            self.log.error("Not enough arguments")
            sys.exit(1)
        else:
            project = args[0].upper()
            version = args[1]

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        if self.options.remove:
            self.mConfDB.unsetReleaseFlag(project, version)
        else:
            self.mConfDB.setReleaseFlag(project, version)
コード例 #4
0
class LbSdbClear(Script):
    """ Clears the Active or Used flags """
    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest="debug",
                          action="store_true",
                          help="Display debug output")

        parser.add_option("-s",
                          dest="action",
                          action="store",
                          default="a",
                          help="Set the action to be done: a: active, u: used")

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()
        if self.options.action.lower() == "a":
            self.mConfDB.deleteActiveLinks()
        elif self.options.action.lower() == "u":
            self.mConfDB.deleteUsedLinks()
        else:
            self.log.error("Unknown action %s " % self.options.action)
コード例 #5
0
    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 2 :
            self.log.error("Not enough arguments")
            sys.exit(1)
        else :
            project   = args[0].upper()
            version   = args[1]

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        buildtool = "cmake"
        if self.options.usecmt:
            if self.options.usecmake:
                raise Exception("Please specify one build system only")
            buildtool = "cmt"
        
        if self.options.remove:
            self.mConfDB.unsetBuildTool(project, version)
        else:
            self.mConfDB.setBuildTool(project, version, buildtool)
コード例 #6
0
class LbSdbBuildTool(Script):
    """ Update information about a project / version to say whether it was built with CMake or CMT"""

    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest = "debug",
                          action = "store_true",
                          help = "Display debug output")

        parser.add_option("-r", "--remove",
                          dest = "remove",
                          action = "store_true",
                          default = False,
                          help = "Remove the link to the CMake node")
        parser.add_option("--cmt",
                          dest = "usecmt",
                          action = "store_true",
                          default = False,
                          help = "Set the build tool to be CMT")
        parser.add_option("--cmake",
                          dest = "usecmake",
                          action = "store_true",
                          default = False,
                          help = "Set the build tool to be CMT")

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 2 :
            self.log.error("Not enough arguments")
            sys.exit(1)
        else :
            project   = args[0].upper()
            version   = args[1]

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        buildtool = "cmake"
        if self.options.usecmt:
            if self.options.usecmake:
                raise Exception("Please specify one build system only")
            buildtool = "cmt"
        
        if self.options.remove:
            self.mConfDB.unsetBuildTool(project, version)
        else:
            self.mConfDB.setBuildTool(project, version, buildtool)
コード例 #7
0
    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()
        if self.options.action.lower() == "a":
            self.mConfDB.deleteActiveLinks()
        elif self.options.action.lower() == "u":
            self.mConfDB.deleteUsedLinks()
        else:
            self.log.error("Unknown action %s " % self.options.action)
コード例 #8
0
class LbSdbTag(Script):
    """ Update information about a project / version to say whether it was built with CMake or CMT"""
    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest="debug",
                          action="store_true",
                          help="Display debug output")

        parser.add_option("-r",
                          "--remove",
                          dest="remove",
                          action="store_true",
                          default=False,
                          help="Remove the link to the CMake node")

        parser.add_option("-p",
                          "--platform",
                          dest="platform",
                          action="store",
                          default=None,
                          help="Set the tag to the project/version/platform")

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 3:
            self.log.error("Not enough arguments")
            sys.exit(1)
        else:
            project = args[0].upper()
            version = args[1]
            tag = args[2].upper()

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        if self.options.remove:
            if self.options.platform != None:
                self.mConfDB.unsetPlatformTag(project, version,
                                              self.options.platform, tag)
            else:
                self.mConfDB.unsetTag(project, version, tag)
        else:
            if self.options.platform != None:
                self.mConfDB.setPlatformTag(project, version,
                                            self.options.platform, tag)
            else:
                self.mConfDB.setTag(project, version, tag)
コード例 #9
0
    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()
        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 2:
            self.log.error("Not enough arguments")
            sys.exit(1)
        else:
            project = args[0].upper()
            version = args[1]

            # Connect to the ConfDB to update the platform
            self.mConfDB = SoftConfDB()
            n = self.mConfDB.mNeoDB.get_indexed_node("ProjectVersion",
                                                     "ProjectVersion",
                                                     project + "_" + version)
            dbRev = n['Rev']
            svnRev = getProjectLastRev(project, version)

            status = "ERROR"
            if dbRev == svnRev:
                status = "OK"
            print "%5s %s %s" % (status, dbRev, svnRev)
            sys.exit(dbRev != svnRev)
コード例 #10
0
class LbSdbUpdateVersion(Script):
    """ Update information about a project / version """
    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest="debug",
                          action="store_true",
                          help="Display debug output")

        parser.add_option(
            "-s",
            dest="action",
            action="store",
            default="a",
            help=
            "Set the action to be done: a: clear active flags, u: clear used flags"
        )

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()
        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 2:
            self.log.error("Not enough arguments")
            sys.exit(1)
        else:
            project = args[0].upper()
            version = args[1]

            # Connect to the ConfDB to update the platform
            self.mConfDB = SoftConfDB()
            if self.options.action.lower() == "a":
                self.mConfDB.setPVActive(project, version)
            elif self.options.action.lower() == "u":
                self.mConfDB.setPVUsed(project, version)
            else:
                self.log.error("Unknown action %s " % self.options.action)
コード例 #11
0
class LbSdbAddPlatform(Script):
    """ Script to add platforms to a project in the Software
    Configuration DB. Use:
    LbSdbAddPlatform project version platform
    """

    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest = "debug",
                          action = "store_true",
                          help = "Display debug output")
        parser.add_option("-r",
                          dest = "remove",
                          action = "store_true",
                          default=False,
                          help = "Remove platform instead of adding")

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()
        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 3 :
            self.log.error("Not enough arguments")
            sys.exit(1)
        else :
            project   = args[0].upper()
            version   = args[1]
            platform  = args[2]

            # Connect to the ConfDB to update the platform
            self.mConfDB = SoftConfDB()
            if opts.remove:
                self.mConfDB.delPVPlatform(project, version, platform)
            else:
                self.mConfDB.addPVPlatform(project, version, platform)
コード例 #12
0
class LbSdbSetApp(Script):
    """ Update information about a project / version """

    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest = "debug",
                          action = "store_true",
                          help = "Display debug output")

        parser.add_option("-r",
                          dest = "remove",
                          action = "store_true",
                          default = False,
                          help = "Remove the link to the application node")


    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()


        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)
        if len(args) < 1 :
            self.log.error("Not enough arguments")
            sys.exit(1)
        else :
            project   = args[0].upper()

                # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        if self.options.remove:
            self.mConfDB.unsetApplication(project)
        else:
            self.mConfDB.setApplication(project)
コード例 #13
0
class LbSdbGenerateVersionJSON(Script):
    """ Update information about a project / version to say whether it was built with CMake or CMT"""
    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest="debug",
                          action="store_true",
                          help="Display debug output")

    def main(self):
        """ Main method for bootstrap and parsing the options.
        It invokes the appropriate method and  """
        self.log = logging.getLogger()

        opts = self.options
        args = self.args
        if opts.debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.WARNING)

        known_tags = ["prod"]

        # Connect to the ConfDB to update the platform
        self.mConfDB = SoftConfDB()

        allvers = {}

        for tag in known_tags:
            tmplist = []
            for p in sorted(self.mConfDB.listTag(tag.upper())):
                tmplist.append(p)
            allvers[tag] = tmplist

        import json
        print json.dumps(allvers, indent=2)
コード例 #14
0
class AppImporter:
    """ Main scripts class for looking up dependencies.
    It inherits from """
    def __init__(self, autorelease=True):
        # Creating the SoftConfDB Object
        self.mConfDB = SoftConfDB()
        self.log = logging.getLogger()
        self.installArea = None
        self.mAutorelease = autorelease

    def processProjectVersion(self, p, v, alreadyDone=[], recreate=False):
        """ Get the dependencies for a single project """
        # Cleanup the project name and version and get the SVN URL
        (proj, ver) = importerTranslateProject(p, v)
        tagpath = ""

        # Getting the project.cmt file with dependencies
        if proj.upper() == "GANGA":
            projcmt = self.getGangaProjectCMT(ver)
        else:
            if proj.upper() == "GAUDI":
                tagpath = gaudisvn.url(proj, ver, isProject=True)
            elif proj.upper() == "LHCBDIRAC" or proj.upper() == "DIRAC":
                tagpath = diracsvn.url(proj, ver, isProject=True)
            else:
                tagpath = lbsvn.url(proj, ver, isProject=True)
            self.log.debug("SVN PATH:" + tagpath)
            # Get the project.cmt file and parse it to retrieve the dependencies
            #if not tagpath.endswith("cmt"):
            #    tagpath += "/cmt"
            projcmt = getProjectCmt(tagpath).strip()
            self.log.debug("Project tag SVN path:" + tagpath)
        deps = []

        # Formatting the project name/version
        corver = ver
        if proj in ver:
            corver = ver.replace(proj + "_", "")
        proj = proj.upper()

        # Looking for the project version in the DB
        tmp = self.mConfDB.findVersion(proj, ver)
        rev = getPathLastRev(tagpath)
        createNode = False
        node_parent = None

        # First checking if the node is there with the correct revision
        if len(tmp) != 0:
            node = tmp[0][0]
            node_parent = node
            noderev = node["Rev"]
            if noderev != None:
                self.log.warning(
                    "Project %s %s already exists with revision %s (path rev: %s)"
                    % (proj, ver, noderev, rev))
                if rev != noderev and recreate:
                    self.log.warning(
                        "Mismatch in revisions for %s %s, recreating" %
                        (proj, ver))
                    self.log.warning(
                        "WARNING was a retag of  %s %s done? you may need to call "
                        " lb-sdb-deletepv <proj> <ver> and reimport if "
                        " it is the case " % (proj, ver))

                    try:
                        self.mConfDB.deletePV(proj, corver)
                    except Exception, e:
                        self.log.error(e)
                    createNode = True

            else:
                self.log.warning(
                    "Project %s %s already exists without revision" %
                    (proj, ver))

        #If the node does not exist just create it...
        else:
コード例 #15
0
 def __init__(self):
     # Creating the SoftConfDB Object
     self.mConfDB = SoftConfDB()
     self.log = logging.getLogger()
     self.installArea = None
     self.doSvnCheck = True
コード例 #16
0
class DatapkgImporter:
    """ Main script to look up package """
    def __init__(self):
        # Creating the SoftConfDB Object
        self.mConfDB = SoftConfDB()
        self.log = logging.getLogger()
        self.installArea = None
        self.doSvnCheck = True

    def setSvnCheck(self, svncheck):
        """ Set the flag indicating whether the SVN check should be done """
        self.doSvnCheck = svncheck

    def importpkg(self, project, datapkg, version, hat=None):
        """ Import a datapackage version """

        project = project.upper()
        tmp = datapkg
        if hat != None:
            tmp = "/".join([hat, datapkg])
        self.log.info("Checking %s %s %s" % (project, tmp, version))

        # Loading the package from LbScripts
        pack = getPackage(datapkg)
        if pack.hat() != hat:
            raise Exception("Error importing: hat does not match conf data!")

        if pack.project().upper() != project:
            raise Exception(
                "Error importing: project does not match conf data!")

        # Check if the package actually exist
        if self.doSvnCheck:
            found = lbsvn.hasVersion(tmp, version)
            if not found:
                raise Exception("Could not find package  %s %s %s in SVN" %
                                (project, tmp, version))

        # Now creating the package if it does not exist
        self.log.warning("Adding to DB %s %s %s" % (project, tmp, version))
        self.mConfDB.getOrCreateDatapkgVersion(project, hat, datapkg, version)

    def importProjectDir(self, dirname, hat=None, nbdays=-1):
        """ Import all projects in a directory """
        import os

        # Checking existence
        if not os.path.exists(dirname):
            raise Exception("Directory %s does not exist" % dirname)

        # Getting the absolute path
        dirabspath = os.path.realpath(os.path.abspath(dirname))

        # Now iterating on the subdirs, we try and see if they are data packages
        # That's how we separate datapackages from hats...
        for entry in os.listdir(dirabspath):
            path = os.path.join(dirabspath, entry)

            # We ignores files, just processing directories...
            if not os.path.isdir(path):
                continue

            pack = None
            try:
                pack = getPackage(entry)
            except PackageConfException:
                # This is not a package, it maybe a hat for other packages...
                # but only if we're not trying to process a hat already...
                # CAREFUL: only handle one level hats...
                if hat == None:
                    self.log.warning("Processing  subdirectory %s" % entry)
                    # Checking the date
                    verpath = os.path.join(dirname, entry)
                    self.importProjectDir(verpath, entry, nbdays)

            if pack != None:
                # Now performing the import
                self.log.info("Processing package: %s" % entry)
                self._importPackage(os.path.join(dirname, entry), hat, pack,
                                    nbdays)

    def _importPackage(self, datapkgdir, hat, pack, nbdays):
        """ Import all the versions of a package from a specific directory """
        # First some checks...
        project = pack.project()
        datapkg = pack.Name()
        if hat != pack.hat():
            raise Exception("Mismatch in hats: %s vs %s" % (hat, pack.hat()))
        if hat == None:
            har = ""

        # Now adding all the versions from the directory
        # Using LbCOnfigurations tool for that
        for ver in getVersionsFromDir(datapkgdir):
            self.log.info("Adding package %s %s %s %s" %
                          (project, hat, datapkg, ver.name()))
            verpath = os.path.join(datapkgdir, ver.name())
            processdir = True
            if nbdays > 0:
                now = datetime.now()
                delta = timedelta(days=nbdays)
                then = datetime.fromtimestamp(os.path.getctime(verpath))
                if (now - then) > delta:
                    self.log.info("Too old %s" % verpath)
                    processdir = False
            if processdir == True:
                self.importpkg(project, datapkg, ver.name(), hat)
コード例 #17
0
 def __init__(self, autorelease=True):
     # Creating the SoftConfDB Object
     self.mConfDB = SoftConfDB()
     self.log = logging.getLogger()
     self.installArea = None
     self.mAutorelease = autorelease