コード例 #1
0
ファイル: client_conf.py プロジェクト: abhirathb/copernicus
 def __init__(self, userSpecifiedPath=None):
     """
     Can_create allows for the initialization of an empty configuration file
     """
     if self.exists():
         return
             
     # call parent constructor with right file name.
     try:
         Conf.__init__(self, name="clientconfig.cfg",
             userSpecifiedPath=userSpecifiedPath)
         self.lock = threading.RLock()
         self.initDefaults()
         self._tryRead()
         self._loadDefaultServer();
     except NoConfError as e:
         self._initClientConf()
コード例 #2
0
    def __init__(self,
                 userSpecifiedPath=None,
                 create=False,
                 fqdn=socket.getfqdn()):
        # check whether the object is already initialized
        if not create:
            if self.exists():
                return
                # call parent constructor with right file name.
            Conf.__init__(self,
                          name='client.cnx',
                          userSpecifiedPath=userSpecifiedPath)
        if create:
            # create an empty conf without any values.
            self.conf = dict()

        self.client_host = fqdn
        self.server_secure_port = Conf.getDefaultServerSecurePort()
        self.client_secure_port = Conf.getDefaultClientSecurePort()
        self.privateKey = ''
        self.publicKey = ''
        self.cert = ''
        self.CAcert = ''
        self.initDefaults()

        # TODO: make it a regular Lock() - for now this might reduce the
        # chances of a deadlock
        self.lock = threading.RLock()

        #worker specific
        dn = os.path.dirname(sys.argv[0])
        self.execBasedir = ''
        if dn != "":
            self.execBasedir = os.path.abspath(dn)

        self._add('exec_base_dir',
                  self.execBasedir,
                  'executable base directory',
                  writable=False)

        self.tempfiles = dict()
        #if conffile:
        self._tryRead()
        '''
        the private key, cert and
        ca cert need to be provided as filepaths to the ssl connection object
        So we create tempfiles for them here
        '''
        privKeyTempFile = tempfile.NamedTemporaryFile(delete=False)
        privKeyTempFile.write(self.get('private_key'))
        privKeyTempFile.seek(0)
        self.tempfiles['private_key'] = privKeyTempFile
        privKeyTempFile.close()

        certTempFile = tempfile.NamedTemporaryFile(delete=False)
        certTempFile.write(self.get('cert'))
        certTempFile.seek(0)
        self.tempfiles['cert'] = certTempFile
        certTempFile.close()

        caCertTempFile = tempfile.NamedTemporaryFile(delete=False)
        caCertTempFile.write(self.get('ca_cert'))
        caCertTempFile.seek(0)
        self.tempfiles['ca_cert'] = caCertTempFile
        caCertTempFile.close()
コード例 #3
0
    def __init__(self, userSpecifiedPath=None, create=False,
                 fqdn=socket.getfqdn()):
        # check whether the object is already initialized
        if not create:
            if self.exists():
                return
                # call parent constructor with right file name.
            Conf.__init__(self, name='client.cnx',
                userSpecifiedPath=userSpecifiedPath)
        if create:
            # create an empty conf without any values.
            self.conf = dict()

        self.client_host = fqdn
        self.server_secure_port = Conf.getDefaultServerSecurePort()
        self.client_secure_port = Conf.getDefaultClientSecurePort()
        self.privateKey = ''
        self.publicKey = ''
        self.cert = ''
        self.CAcert = ''
        self.initDefaults()


        # TODO: make it a regular Lock() - for now this might reduce the 
        # chances of a deadlock
        self.lock = threading.RLock()


        #worker specific
        dn = os.path.dirname(sys.argv[0])
        self.execBasedir = ''
        if dn != "":
            self.execBasedir = os.path.abspath(dn)

        self._add('exec_base_dir', self.execBasedir,
            'executable base directory', writable=False)

        self.tempfiles = dict()
        #if conffile:
        self._tryRead()
        '''
        the private key, cert and
        ca cert need to be provided as filepaths to the ssl connection object
        So we create tempfiles for them here
        '''
        privKeyTempFile = tempfile.NamedTemporaryFile(delete=False)
        privKeyTempFile.write(self.get('private_key'))
        privKeyTempFile.seek(0)
        self.tempfiles['private_key'] = privKeyTempFile
        privKeyTempFile.close()

        certTempFile = tempfile.NamedTemporaryFile(delete=False)
        certTempFile.write(self.get('cert'))
        certTempFile.seek(0)
        self.tempfiles['cert'] = certTempFile
        certTempFile.close()

        caCertTempFile = tempfile.NamedTemporaryFile(delete=False)
        caCertTempFile.write(self.get('ca_cert'))
        caCertTempFile.seek(0)
        self.tempfiles['ca_cert'] = caCertTempFile
        caCertTempFile.close()