def __init__(self): path = os.getcwd() LoggerModule.flush_logs() self.data_logger = LoggerModule.csv_loggers(path) self.field_values = [] self.field_names = ["Name", "Reg. No.", "KANNADA", "ENGLISH", "SANSKRIT", "HINDI", "PHYSICS", "CHEMISTRY", "MATHEMATICS", "BIOLOGY", "ELECTRONICS", "COMPUTER SCIENCE", "HOME SCIENCE", "GEOLOGY"] self.data_logger.debug("Logging Has been Initiated") self.studentData = None
def __init__(self): path = os.getcwd() LoggerModule.flush_logs() self.data_logger = LoggerModule.csv_loggers(path) self.field_values = [] self.field_names = [ "Name", "Reg. No.", "KANNADA", "ENGLISH", "SANSKRIT", "HINDI", "PHYSICS", "CHEMISTRY", "MATHEMATICS", "BIOLOGY", "ELECTRONICS", "COMPUTER SCIENCE", "HOME SCIENCE", "GEOLOGY" ] self.data_logger.debug("Logging Has been Initiated") self.studentData = None
def reading_rfid(): ser = serial.Serial('/dev/ttyAMA0', 9600, timeout=1) ser.open() lcd.message("Kinderbox stopped", "Ready to add new card") try: while 1: rawData = [] decimalData = "" isRead = False buf = ser.read(50) if len(buf) > 0: for d in buf: if d == '\x02': rawData = [] isRead = True elif d == '\x03': isRead = False break else: if isRead: rawData.append(d) if len(rawData) > 0: decimalData = str(tag_to_dec(rawData)) print "RFID Reading = %s" % decimalData add_rfid(str(decimalData)) except Exception, ex: logger = LoggerModule.Logger("Reading RFID") logger.error("%s" % ex)
def init(self, globalConf=None): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__misc = MiscModule.MiscModule() self.__data_push_handler = self.__globalConf.get("EXTERNAL_DATA_PUSH") self.short_retention = "SHORT" self.long_retention = "LONG" # checking class properly implemented if not self.__data_push_handler: self.__logger.printLog( "WARNING", "ReportModule init: no report push mechanism enabled") else: try: self.__data_push_handler.resultPush except AttributeError as e: self.__logger.printLog( "WARNING", "ReportModule init: missing 'resultPush' in class methods for " "external report push (error={})".format(e)) self.__data_push_handler = None else: try: self.__data_push_handler.attachmentPush except AttributeError as e: self.__logger.printLog( "WARNING", "ReportModule init: missing 'attachmentPush' in class methods for " "external report push (error={})".format(e)) self.__data_push_handler = None
class log(object): mjLog = LoggerModule.LoggerModule() consHandlr = None fileHandlr = None rprtHandlr = None @staticmethod def setLogHandlers(): log.consHandlr = log.mjLog.ConsoleLogWriter( confMgr.getConfigMap()['UI_lOG_LEVEL'], "", False) # param1: Log level, param2: Filter, param3: TimeOn? log.fileHandlr = log.mjLog.RotatingLogFileHandler( LOG_FILE, "a", confMgr.getConfigMap()['FILE_LOG_LEVEL'], "", False) # param1: logfile, param2: level, param3: filter log.rprtHandlr = log.mjLog.RotatingLogFileHandler( REPORT_FILE, "a", "debug", "TReport", False) # param1: logfile, param2: level, param3: filter @classmethod def changeConsoleLogLevel(self, newLevel): log.mjLog.HandlerClose(log.consHandlr) log.consHandlr = log.mjLog.ConsoleLogWriter(newLevel, "", False) @classmethod def changeFileLogLevel(self, newLevel): log.mjLog.HandlerClose(log.fileHandlr) log.fileHandlr = log.mjLog.RotatingLogFileHandler( LOG_FILE, "w", newLevel, "", False)
def init(self, globalConf=None): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__device = DeviceModule.DeviceModule() self.__workaround = WorkaroundModule.WorkaroundModule() self.__configuration = ConfigurationModule.ConfigurationModule() self.__misc = MiscModule.MiscModule() self.__osManager = OsManagerModule.OsManagerModule() self.__output = OutputModule.OutputModule() self.__report = ReportModule.ReportModule() self.logsFiles = list() self.__mandatoryLogsFiles = ["history_event"] self.tc_name = "" self.tc_name_number = "" campaign_report_path = self.__globalConf.get("REPORT_PATH") if campaign_report_path and os.path.isdir(campaign_report_path): self.bootota_log_path = os.path.abspath(os.path.join(campaign_report_path, "logs_bootota")) # if directory not created, create it for future use in TC if not os.path.isdir(self.bootota_log_path): os.makedirs(self.bootota_log_path) self.__logger.printLog("WARNING", "LogsModule init: storing BootOta specific data into " "{}".format(self.bootota_log_path)) else: self.__logger.printLog("WARNING", "LogsModule init: invalid or empty report path " "('{}')".format(campaign_report_path)) self.bootota_log_path = "" self.tc_report_path = ""
def run(): try: data = sys.stdin.read() d = json.loads(data) barcodeid = d['barcodeid'] if barcodeid is None: js = json.dumps({"result": "error. barcodeid is None"}) else: item = db.get_item_by_barcodeid(barcodeid) if item is None: js = json.dumps({"result": "error. Album not existed"}) return name = item[2] #Delete database db.delete_item_by_barcodeid(barcodeid) #Delete m3u m3u_file = os.path.join(playlist_path, "%s.m3u" % barcodeid) remove(m3u_file) #Delete datafile music_dir = os.path.join(music_path, name) remove(music_dir) js = json.dumps({"result": "success"}) except Exception, ex: logger = LoggerModule.Logger("Delete item") logger.error("Error when delete item: %s" % ex) js = json.dumps({"result": "error: %s" % ex})
def init(self, globalConf=None): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__relayCard = RelayCardModule.RelayCardModule() self.__device = DeviceModule.DeviceModule() self.__workaround = WorkaroundModule.WorkaroundModule() self.__getEndTime = None self.__misc = MiscModule.MiscModule() self.__osManager = OsManagerModule.OsManagerModule() self.__flashFile = FlashFileModule.FlashFileModule() self.__output = OutputModule.OutputModule() # table to match uefi var with offset in RCSI_table self.__RSCI_dict = dict() self.__RSCI_dict["wake_source"] = 36 self.__RSCI_dict["reset_source"] = 37 self.__RSCI_dict["reset_type"] = 38 self.__RSCI_dict["shutdown_source"] = 39 self.__RSCI_dict["reset_extra_information"] = None # table to match uefi var to name in sysfs self.efi_vars_matching = dict() self.efi_vars_matching["wake_source"] = "WakeSource" self.efi_vars_matching["reset_source"] = "ResetSource" self.efi_vars_matching["reset_type"] = "ResetType" self.efi_vars_matching["shutdown_source"] = "ShutdownSource" self.efi_vars_matching["mode"] = "LoaderEntryLast" self.efi_vars_matching["watchdog"] = "WdtCounter"
def init(self, globalConf=None, externalRelayCard=None): self.globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__output = OutputModule.OutputModule() self.configuration = ConfigurationModule.ConfigurationModule() self.cardConfiguration = self.globalConf.get( "RELAY_CARD_CONFIGURATION", dict()) self.relayConfiguration = self.cardConfiguration.get("relays", dict()) self.__delayBetweenCommands = 1 self.__allow_usb_toggle_event = False self.__usb_connected = "unknown" if externalRelayCard: self.__relay = externalRelayCard else: self.__relay = self.__internalRelayCard() self.__relay.setConfig(self.cardConfiguration) if self.relayConfiguration: self.__relay.setDefaultState() else: self.relayConfiguration["SwitchOnOff"] = -1 self.relayConfiguration["UsbHostPcConnect"] = -1 self.relayConfiguration["VolumeUp"] = -1 self.relayConfiguration["VolumeDown"] = -1 self.relayConfiguration["Dediprog"] = -1 self.relayConfiguration["PowerSupply"] = -1 self.relayConfiguration["J6B2_relay"] = -1 self.SwitchOnOff = self.relayConfiguration.get("SwitchOnOff", -1) self.UsbHostPcConnect = self.relayConfiguration.get( "UsbHostPcConnect", -1) self.VolumeUp = self.relayConfiguration.get("VolumeUp", -1) self.VolumeDown = self.relayConfiguration.get("VolumeDown", -1) self.Dediprog = self.relayConfiguration.get("Dediprog", -1) self.PowerSupply = self.relayConfiguration.get("PowerSupply", -1) self.J6B2_relay = self.relayConfiguration.get("J6B2_relay", -1)
def __init__(self, conf): self.globalConf = conf self.verdict = True self.output = "" self.output_list = [] self.name = "" self.description = "" self.specific = "" self.isWorkaround = False self.skip = False self.backup_name = "" self.defaultParameter = dict() self.logger = LoggerModule.LoggerModule() self.host = HostModule.HostModule() self.relayCard = RelayCardModule.RelayCardModule() self.device = DeviceModule.DeviceModule() self.workaround = WorkaroundModule.WorkaroundModule() self.misc = MiscModule.MiscModule() self.osManager = OsManagerModule.OsManagerModule() self.flashFile = FlashFileModule.FlashFileModule() self.logs = LogsModule.LogsModule() self.efiVar = EfiVarModule.EfiVarModule() self.dediprog = DediprogModule.DediprogModule() self.outputModule = OutputModule.OutputModule() self.configuration = ConfigurationModule.ConfigurationModule() self.bootData = BootDataModule.BootDataModule() self.resetIrq = ResetIrqModule.ResetIrqModule() self.watchdog = WatchdogModule.WatchdogModule() self.download = DownloadModule.DownloadModule() self.campaign = CampaignModule.CampaignModule() self.flash = FlashModule.FlashModule() self.events = EventsModule.EventsModule()
def __init__(self): self.playlist_dir = config.playlist_dir self.sensor = SensorModule.Sensor() self.player = PlayerModule.Player() self.lcd = LCDModule.LCD() self.logger = LoggerModule.Logger() self.db = DBModule.DBUtils()
def init(self, globalConf=None): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__relayCard = RelayCardModule.RelayCardModule() self.__output = OutputModule.OutputModule() self.__misc = MiscModule.MiscModule() self.__configuration = ConfigurationModule.ConfigurationModule()
def init(self, globalConf=None): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__misc = MiscModule.MiscModule() self.__biosFile = None self.__voltage = "1.8V" self.__flashToolCmd = None
def run(): try: rfid_list = db.get_all_rfid() js = json.dumps({"data": rfid_list}) except Exception, ex: logger = LoggerModule.Logger("Get all RFID") logger.error("Get RFID error: %s" % ex) js = json.dumps({"error": "%s" % ex})
def init(self, globalConf): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__output = OutputModule.OutputModule() self.__host = HostModule.HostModule() self.local_files_handler = self.__FilesHandler() self.extra_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "Extras")) self.otaBuild = ""
def __init__(self): print "Init player" self.playlist_dir = config.playlist_dir self.track_count = 0 self.current_track = 1 self.play_status = 0 self.current_artist_title = "" self.current_album = "" self.logger = LoggerModule.Logger("Player module")
def __init__(self): self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__config = None self.__port = None self.__defaultState = None self.__wiringTable = None self.__relays = None self.__delay = 1
def init(self, globalConf): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__output = OutputModule.OutputModule() self.__efiVar = EfiVarModule.EfiVarModule() self.__resetIrq = ResetIrqModule.ResetIrqModule() self.__device = DeviceModule.DeviceModule() self.__osManager = OsManagerModule.OsManagerModule() self.__logs = LogsModule.LogsModule() self.__workaround = WorkaroundModule.WorkaroundModule() self.__configuration = ConfigurationModule.ConfigurationModule() self.__RSCI_table = list()
def init(self, globalConf): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__output = OutputModule.OutputModule() self.__device = DeviceModule.DeviceModule() self.__osManager = OsManagerModule.OsManagerModule() self.__misc = MiscModule.MiscModule() self.__workaround = WorkaroundModule.WorkaroundModule() self.__configuration = ConfigurationModule.ConfigurationModule() self.__logs = LogsModule.LogsModule() self.force_ramdump_removal = False self.wd_handler = self.HistoryEventHandler(self.__globalConf)
def __init__(self, eventLevel, eventId, eventTime, eventType, eventRoot=None): self.level = eventLevel self.id = eventId self.time = eventTime self.etype = eventType self.root = eventRoot self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule()
def __init__(self): self.transaction_table = {} # Hash table for transactions with transaction ID as a key and # Transaction class as the value self.lock_table = {} # Hash table for locks with data item as the key and Lock class as # the value self.received_operations = [] # Queue for holding each operation in the order it was receieved self.schedule = "" # Final serialiable history produced by scheduler self.timestamp = 1 # Timestamp for tracking ages of operations self.logger = LoggerModule.Logger()
def __init__(self, globalConf): self.__logger = LoggerModule.LoggerModule() self.__device = DeviceModule.DeviceModule() self.__host = HostModule.HostModule() self.__misc = MiscModule.MiscModule() self.__logs = LogsModule.LogsModule() self.__configuration = ConfigurationModule.ConfigurationModule() self.__globalConf = globalConf self.current_TC = TCInformation() self.__json_path = "" self.__json_data = dict() self.__json_top_key = "BootOtaCampaignData" self.__json_name = self.__json_top_key + ".json" self.TCR_data_handler = TCRDataHandler(self.__globalConf)
def __init__(self, conf): self.__globalConf = conf self.__historyEvent = "" self.__initial_content = [] self.__delta = "" self.__crashlogs = None self.__configuration = ConfigurationModule.ConfigurationModule() self.__output = OutputModule.OutputModule() self.__logger = LoggerModule.LoggerModule() self.__host = HostModule.HostModule() self.__device = DeviceModule.DeviceModule() self.__workaround = WorkaroundModule.WorkaroundModule() self.__logs = LogsModule.LogsModule() self.__misc = MiscModule.MiscModule()
def __init__(self, globalConf, jsonList, config, specific_type=None, print_config=True): self.__globalConf = globalConf self.__misc = MiscModule.MiscModule() self.__logger = LoggerModule.LoggerModule() self.__configType = config self.__jsonList = jsonList self.__specific_type = specific_type self.DATA = dict() self.__print_config = print_config self.parseJson()
def run(): try: free_rfid = db.get_free_rfid() while (free_rfid): free_album = db.get_free_album() if free_album is None: break barcodeid = free_album[1] name = free_album[2] db.update_item_by_barcodeid(free_rfid[0], barcodeid, name) free_rfid = db.get_free_rfid() print "Mapping done" except Exception, ex: logger = LoggerModule.Logger("Mapping RFID with Album") logger.error("%s" % ex) print "Have error: %s" % ex
def __init__(self, conf): self.globalConf = conf self.logger = LoggerModule.LoggerModule() self.host = HostModule.HostModule() self.relayCard = RelayCardModule.RelayCardModule() self.device = DeviceModule.DeviceModule() self.workaround = WorkaroundModule.WorkaroundModule() self.misc = MiscModule.MiscModule() self.osManager = OsManagerModule.OsManagerModule() self.flashFile = FlashFileModule.FlashFileModule() self.logs = LogsModule.LogsModule() self.efiVar = EfiVarModule.EfiVarModule() self.dediprog = DediprogModule.DediprogModule() self.output = OutputModule.OutputModule() self.configuration = ConfigurationModule.ConfigurationModule() self.bootData = BootDataModule.BootDataModule() self.resetIrq = ResetIrqModule.ResetIrqModule() self.download = DownloadModule.DownloadModule() self.flash = FlashModule.FlashModule() self.campaign = CampaignModule.CampaignModule() self.watchdog = WatchdogModule.WatchdogModule() self.report = ReportModule.ReportModule() self.events = EventsModule.EventsModule() self.step_list = list() self.verdict = True self.output = "" self.name = "" self.skipping = False self.tc_crashlogs = None self.allowed_TC_upon_success = [] self.removed_TC_upon_success = [] self.allowed_TC_upon_failure = [] self.removed_TC_upon_failure = [] self.allowed_TC_upon_skip = [] self.removed_TC_upon_skip = [] self.campaign_constraint_file = "" self.campaign_constraint_file_name = "PupdrCampaignConstraints.json" self.enable_init = True self.enable_final = True self.INVALID = "INVALID" self.VALID = "VALID" self.BLOCKED = "BLOCKED" self.FAILURE = "FAILURE" self.SUCCESS = "SUCCESS" self.verdict_name = self.SUCCESS self.step_number = 0 self.output_dict = {}
def main(): try: #Kill all python and mpc kill_kinderbox() kill_reading_RFID() #Run readingRFID.py : receive new RFID from sensor os.system("sudo python /home/pi/huy-projects/kinderbox/kinderbox.py &") print "Status: 204 NO CONTENT" print "Content-Type: application/json;charset=UTF-8" print except Exception, e: logger = LoggerModule.Logger("Enable Kinderbox") logger.error("%s" % e) print "Status: 400 BAD REQUEST" print "Content-Type: application/json;charset=UTF-8" print print "Unexpected error: %s" % e
def __init__(self): """ init """ self.__host = HostModule.HostModule() self.__logger = LoggerModule.LoggerModule() # Shift of /proc/uptime in device self.uptimeShift = None # Shift of date in device self.offtimeShift = None # Past time on host self.timePast = None # Time read on device self.deviceTime = None # Time read on host self.hostTime = None self.__timeSet = None self.__delta = None self.__uptimeDiff = None
def init(self, globalConf=None): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() self.__output = OutputModule.OutputModule() self.flash = None self.boot = None self.logs = None self.timeout = None self.download = None self.custom = None self.boot_vars = None self.workaround = None self.board = None self.branch = None self.test_description = None self.__configuration_list = dict() self.__branchList = None self.__boardList = None self.__current_config_name = ""
def run(): try: listItem = db.get_all_item() item_map = [] if listItem is None: print json.dumps({"data": item_map}) return for (r, b, n, cr) in listItem: rfid = r barcodeid = b name = n created_date = cr d = dict(rfid=rfid, barcodeid=barcodeid, name=name, created_at=created_date) item_map.append(d) js = json.dumps({"data": item_map}) except Exception, ex: logger = LoggerModule.Logger("Get item") logger.error("Get item error: %s" % ex) js = json.dumps({"error": "%s" % ex})
def init(self, globalConf=None, externalCmdExec=False): self.__globalConf = globalConf self.__logger = LoggerModule.LoggerModule() if externalCmdExec: self.__isExternal = True else: self.__isExternal = False self.updateSerialNumbers() self.__credentials = self.__globalConf.get("CREDENTIALS", "") if not self.__credentials or len( self.__credentials.split(":")) != 2 or [ x for x in self.__credentials.split(":") if not x ]: self.__logger.printLog( "WARNING", "HostModule init: error with credentials, unexpected format or empty (artifactory download disabled)" ) self.__credentials = "" else: self.__logger.printLog( "INFO", "HostModule init: using '{}' credentials".format( self.__print_creds_user()))