Ejemplo n.º 1
0
 def reregister( self, srce, targ ):
     srce = RegPath(srce).get()
     targ = RegPath(targ).get()
     for key in self.items:
         if key == targ:
             # There is already a suite of the same name as targ.
             raise SuiteTakenError, targ
         elif key.startswith(targ + RegPath.delimiter):
             # There is already a group of the same name as targ.
             raise IsAGroupError, targ
         elif targ.startswith(key + RegPath.delimiter ):
             # targ starts with, to some level, an existing suite name
             raise NotAGroupError, key
     found = False
     for key in self.items.keys():
         if key.startswith(srce):
             dir, title = self.items[key]
             newkey = re.sub( '^'+srce, targ, key )
             #if self.verbose:
             print 'REREGISTER', key, 'to', newkey
             del self.items[key]
             self.items[newkey] = dir, title
             found = True
     if not found:
         raise SuiteOrGroupNotFoundError, srce
Ejemplo n.º 2
0
    def register( self, suite, dir ):

        suite = RegPath(suite).get()
        for key in self.items:
            if key == suite:
                # there is already a suite of the same name
                raise SuiteTakenError, suite
            elif key.startswith(suite + RegPath.delimiter ):
                # there is already a group of the same name
                raise IsAGroupError, suite
            elif suite.startswith(key + RegPath.delimiter ):
                # suite starts with, to some level, an existing suite name
                raise NotAGroupError, key

        if dir.startswith( '->' ):
            # (alias: dir points to target suite reg)
            # parse the suite for the title
            try:
                title = self.get_suite_title( dir[2:] )
            # parse the suite for the title
            except Exception, x:
                print >> sys.stderr, 'WARNING: an error occurred parsing the suite definition:\n  ', x
                print >> sys.stderr, "Registering the suite with temporary title 'SUITE PARSE ERROR'."
                print >> sys.stderr, "You can update the title later with 'cylc db refresh'.\n"
                title = "SUITE PARSE ERROR"
            # use the lowest level alias
            target = self.unalias( dir[2:] )
            dir = '->' + target
Ejemplo n.º 3
0
    def register( self, name, dir ):
        name = RegPath(name).get()
        for suite in self.list_all_suites():
            if name == suite:
                raise RegistrationError, "ERROR: " + name + " is already registered."
            elif suite.startswith( name + RegPath.delimiter ):
                raise RegistrationError, "ERROR: " + name + " is a registered group."
            elif name.startswith( suite + RegPath.delimiter ):
                # suite starts with, to some level, an existing suite name
                raise RegistrationError, "ERROR: " + suite + " is a registered suite."
        dir = dir.rstrip( '/' )  # strip trailing '/'
        dir = re.sub( '^\./', '', dir ) # strip leading './'
        if not dir.startswith( '/' ):
            # On AIX on GPFS os.path.abspath(dir) returns the path with
            # full 'fileset' prefix. Manual use of $PWD to absolutize a
            # relative path gives a cleaner result.
            dir = os.path.join( os.environ['PWD'], dir )
        title = self.get_suite_title(name, path=dir)
        title = title.split('\n')[0] # use the first of multiple lines
        print 'REGISTER', name + ':', dir
        with open( os.path.join( self.dbpath, name ), 'w' ) as file:
            file.write( 'path=' + dir + '\n' )
            file.write( 'title=' + title + '\n' )

        # create a new passphrase for the suite if necessary
        passphrase(name,user,get_hostname()).generate(dir)
Ejemplo n.º 4
0
 def register( self, name, dir ):
     name = RegPath(name).get()
     for suite in self.list_all_suites():
         if name == suite:
             raise RegistrationError, "ERROR: " + name + " is already registered."
         elif suite.startswith( name + RegPath.delimiter ):
             raise RegistrationError, "ERROR: " + name + " is a registered group."
         elif name.startswith( suite + RegPath.delimiter ):
             # suite starts with, to some level, an existing suite name
             raise RegistrationError, "ERROR: " + suite + " is a registered suite."
     dir = dir.rstrip( '/' )  # strip trailing '/'
     dir = re.sub( '^\./', '', dir ) # strip leading './'
     if not dir.startswith( '/' ):
         # On AIX on GPFS os.path.abspath(dir) returns the path with
         # full 'fileset' prefix. Manual use of $PWD to absolutize a
         # relative path gives a cleaner result.
         dir = os.path.join( os.environ['PWD'], dir )
     try:
         title = self.get_suite_title( name, path=dir )
     except Exception, x:
         print >> sys.stderr, 'WARNING: an error occurred parsing the suite definition:\n  ', x
         print >> sys.stderr, "Registering the suite with temporary title 'SUITE PARSE ERROR'."
         print >> sys.stderr, "You can update the title later with 'cylc db refresh'.\n"
         title = "SUITE PARSE ERROR"
Ejemplo n.º 5
0
 def get_suite_data( self, suite ): 
     suite = RegPath(suite).get()
     fpath = os.path.join( self.dbpath, suite )
     if not os.path.isfile( fpath ):
         raise RegistrationError, "ERROR: Suite not found " + suite
     data = {}
     with open( fpath, 'r' ) as file:
         lines = file.readlines()
     count = 0
     for line in lines:
         count += 1
         line = line.rstrip()
         try:
             key,val = line.split('=')
         except ValueError:
             print >> sys.stderr, 'ERROR: failed to parse line ' + str(count) + ' from ' + fpath + ':'
             print >> sys.stderr, '  ', line
             continue
         data[key] = val
     if 'title' not in data or 'path' not in data:
         raise RegistrationError, 'ERROR, ' + suite + ' suite registration corrupted?: ' + fpath
     return data
Ejemplo n.º 6
0
 def reregister( self, srce, targ ):
     targ = RegPath(targ).get()
     found = False
     for suite in self.list_all_suites():
         if suite == srce:
             # single suite
             newsuite = targ
             data = self.get_suite_data( suite )
             dir, title = data['path'], data['title']
             self.register( targ, data['path'] )
             self.unregister( suite )
             found = True
         elif suite.startswith( srce + RegPath.delimiter ):
             # group of suites
             data = self.get_suite_data( suite )
             dir, title = data['path'], data['title']
             newsuite = re.sub( '^' + srce, targ, suite )
             self.register( newsuite, data['path'] )
             self.unregister( suite )
             found = True
     if not found:
         raise RegistrationError, "ERROR, suite or group not found: " + srce