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
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
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)
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"