def date(self): """ Returns the send date contained in the Properties file. """ try: return self.__date except AttributeError: if self.has_key('00390040'): self.__date = fromTimeStamp( msgEpoch(self.get('00390040').value)).__format__( '%a, %d %b %Y %H:%M:%S GMT %z') elif self.has_key('30080040'): self.__date = fromTimeStamp( msgEpoch(self.get('30080040').value)).__format__( '%a, %d %b %Y %H:%M:%S GMT %z') elif self.has_key('30070040'): self.__date = fromTimeStamp( msgEpoch(self.get('30070040').value)).__format__( '%a, %d %b %Y %H:%M:%S GMT %z') else: # DEBUG print( 'Warning: Error retrieving date. Setting as "Unknown". Please send the following data to developer:\n--------------------' ) print(properHex(self.__stream)) print(self.keys()) print('--------------------') self.__date = 'Unknown' return self.__date
def date(self): """ Returns the send date contained in the Properties file. """ try: return self.__date except AttributeError: if self.has_key('00390040'): self.__date = fromTimeStamp(msgEpoch(self.get('00390040').value)).__format__( '%a, %d %b %Y %H:%M:%S %z') elif self.has_key('30080040'): self.__date = fromTimeStamp(msgEpoch(self.get('30080040').value)).__format__( '%a, %d %b %Y %H:%M:%S %z') elif self.has_key('30070040'): self.__date = fromTimeStamp(msgEpoch(self.get('30070040').value)).__format__( '%a, %d %b %Y %H:%M:%S %z') else: # DEBUG logger.warning( 'Error retrieving date. Setting as "Unknown". Please send the following data to developer:\n--------------------') logger.warning(properHex(self.__stream)) logger.warning(self.keys()) logger.warning('--------------------') self.__date = 'Unknown' return self.__date
def parseType(self, _type, stream): """ Converts the data in :param stream: to a much more accurate type, specified by :param _type:, if possible. :param stream: #TODO what is stream for? WARNING: Not done. """ # WARNING Not done. value = stream if _type == 0x0000: # PtypUnspecified pass elif _type == 0x0001: # PtypNull if value != b'\x00\x00\x00\x00\x00\x00\x00\x00': # DEBUG logger.warning( 'Property type is PtypNull, but is not equal to 0.') value = None elif _type == 0x0002: # PtypInteger16 value = constants.STI16.unpack(value)[0] elif _type == 0x0003: # PtypInteger32 value = constants.STI32.unpack(value)[0] elif _type == 0x0004: # PtypFloating32 value = constants.STF32.unpack(value)[0] elif _type == 0x0005: # PtypFloating64 value = constants.STF64.unpack(value)[0] elif _type == 0x0006: # PtypCurrency value = (constants.STI64.unpack(value))[0] / 10000.0 elif _type == 0x0007: # PtypFloatingTime value = constants.STF64.unpack(value)[0] return constants.PYTPFLOATINGTIME_START + datetime.timedelta( days=value) elif _type == 0x000A: # PtypErrorCode value = constants.STI32.unpack(value)[0] # TODO parsing for this pass elif _type == 0x000B: # PtypBoolean value = bool(constants.ST3.unpack(value)[0]) elif _type == 0x0014: # PtypInteger64 value = constants.STI64.unpack(value)[0] elif _type == 0x0040: # PtypTime try: value = fromTimeStamp(msgEpoch(constants.ST3.unpack(value)[0])) except Exception as e: logger.exception(e) logger.error( 'Timestamp value of {} caused an exception. This was probably caused by the time stamp being too far in the future.' ) logger.error(self.raw) value = constants.ST3.unpack(value)[0] elif _type == 0x0048: # PtypGuid # TODO parsing for this pass return value