Ejemplo n.º 1
0
def CMT2LHCb(projectname, projectversion):
    if "_" in projectversion:
        newversion = projectversion.split("_")[1]
    else:
        newversion = projectversion
    newname = getProject(projectname).Name()
    return newname, newversion
Ejemplo n.º 2
0
def translateProject(project,version):
    """
    take project:version strings
    convert to the correct strings for the SVN repository tools
    returns a tuple, project,version

    Used to deal with silly capitalization in our software
    """
    #project=project.lower()
    #if project=="davinci":
    #    project="DaVinci"
    #elif project=="lhcb":
    #    project="LHCb"
    #elif project=="lhcbdirac":
    #   project="LHCbDirac"
    #elif project=="lbscripts":
        # This is a temporary fix, we need to integrate with the list of projects from LbConfiguration
    #    project="LbScripts"
    #else:
    #    project=project[0].upper()+project[1:]

    # Integrate this class with the normal LHCb project list
    try:
        project = getProject(project, True).Name()
    except:
        # If that fails use the capitalized version
        project = project.lower()
        project=project[0].upper()+project[1:]

    # Cleaning up version from PROJECT string
    if '_' in version and project.upper() == version.split('_')[0].upper():
        version=version.split('_')[-1]


    return (project,version)
Ejemplo n.º 3
0
    def resetActiveFlag(self, path):
        """ Set the Active flag correctly based on an install area """

        # First clear everything...
        # We use a btach to submit all actions at the same time
        confDB = self.mAppImporter.mConfDB
        batch = confDB.getWriteBatch()
        confDB.deleteActiveLinks(batch)

        projCounter = 0
        # First find projects
        for projdir in os.listdir(path):
            # Checking if this corresponds to an existing project...
            proj = None
            try:
                proj = getProject(projdir)
            except:
                pass

            # If yes, then process it...
            if proj != None:
                releases = self.findRecentReleasesForProject(
                    os.path.join(path, projdir), projdir, -1)
                for (p, v) in releases:
                    try:
                        confDB.setPVActive(p, v, batch)
                        projCounter += 1
                    except:
                        self.log.warning("Ignoring %s %s" % (p, v))
        # Now submitting the batch
        batch.submit()
        self.log.warning("Added %s projects" % projCounter)
Ejemplo n.º 4
0
def create_volume(pname, pversion, size=0):
    log = logging.getLogger()

    projconf = getProject(pname, svn_fallback=True)

    if not size:
        size = projconf.FullSize()

    # get user name
    MYNAME = getuser()

    # project directory, afs group, volume root
    PNAME = projconf.NAME()
    P_DIR = projconf.ReleaseArea()
    group = projconf.AFSLibrarianGroup()

    # set the volume name
    vol_name = projconf.AFSReleaseVolumeName(pversion)

    PPATH = os.path.join(P_DIR, PNAME, PNAME + '_' + pversion)
    if not os.path.exists(PPATH):
        if os.path.exists(os.path.dirname(PPATH)):
            createVolume(PPATH, vol_name, size, MYNAME, group)
        else:
            log.error('The project %s does not exist on %s', PNAME, P_DIR)
            return False
    else:
        log.warning('The version %s of the project %s already exists',
                    pversion, projconf.Name())

    return True
Ejemplo n.º 5
0
 def testAFSReleaseVolumeName(self):
     p = getProject("Integration")
     self.assertEqual(p.AFSVolumeShortName(), "IN")
     self.assertEqual(p.AFSVolumeName(), "INTEG")
     self.assertEqual(p.AFSReleaseVolumeName("v1r0"), "q.lhcb.INTEG_v1r0")
     ver = "v1000r1234"
     self.assertEqual(p.AFSReleaseVolumeName(ver), "q.lhcb.IN_%s" % ver)
     ver = "v1000000000r123456789"
     self.assertRaises(BadVolumeName, p.AFSReleaseVolumeName, ver)
Ejemplo n.º 6
0
 def _sanitizeProjectName(sel, pname):
     ''' Puts back the correct case in display '''
     ret = pname
     try:
         from LbConfiguration.Project import getProject
         p = getProject(pname)
         ret = p.Name()
     except:
         # Ignore errors and return initial name
         pass
     return ret
Ejemplo n.º 7
0
    def findRecentReleases(self, path, nbdays):
        """ Iterate though the install area to find the projects
        newer than nbdays """
        ret = []
        for projdir in os.listdir(path):
            # Checking if this corersponds to an existing project...
            proj = None
            try:
                proj = getProject(projdir)
            except:
                pass

            # If yes, then process it...
            if proj != None:
                newprojs = self.findRecentReleasesForProject(
                    os.path.join(path, projdir), projdir, nbdays)
                ret += newprojs
        return ret
Ejemplo n.º 8
0
    def main(self):
        """  Parse the args, validate the project and start the DIRAC method """
        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:
            # Now calling the bookkeeping
            self.diracInit()
            self.listAppsInUSedSteps()
            exit(0)

            #self.log.error("Not enough arguments")
            #self.parser.print_help()
            #sys.exit(1)
        else:
            projectNameCmd = args[0]
            version = args[1]

        # First validating the project name
        project = getProject(projectNameCmd, True)
        if project == None:
            self.log.error("Could not find project: %s" % projectNameCmd)
            sys.exit(1)
        projectName = project.Name()

        # Now calling the bookkeeping
        self.diracInit()
        isUsed = self.isProjectUsed(projectName, version)
        if isUsed:
            sys.exit(1)
        else:
            sys.exit(0)
Ejemplo n.º 9
0
 def configuration(self):
     if self._conf is None:
         self._conf = getProject(self.name())
     return self._conf
Ejemplo n.º 10
0
 def testBeautyDirac(self):
     p = getProject("BeautyDirac")
     print p
     self.assertEqual("BeautyDirac", p.Name())
Ejemplo n.º 11
0
 def testMooreOnline(self):
     p = getProject("MooreOnline")
     self.assertEqual("MooreOnline", p.Name())