def __init__(self, wrapper=None, dirName=None, methodObj=None, emptyDir=True): object.__init__(self) self.wrapper = wrapper self.logger = Logger.Logger(dirName=dirName, emptyDir=emptyDir) self.methodList = [] self.methodObj = methodObj self.antiids = AntiIDS.AntiIDS(wrapper) self.IDSEvasion = self.auto = self.simultaneous = False self.IDSEvasionOpt = self.IDSEvasionURI = \ self.bauser = self.bapass = \ self.wsseuser = self.wssepass = \ self.keyfile = self.certfile = \ self.soapAction = self.proxy = \ self.proxyport = self.dictType = None self.version = 0 self.alterhost = None self.saveFileHandle = "" self.xmlp = XMLProcessor.XMLProcessor() self.xdos = XDoS.XDoS(fp=self.logger.getLogPath()) self.xdosObjExists = False self.baseLine = 0 self.pdfw = PDFWriter.PDFWriter(path=self.logger.getLogPath()) self.fuzzList = [] # to be used during XDoS process self.pollObjects = []
def __init__(self, args): super(trainer, self).__init__() # parse option self.args = args # train data print('loading training data...') self.train_dataloader, self.valid_dataloader = get_dataloader( self.args) # model self.model = DRGANModel(self.args) self.model.setup() # visualizer self.train_logger = Logger(self.args.num_epochs, len(self.train_dataloader)) self.valid_logger = Logger(self.args.num_epochs, len(self.valid_dataloader))
def main(): # Config class config = Config.Config('config/config.yaml') # Logger class logger = Logger.Logger(config.get('log')) # Start the logger logger.run() # Network class network = Network.Network({ 'ip_file': config.get('ip.file') }, logger) # GoDaddy class godaddy = GoDaddy.GoDaddy({ 'username': config.get('godaddy.username'), 'password': config.get('godaddy.password'), 'hostname': config.get('godaddy.hostname'), 'type': config.get('godaddy.type'), }, logger, network) # Get the public IP ip = network.getPublicIP() if network.checkIpCache(ip) != 1: godaddy.updateDNS(ip) else: print("Everything is all good, mate")
def __init__(self, ip, port): self._send_lock = threading.Lock() self._ip = ip self._port = port self._url = "tcp://%s:%s" % (ip, port) self._logger = Logger("Remote %s" % self._url) self._z_ctx = None self._z_sck = None
def __init__(self): self.tonevalue = 0 self.port = None self.sensorlist = [] self.logger = Logger.Logger(self) self.btdevice = self.find_bluetooth_device() if self.btdevice == None: self.logger.log("TODO: %s not found" % self.bt_devices['usb']) else: self.logger.log("btdevice: %s " % self.btdevice)
def __init__(self): self.cnf = cnf.get("core") self.logger = Logger("Core") self.logger.debug("Loading services") self._services = [] for service_name in self.cnf.get("services"): service = Loader.by_id('services', service_name) self._services.append(service)
def __init__(self, thread, id, root=cnf): super().__init__(id, root) self._data = Loader.by_id('storage', self.lcnf.get("storage")) self._stop_timeout = 10 self._running = False self._thread_to_run = thread self._run_thread = None self._logger = Logger('Service') self._init()
def main(): Logger().log('enter main function') actions = Config.actions for actionName in actions: ActionsManager().regiest(actionName, actions[actionName]) ActionsManager().run()
from lib.daemonize import Daemonize from lib import CMD from lib import Logger import os PID_FILE = os.path.join(os.getcwd(), 'process.pid') def main(): Logger().log('enter main function') actions = Config.actions for actionName in actions: ActionsManager().regiest(actionName, actions[actionName]) ActionsManager().run() if __name__ == '__main__': daemon = Daemonize(app='ProcessDaemon', pid=PID_FILE, action=main) if CMD == 'start': Logger().log('start daemon') daemon.start() elif CMD == 'stop': Logger().log('stop daemon') daemon.exit() else: print """ProcessDaemon: useage: python entry.py -c start -r production -c --command start stop : start or stop process daemon -r --runmode develop testing production : set run mode """
def __init__(self, id, root): super().__init__(id, root) self._size = self.lcnf.get("size", 0) self._logger = Logger("Storage") self._logger.add_field('vname', self.__class__.__name__)
def __init__(self, id, root): super().__init__(id, root) self._logger = Logger(self.__class__.__name__)
from datetime import datetime import matplotlib.font_manager as fm from indoor_sensor import SHT30 from lib.location import Location from weather_time_render import (weather, get_weather_fettle, get_prior_date, get_week_day) from lib import EPD, Logger from PIL import Image, ImageDraw, ImageFont BASE_DIR = os.path.dirname(os.path.abspath(__file__)) LOG_DIR = os.path.join(BASE_DIR, 'logs') LOG_FILE = os.path.join(LOG_DIR, 'e-Paper.log') if not os.path.isdir(LOG_DIR): os.makedirs(LOG_DIR) logger = Logger(LOG_FILE, level='debug').logger # 获取传感器温度 sht30 = SHT30() pic_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic') lib_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib') if os.path.exists(lib_dir): sys.path.append(lib_dir) now_date = datetime.now() def login(): """
def Run(self): self.logger = Logger() self.initialize_dialog() self.log_info("Running version {}".format(self.version)) self.log_info("Running wxPython version {}".format(self.wx_version)) self.log_info("Logging to directory {}".format(self.logger.path)) self.log_info("Setting icon to {}".format(self.icon_file_name)) if self.local_build: self.initialize_footprint_cache() pcb = pcbnew.GetBoard() self.log_info("Running Speedo Kicad plugin") self.switch_data = SwitchData() # Positions & rotations for the RGB LEDs self.led_bearings = { "L1": (self.switch_data.get_midpoint((0, 8), (1, 8)), 180.0 + 10.0), "L2": (self.switch_data.get_midpoint((0, 10), (1, 10)), 180.0 + 10.0), "L3": (self.switch_data.get_midpoint((0, 12), (1, 12)), 180.0 + 10.0), "L4": (self.switch_data.get_midpoint((3, 12), (4, 12)), 0.0 + 10.0), "L5": (self.switch_data.get_midpoint((3, 10), (4, 10)), 0.0 + 10.0), "L6": (self.switch_data.get_midpoint((3, 8), (4, 8)), 0.0 + 10.0), "L7": (self.switch_data.get_midpoint((3, 5), (4, 5)), 0.0 - 10.0), "L8": (self.switch_data.get_midpoint((3, 3), (4, 3)), 0.0 - 10.0), "L9": (self.switch_data.get_midpoint((3, 1), (4, 1)), 0.0 - 10.0), "L10": (self.switch_data.get_midpoint((0, 1), (1, 1)), 180.0 - 10.0), "L11": (self.switch_data.get_midpoint((0, 3), (1, 3)), 180.0 - 10.0), "L12": (self.switch_data.get_midpoint((0, 5), (1, 5)), 180.0 - 10.0), } # Set switch and diode positions key_count = self.switch_data.get_switch_count() for i in range(0, key_count): key_id = "SW{}".format(str(i + 1)) key = pcb.FindModuleByReference(key_id) if key == None: raise Exception("No key with id {} found".format(key_id)) self.set_key_position(key) diode_id = "D{}".format(str(i + 1)) diode = pcb.FindModuleByReference(diode_id) if diode == None: raise Exception("No diode with id {} found".format(diode_id)) self.set_diode_position(diode) # Set LED and capacitor positions for i in range(0, 12): led_id = "L{}".format(i + 1) led = pcb.FindModuleByReference(led_id) if led == None: raise Exception("No led with id {} found".format(led_id)) self.log_info("Found LED {}".format(led_id)) self.set_led_position(led) capacitor_id = "C{}".format(i + 1) capacitor = pcb.FindModuleByReference(capacitor_id) if capacitor == None: self.log_warn( "No capacitor with id {} found".format(capacitor_id)) self.set_capacitor_position(capacitor) # Elite-C mcu_id = "U1" mcu = pcb.FindModuleByReference(mcu_id) if mcu == None: self.log_warn("No mcu with id {} found".format(mcu_id)) else: self.log_info("Found MCU {}".format(mcu_id)) self.set_mcu_position(mcu) # Remove all existing drawings on the Edge.Cuts line, then add the # desired edge cut segments for d in pcb.GetDrawings(): if d.GetLayerName() == "Edge.Cuts": self.log_info("Found a drawing on Edge.Cuts layer") pcb.Remove(d) self.draw_edge_cuts(pcb) self.setup_text(pcb) self.setup_graphics(pcb)
from lib import Logger from app.Handlers import Touch, SDI # Settings i2c_addr_10 = 0x21 i2c_addr_20 = 0x22 i2c_addr_30 = 0x23 interval = 10 # Initialise and start the logger logger = Logger.Logger(interval) # logger.add_handler('touch', Touch.Handler(10, i2c_addr_10)) # logger.add_handler('touch', Touch.Handler(20, i2c_addr_20)) # logger.add_handler('touch', Touch.Handler(30, i2c_addr_30)) logger.add_handler('touch_sdi', SDI.Handler()) logger.start()
def Run(self): self.logger = Logger() self.initialize_dialog() self.log_info("Running version {}".format(self.version)) self.log_info("Running wxPython version {}".format(self.wx_version)) self.log_info("Logging to directory {}".format(self.logger.path)) if self.local_build: self.initialize_footprint_cache() pcb = pcbnew.GetBoard() # -------------------- TODO -------------------- # z = pcb.Zones() # for i in range(0, len(z)): # outline = z[i].Outline() # # outline.RemoveAllContours() # outline.NewOutline() # outline.Append(pcbnew.VECTOR2I(int(0.0 * POSITION_SCALE), int(0.0 * POSITION_SCALE))) # outline.Append(pcbnew.VECTOR2I(int(10.0 * POSITION_SCALE), int(0.0 * POSITION_SCALE))) # outline.Append(pcbnew.VECTOR2I(int(10.0 * POSITION_SCALE), int(10.0 * POSITION_SCALE))) # outline.Append(pcbnew.VECTOR2I(int(0.0 * POSITION_SCALE), int(10.0 * POSITION_SCALE))) # # z[i].SetOutline(outline) # # return # -------------------- TODO -------------------- self.piece = self.detect_piece(pcb) self.log_info("Running Kicad plugin on Triad piece {}".format( self.piece)) self.switch_data = SwitchData(self.piece) # Set switch and diode positions key_count = 13 if self.piece == TriadPiece.CENTER else 37 for i in range(0, key_count): key_id = "K{}".format(str(i).zfill(2)) # key_id = 'K{}'.format(i) key = pcb.FindModuleByReference(key_id) if key == None: raise Exception("No key with id {} found".format(key_id)) self.set_key_position(key) diode_id = "D{}".format(str(i).zfill(2)) # diode_id = 'D{}'.format(i) diode = pcb.FindModuleByReference(diode_id) if diode == None: raise Exception("No diode with id {} found".format(diode_id)) self.set_diode_position(diode) # Set Pin Header positions pin_header_count = 2 if self.piece == TriadPiece.CENTER else 1 for i in range(0, pin_header_count): pin_header_id = "J{}".format(i + 1) pin_header = pcb.FindModuleByReference(pin_header_id) if pin_header == None: raise Exception( "No pin_header with id {} found".format(pin_header_id)) self.set_pin_header_position(pin_header) # Set LED positions for i in range(0, 4): led_id = "L{}".format(i + 1) led = pcb.FindModuleByReference(led_id) if led == None: raise Exception("No led with id {} found".format(led_id)) self.log_info("Found LED {}".format(led_id)) self.set_led_position(led) # Setup M2 spacer holes for i in range(0, 4): hole_id = "H{}".format(i + 1) hole = pcb.FindModuleByReference(hole_id) if hole == None: self.log_info("No hole {} found, creating it".format(hole_id)) hole = pcbnew.FootprintLoad(COZY_FOOTPRINT_LIBRARY_PATH, "HOLE_M2_SPACER") hole.SetParent(pcb) hole.SetReference(hole_id) pcb.Add(hole) else: self.log_info("Found hole {}".format(hole_id)) self.set_hole_position(hole) # Set positions for the electronics on the center piece if self.piece == TriadPiece.CENTER: mcu_id = "U1" mcu = pcb.FindModuleByReference(mcu_id) if mcu == None: self.log_warn("No mcu with id {} found".format(mcu_id)) else: self.log_info("Found MCU {}".format(mcu_id)) self.set_mcu_position(mcu) # Capacitors for i in range(0, 8): capacitor_id = "C{}".format(i + 1) capacitor = pcb.FindModuleByReference(capacitor_id) if capacitor == None: self.log_warn( "No capacitor with id {} found".format(capacitor_id)) self.set_capacitor_position(capacitor) # Resistors for i in range(0, 6): resistor_id = "R{}".format(i + 1) resistor = pcb.FindModuleByReference(resistor_id) if resistor == None: self.log_warn( "No resistor with id {} found".format(resistor_id)) self.set_resistor_position(resistor) # Crystal crystal_id = "X1" crystal = pcb.FindModuleByReference(crystal_id) if crystal == None: self.log_warn("No crystal with id {} found".format(crystal_id)) self.set_crystal_position(crystal) # Reset switch reset_switch_id = "SW1" reset_switch = pcb.FindModuleByReference(reset_switch_id) if reset_switch == None: self.log_warn( "No reset_switch with id {} found".format(reset_switch_id)) self.set_reset_switch_position(reset_switch) # USB port usb_port_id = "J3" usb_port = pcb.FindModuleByReference(usb_port_id) if usb_port == None: self.log_warn( "No usb_port with id {} found".format(usb_port_id)) self.set_usb_port_position(usb_port) # OLED oled_id = "J4" oled = pcb.FindModuleByReference(oled_id) if oled == None: self.log_warn("No oled with id {} found".format(oled_id)) self.set_oled_position(oled) # Remove all existing drawings on the Edge.Cuts line, then add the # desired edge cut segments for d in pcb.GetDrawings(): if d.GetLayerName() == "Edge.Cuts": self.log_info("Found a drawing on Edge.Cuts layer") pcb.Remove(d) self.draw_edge_cuts(pcb) self.setup_text(pcb) self.setup_graphics(pcb)