Exemplo n.º 1
0
        under certain conditions;.
    """)

    # Parse command line options
    aOptParser = OptionParser()
    aOptParser.add_option("-d", "--host",      dest="aHttpHost",   default="localhost", help="HTTP Hostname")
    aOptParser.add_option("-p", "--port",      dest="aHttpPort",   default="8000",      help="HTTP Port")
    aOptParser.add_option("-w", "--webroot",   dest="aWebRoot",    default="webroot",   help="Web-Root")
    aOptParser.add_option("-x", "--websocket", dest="aWebSocket",  default="8100",      help="Web-Socket Port")
    
    (aOptions, aArgs) = aOptParser.parse_args() 
    xPath = os.path.join(aOptions.aWebRoot, 'public')
    
    aBlackBoard           = TBlackBoard()
    aBlackBoard.mDocRoot  = xPath
    aBlackBoard.mRootPath = xPath
    
    if os.path.isdir(xPath):
        os.chdir(xPath)
    else:
        print('webroot not found: {}'.format(xPath))
        os._exit(0)
        
    aHttpd  = TWebServer((aOptions.aHttpHost, int(aOptions.aHttpPort)), THttpHandler, aOptions.aWebSocket)
           
    # Start the HTTP server
    print("serving {0} at port {1} ...".format(aOptions.aHttpHost, aOptions.aHttpPort))    
    aHttpd.serve_forever()
    print('shutdown')

    
Exemplo n.º 2
0
    def get_dictionary(self):
        return dict()

# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
def globalfnct():
    try:
        print(xList['test'])
    except Exception as xEx:
        xTracer.writeException(1, {"return":{"code":600, "value":"error"}})
        # raise
    
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
if __name__ == '__main__':
    xList   = {}
    xBlackboard = TBlackBoard()
    xBlackboard.mRootPath = os.path.join('/', 'temp')
    xTracer = TTracer()
    
    for i in range(5):
        globalfnct()

    xSessions = xTracer.get_selected_sessions(convert_time=True)
    xSessions.printTable()
    
    xTraces   = xTracer.get_selected_traces(1)
    xTraces.printTable()
    
    pass