Ejemplo n.º 1
0
    def __init__(self, conf=None):
        '''
        Initializes daemon by starting and configuring a server.

        :param conf: A path to a daemon configuration file
        :type conf: string
        '''
        if conf is not None:
            if os.path.isfile(conf):
                config.update('daemon', conf)
            else:
                log.warning("Configuration file %s does not exist."
                            " Skipped" % conf)
        port = config.getInt('daemon', 'connection', 'port')
        ip = config.get('daemon', 'connection', 'address')
        if ip is None:
            log.warning("No attribute IP in daemon configuration file. "
                        "Using default value %s" % DEFAULT_IP)
            config.set('daemon', 'connection', 'address', DEFAULT_IP)
            ip = DEFAULT_IP
        if port is None:
            log.warning("No attribute port in daemon configuration file. "
                        "Using default value %d" % DEFAULT_PORT)
            config.set('daemon', 'connection', 'port', DEFAULT_PORT)
            port = DEFAULT_PORT
        server.Server.__init__(self, (ip, port))
        info = protocol.create(protocol.MSG_TYPE_RESPONSE,
                               protocol.MSG_TARGET_SYSTEM,
                               protocol.MSG_NAME_INFO,
                               version=config.VERSION,
                               locale=(locale.getdefaultlocale()[0] or ''),
                               extensions=protocol.getExtensions(),
                               status=True)
        self._infoData = info.marshal()
Ejemplo n.º 2
0
 def _setUpTestFiles(self):
     try:
         os.mkdir(os.path.dirname(self._files[1]))
     except OSError:
         pass
     test_file = open(self._files[1], 'w')
     configWriter = ConfigParser.ConfigParser()
     configWriter.add_section('Test_2')
     configWriter.set('Test_2', 'test2_1', '2')
     configWriter.set('Test_2', 'test2_2', '22')
     configWriter.set('Test_2', 'test2_3', 'True')
     configWriter.add_section('Test_3')
     configWriter.set('Test_3', 'test3_1', '3')
     configWriter.set('Test_3', 'test3_2', '33')
     configWriter.add_section('Test_4')
     configWriter.set('Test_4', 'test4_1', '4')
     configWriter.set('Test_4', 'test4_2', '44')
     configWriter.set('Test_4', 'test4_3', 'True')
     configWriter.set('Test_4', 'test4_4', 'Test')
     configWriter.write(test_file)
     test_file.close()
     test_file = open(self._files[1], 'r')
     config.update(self._filenames[1], test_file)
     test_file.close()
Ejemplo n.º 3
0
 def _setUpTestFiles(self):
     try:
         os.mkdir(os.path.dirname(self._files[1]))
     except OSError:
         pass
     test_file = open(self._files[1], 'w')
     configWriter = ConfigParser.ConfigParser()
     configWriter.add_section('Test_2')
     configWriter.set('Test_2', 'test2_1', '2')
     configWriter.set('Test_2', 'test2_2', '22')
     configWriter.set('Test_2', 'test2_3', 'True')
     configWriter.add_section('Test_3')
     configWriter.set('Test_3', 'test3_1', '3')
     configWriter.set('Test_3', 'test3_2', '33')
     configWriter.add_section('Test_4')
     configWriter.set('Test_4', 'test4_1', '4')
     configWriter.set('Test_4', 'test4_2', '44')
     configWriter.set('Test_4', 'test4_3', 'True')
     configWriter.set('Test_4', 'test4_4', 'Test')
     configWriter.write(test_file)
     test_file.close()
     test_file = open(self._files[1],'r')
     config.update(self._filenames[1], test_file)
     test_file.close()