コード例 #1
0
ファイル: proxy-unittest.py プロジェクト: tkjelsrud/operator
    def test_exec(self):
        cfg = Config()
        cfg.readCfg("unittest_config_med.xml")

        self.assertEqual(cfg.get("port"), "8080")
        self.assertEqual(len(cfg.data["routing"]), 3)
        self.assertEqual(len(cfg.data["exec"]), 7)

        self.assertEqual(cfg.getEndpoint("/asd"), ["testasd.no", "/pathasd", True])
コード例 #2
0
ファイル: proxy-unittest.py プロジェクト: tkjelsrud/operator
    def test_read(self):
        cfg = Config()
        cfg.readCfg("unittest_config_small.xml")

        self.assertEqual(cfg.get("port"), "8080")
        self.assertEqual(len(cfg.data["routing"]), 2)
コード例 #3
0
ファイル: proxy.py プロジェクト: tkjelsrud/operator
            print("Error when posting" + str(sys.exc_info()[0]))
            raise

    def toFile(self, fname, data):
        f = open(fname, 'rw+')
        text = f.read()
        f.seek(0)
        f.write(data)
        f.truncate()
        f.close()

CONFIG = 0

if __name__ == "__main__":
    CONFIG = Config()
    CONFIG.readCfg(CFG)

    sys.tracebacklimit=1

    #SocketServer.ThreadingTCPServer.allow_reuse_address = True
    #httpd = SocketServer.TCPServer(("", int(CONFIG.get('port'))), Handler)
    
    # NOTE, need to support http.server in Python>3
    
    httpd = SocketServer.ThreadingTCPServer((CONFIG.get('host', 'localhost'), int(CONFIG.get('port'))), Handler, False) # Do not automatically bind
    httpd.allow_reuse_address = True # Prevent 'cannot bind to address' errors on restart
    httpd.server_bind()     # Manually bind, to support allow_reuse_address
    httpd.server_activate() # (see above comment)
    
    #SO_REUSEADDR
    if(len(sys.argv) > 1):