예제 #1
0
 def __init__(self, df, logger = None):
     self.df = df
     self.logger = logger
     self.loadData(WiseMLServer.raw, WiseMLServer.human, WiseMLServer.wiseml, WiseMLServer.intervals)
     log(logger, logging.INFO, 'Registering sigusr1 signal to update.')
     cherrypy.engine.signal_handler.handlers['SIGUSR1'] = self.update
     log(logger, logging.INFO, 'Starting the server.')
예제 #2
0
 def update(self):
     log(self.logger, logging.INFO, 'Received signal SIGUSR1, updating.')
     log(self.logger, logging.INFO, 'Setting the maintenance pages.')
     WiseMLServer.raw.inMaintenance = True
     WiseMLServer.human.inMaintenance = True
     WiseMLServer.wiseml.inMaintenance = True
     WiseMLServer.intervals.inMaintenance = True
     log(self.logger, logging.INFO, 'Fetching data from the net.')
     self.df.fetchNetData(weekOrYear = False)
     self.df.serialize()
     self.loadData(WiseMLServer.raw, WiseMLServer.human, WiseMLServer.wiseml, WiseMLServer.intervals)
     log(self.logger, logging.INFO, 'Restoring functional pages.')
     WiseMLServer.raw.inMaintenance = False
     WiseMLServer.human.inMaintenance = False
     WiseMLServer.wiseml.inMaintenance = False
     WiseMLServer.intervals.inMaintenance = False
     log(self.logger, logging.INFO, 'Update process finished.')
예제 #3
0
def main():
    usage = 'usage: extractor.py [options] username password'
    aparser = OptionParser(usage, version="visor 0.9.6")
    aparser.add_option('-n', '--net', action='store_true', default=False, dest='net', help='Fetches the data from the net.')
    aparser.add_option('-s', '--serialize', action='store_true', default=False, dest='serialize', help='Serializes the net fetched data. Doesn\'t start the web server.')
    aparser.add_option('-f', '--serialize_from', default='extractor_data.o', dest='fromFile', help='Defines the name of file where the serialized data will be recovered from.')
    aparser.add_option('-t', '--serialize_to', default='extractor_data.o', dest='toFile', help='Defines the name of file where the data will be serialized to.')
    aparser.add_option('-p', '--port', default='8080', dest='port', help='Defines the port in which to start up the server.')

    (options, args) = aparser.parse_args()
    if len(args) != 2:
        aparser.error('Incorrect usage')
        sys.exit(0)

    logger = logging.getLogger('wiseserver')
    logger.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
    console = logging.StreamHandler()
    console.setLevel(logging.DEBUG)
    console.setFormatter(formatter)
    logger.addHandler(console)

    df = dataFetcher(args[0], args[1], serializedFile = options.toFile, logger = logger)
    if options.net:
        log(logger, logging.INFO, 'Fetching data from the net.')
        df.fetchNetData()
    else:
        log(logger, logging.INFO, 'Fetching data from a serialized file.')
        df.fetchSerialized(options.fromFile)
    if options.serialize:
        df.serialize(options.toFile)
    else:
        cherrypy.log.access_log.addHandler(console)
        cherrypy.log.error_log.addHandler(console)
        cherrypy.log.screen = False
        cherrypy.config.update({'server.socket_port':int(options.port), 'server.socket_host': '0.0.0.0', })
        conf = {'/favicon.ico':{'tools.staticfile.on': True, 'tools.staticfile.filename': os.path.join(os.getcwd(), 'favicon.ico')}}
        cherrypy.quickstart(WiseMLServer(df, logger), '/', conf)
예제 #4
0
 def loadData(self, raw, human, wiseml, intervals):
     log(self.logger, logging.INFO, 'Retrieving the data.')
     self.data = self.df.data()
     log(self.logger, logging.INFO, 'Converting the data to experiment and traces.')
     self.trRed = reduce(traceProcess, self.data)
     log(self.logger, logging.INFO, 'Passing the experiment and traces to the webapps.')
     raw.setRawObject(self.data)
     human.setRawObject(self.trRed)
     wiseml.setRawObject(self.trRed)
     intervals.setRawObject(self.trRed)