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)
Example #2
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: