def handle_timer(message, nm): print "\n" + mcolors.OKGREEN + "INFO: %s" % message, mcolors.ENDC if nm.switched: nm.switched = False else: nm.switched = True message = "Link Failure Simulation Raised at: %s" % get_time_now() message2 = "0-0-%s" % get_time_now() flow_flush(nm) ServiceThread.start_in_new_thread(network_measurer.logger_thread, message) return
def handle_timer(message, nm): print "\n" + mcolors.OKGREEN + "INFO: %s" % message, mcolors.ENDC if nm.switched == True: nm.switched = False message = "*** Timer Event switch set to False - %s ***" % str( datetime.datetime.now()) else: nm.switched = True message = "*** Timer Event switch set to True - %s ***" % str( datetime.datetime.now()) ServiceThread.start_in_new_thread(network_measurer.logger_thread, message) flow_flush() return
def logger(message): ServiceThread.start_in_new_thread(logger_thread, message)
def logger_detail(self, message): detail_log = "./log_measurer_detail.txt" ServiceThread.start_in_new_thread(network_measurer.logger_thread, [message, detail_log])
def logger(self, message): ServiceThread.start_in_new_thread(network_measurer.logger_thread, message)
def logger(self, message): #XXX SOLVED! - We need a lot of accuracy on our measurements, I think we should start the method in a new Thread. #XXX look at the service_thread.py on this directory #XXX In example we could decouple logger method in another static class (Logger) and thencall ServiceThread.star_in_new_thread(Logger.log_measurement, message) ServiceThread.start_in_new_thread(network_measurer.logger_thread, message)
import binascii import os import select import socket import SocketServer import StringIO import time import threading import datetime from service_thread import ServiceThread """ def get_time_now(): return str(datetime.datetime.now().strftime('%M:%S.%f')[:-3]) message = "EVENT at: %s" % get_time_now() ServiceThread.start_in_new_thread(network_measurer.logger_thread, message) def logger(self, message): ServiceThread.start_in_new_thread(network_measurer.logger_thread, message) @staticmethod def logger_thread(message, log_file="./time_log_3v2.txt"): if os.path.exists(log_file): l = open(log_file, 'a') l.write(message+"\n") else: l = open(log_file, 'wb') l.write(message+"\n") l.close()
def a_service(): string = "Starting A-server" ServiceThread.start_in_new_thread(a_server, string) return
def handle_timer(): string = "TIMER START - 30" ServiceThread.start_in_new_thread(timer, string) return status.up