Campbell 4WPB100 Especificaciones Pagina 64

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 70
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 63
63
MOMSN =
AttachmentName[AttachmentName.index('_')+1:AttachmentName.index('.')]
ThisIMEIDir = BaseDir + '\\' + IMEI + '\\'#TODO make it more portable using
the path module
if not glob.glob(ThisIMEIDir): #this IMEI has already been seen
os.mkdir(BaseDir + '\\' + IMEI.encode(UnicodeEncoding))#TODO make it
more portable using the path module
Attachment.WriteToFile(ThisIMEIDir + AttachmentName)#TODO add
exceptions handling
with open(ThisIMEIDir + AttachmentName, 'rb') as InFile:#TODO add
exceptions handling
IsTooLong = False
IsTooShort = False
DataLine = InFile.read(420)
if len(DataLine) == 0: break
if DataLine[0].isdigit():
IsKnownBinaryFormat = False
MessageFormatNum = -9999
else:
MessageFormatNum = ord(DataLine[0])
try:
MessageFormat = FormatSpec[MessageFormatNum]
IsKnownBinaryFormat = True
except KeyError:
IsKnownBinaryFormat = False
UnknMsgFormNum = MessageFormatNum
if IsKnownBinaryFormat:#TODO bring all this "if" into the try logic
above
print '%s-%s (binary)' %(IMEI, MOMSN) , MessageFormat[2]
ExpectedMsgLen = FormatSpec[MessageFormatNum][3]
if len(DataLine) < ExpectedMsgLen:
IsTooShort = True
elif len(DataLine) > ExpectedMsgLen:
IsTooLong = True
BinaryMessage = DataLine[1:]
DataLine = '' #this is a bit crap but works... to be fixed when turning the
decoder into a func
BytePointer = 0
for ValueNum in range(0, MessageFormat[0]):#TODO - use an iterator
instead of indexes
ValueBytes = []
ValueBytesNum =
FormatBytesNum[MessageFormat[1][ValueNum]]
if MessageFormat[1][ValueNum] == 'f':
try:
for offset in range(0,ValueBytesNum):
Vista de pagina 63
1 2 ... 59 60 61 62 63 64 65 66 67 68 69 70

Comentarios a estos manuales

Sin comentarios