예제 #1
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)
예제 #2
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)
예제 #3
0
 def __init__( self, suite, options ):
     prep.__init__( self, suite, options )
     # get the suite passphrase
     try:
         self.pphrase = passphrase( self.suite, self.options.owner, self.options.host,
                 verbose=options.verbose ).get( None, self.suitedir )
     except Exception, x:
         if self.options.debug:
             raise
         raise SystemExit(x)
예제 #4
0
    def get_proxy( self ):
        # get passphrase here, not in __init__, because it is not needed
        # on remote task hosts if 'ssh messaging = True' (otherwise, if
        # it is needed, we will end up in this method).

        self.pphrase = passphrase( self.suite, self.owner, self.host ).get( None, None )

        import cylc_pyro_client
        return cylc_pyro_client.client( self.suite, self.pphrase,
                self.owner, self.host, self.try_timeout,
                self.port ).get_proxy( self.task_id )
예제 #5
0
 def get_proxy( self ):
     # get passphrase here, not in __init__, because it is not needed
     # on remote task hosts if 'ssh messaging = True' (otherwise, if
     # it is needed, we will end up in this method). 
     self.pphrase = passphrase( self.suite, self.owner, self.host,
             verbose=self.verbose ).get( None, None )
     # this raises an exception on failure to connect:
     import cylc_pyro_client
     return cylc_pyro_client.client( self.suite, self.pphrase,
             self.owner, self.host, self.pyro_timeout, self.port,
             self.verbose ).get_proxy( self.task_id )
예제 #6
0
 def __init__(self, suite, options):
     prep.__init__(self, suite, options)
     # get the suite passphrase
     try:
         self.pphrase = passphrase(self.suite, self.options.owner,
                                   self.options.host).get(
                                       None, self.suitedir)
     except Exception, x:
         if cylc.flags.debug:
             raise
         raise SystemExit(x)
예제 #7
0
    def get_proxy(self):
        # get passphrase here, not in __init__, because it is not needed
        # on remote task hosts if 'ssh messaging = True' (otherwise, if
        # it is needed, we will end up in this method).

        self.pphrase = passphrase(self.suite, self.owner,
                                  self.host).get(None, None)

        import cylc_pyro_client
        return cylc_pyro_client.client(self.suite, self.pphrase, self.owner,
                                       self.host, self.try_timeout,
                                       self.port).get_proxy(self.task_id)
예제 #8
0
파일: port_scan.py 프로젝트: kaday/cylc
def load_passphrases(db):
    """Load all of the user's passphrases (back-compat for <= 6.4.1)."""
    global passphrases
    if passphrases:
        return passphrases

    # Find passphrases in all registered suite directories.
    reg = localdb(db)
    reg_suites = reg.get_list()
    for item in reg_suites:
        rg = item[0]
        di = item[1]
        try:
            p = passphrase(rg, user, get_hostname()).get(suitedir=di)
        except Exception, x:
            # Suite has no passphrase.
            if cylc.flags.debug:
                print >> sys.stderr, x
        else:
            passphrases.append(p)
예제 #9
0
파일: port_scan.py 프로젝트: aosprey/cylc
def load_passphrases(db):
    """Load all of the user's passphrases (back-compat for <= 6.4.1)."""
    global passphrases
    if passphrases:
        return passphrases

    # Find passphrases in all registered suite directories.
    reg = localdb(db)
    reg_suites = reg.get_list()
    for item in reg_suites:
        rg = item[0]
        di = item[1]
        try:
            p = passphrase(rg, user, get_hostname()).get(suitedir=di)
        except Exception, x:
            # Suite has no passphrase.
            if cylc.flags.debug:
                print >> sys.stderr, x
        else:
            passphrases.append(p)
예제 #10
0
        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"

        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 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('=')
예제 #11
0
        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"

        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 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('=')