コード例 #1
0
 def get_SkyRtcServerConfig(cls):
     initializationConfigParser = InitializationConfigParser(
         "ServerConfig.ini")
     databaseConnectConfig = initializationConfigParser.GetAllNodeItems(
         "SkyRtcWebsocketServer")
     config_path = databaseConnectConfig.get("config_path")
     IoTSensorWebLauncher.skyRTC_config = json.load(open(config_path, 'r'))
コード例 #2
0
 def connect_mongodb(cls):
     initializationConfigParser = InitializationConfigParser(
         "ServerConfig.ini")
     databaseConnectConfig = initializationConfigParser.GetAllNodeItems(
         "DataBase")
     databaseConnectConfig["port"] = int(databaseConnectConfig.get("port"))
     IoTSensorWebLauncher.mongo_read_conn = SensorMongoORM(
         **databaseConnectConfig)
コード例 #3
0
def sensor_recv_TCPserver_run():
    initializationConfigParser = InitializationConfigParser("ServerConfig.ini")
    TcpListingConfig = initializationConfigParser.GetAllNodeItems(
        "TcpServerListeningSocket")
    TcpListingConfig["listening_port"] = int(
        TcpListingConfig.get("listening_port"))
    TcpAddress = (TcpListingConfig.get("tcpserver_host"),
                  TcpListingConfig.get("listening_port"))
    logging.info(TcpAddress)
    server = ThreadingTCPServer(TcpAddress, SensorRecvTCPServerHandler)
    logging.info('request_tcpserver_thread start')
    serve_forever_thread = threading.Thread(target=server.serve_forever)
    serve_forever_thread.start()
    logging.info('request_tcpserver_thread running')
コード例 #4
0
 def __init__(self, *args, **kwargs):
     if isinstance(SensorRecvTCPServerHandler.mongo_connection,
                   SensorMongoORM) is not True:
         initializationConfigParser = InitializationConfigParser(
             "ServerConfig.ini")
         databaseConnectConfig = initializationConfigParser.GetAllNodeItems(
             "DataBase")
         databaseConnectConfig["port"] = int(
             databaseConnectConfig.get("port"))
         SensorRecvTCPServerHandler.mongo_connection = SensorMongoORM(
             **databaseConnectConfig)
         logging.info(SensorRecvTCPServerHandler.mongo_connection)
     self.terminal_owner = None
     self.terminal_address = None
     StreamRequestHandler.__init__(self, *args, **kwargs)
コード例 #5
0
def initialization_read_save_test():
    logging.warning("Test initialization config read and save ...")
    config_sample_path = "ConfigFileInfoParser/UnitTest.ini"
    ini_Parser = InitializationConfigParser(config_sample_path)
    check_data = str(random.random())
    ini_Parser.SetOneKeyValue("UnitReadSaveTest", "save_test", check_data)
    ini_Parser = InitializationConfigParser(config_sample_path)
    node_UnitReadSaveTest = ini_Parser.GetAllNodeItems("UnitReadSaveTest")
    read_data = node_UnitReadSaveTest.get("save_test")
    assert str(read_data) == check_data
    logging.warning("Test initialization config  read and save method OK.")
def save_baidu_token_config(path, access_token):
    ini_Parser = InitializationConfigParser(path)
    ini_Parser.SetOneKeyValue("ClientCredentials", "access_token",
                              access_token)
def get_baidu_token_config(path):
    ini_Parser = InitializationConfigParser(path)
    Client_Credentials = ini_Parser.GetAllNodeItems("ClientCredentials")
    access_token = Client_Credentials.get("access_token")
    return access_token
def get_baidu_api_key_config(path):
    ini_Parser = InitializationConfigParser(path)
    Client_Credentials = ini_Parser.GetAllNodeItems("ClientCredentials")
    api_key = Client_Credentials.get("api_key")
    secret_key = Client_Credentials.get("secret_key")
    return api_key, secret_key