def sendReport(self): # need to reimport - Qt provides something stupid instead from __builtin__ import hex self.reportSettings( "Settings", [ ( "Classifiers", ", ".join( '<font color="#%s">%s</font>' % ( "".join(("0" + hex(x)[2:])[-2:] for x in self.classifierColor[cNum].getRgb()[:3]), str(item.text()), ) for cNum, item in enumerate( self.classifiersQLB.item(i) for i in range(self.classifiersQLB.count()) ) if item.isSelected() ), ), ("Target class", self.classCombo.itemText(self.targetClass) if self.targetClass is not None else "N/A"), ("Costs", "FP=%i, FN=%i" % (self.FPcost, self.FNcost)), ("Prior target class probability", "%i%%" % self.pvalue), ], ) if self.targetClass is not None: self.reportRaw("<br/>") self.reportImage(self.graphs[self.targetClass].saveToFileDirect, QSize(500, 400))
def hex(obj): if isinstance(obj, Element): return obj.hex() elif hasattr(obj, '__hex__') and callable(obj.__hex__): return obj.__hex__() else: # will certainly raise return builtins.hex(obj)
def hex(value): """ @brief Convert an integer or list of integers to a hex string. This overrides the built-in function which adds a trailing 'L' to large numbers. This version also recurses down an array. If passed anything that's not an int or array, we simply return its string representation. """ if isinstance(value, (list, tuple)): return str([hex(intgr) for intgr in value]) elif isinstance(value, (int, long)): return __builtin__.hex(value).rstrip('L') return str(value)
def sendReport(self): # need to reimport - Qt provides something stupid instead from __builtin__ import hex self.reportSettings("Settings", [ ("Classifiers", ", ".join( '<font color="#%s">%s</font>' % ("".join( ("0" + hex(x)[2:])[-2:] for x in self.classifierColor[cNum].getRgb()[:3]), str(item.text())) for cNum, item in enumerate( self.classifiersQLB.item(i) for i in range(self.classifiersQLB.count())) if item.isSelected())), ("Target class", self.classCombo.itemText(self.targetClass)), ]) self.reportRaw("<br/>") self.reportImage(self.graphs[self.targetClass].saveToFileDirect, QSize(400, 400))
def sendReport(self): # need to reimport - Qt provides something stupid instead from __builtin__ import hex self.reportSettings("Settings", [ ("Classifiers", ", ".join( '<font color="#%s">%s</font>' % ("".join( ("0" + hex(x)[2:])[-2:] for x in self.classifierColor[cNum].getRgb()[:3]), str(item.text())) for cNum, item in enumerate( self.classifiersQLB.item(i) for i in range(self.classifiersQLB.count())) if item.isSelected())), ("Target class", self.classCombo.itemText(self.targetClass) if self.targetClass is not None else "N/A"), ("Costs", "FP=%i, FN=%i" % (self.FPcost, self.FNcost)), ("Prior target class probability", "%i%%" % self.pvalue) ]) if self.targetClass is not None: self.reportRaw("<br/>") self.reportImage(self.graphs[self.targetClass].saveToFileDirect, QSize(500, 400))
def makekml(self): # vedi di aggiungere zoom,range e view type ... magari link a immagini ??? # aggiungi un "salva in sqlite" il db deve essere inizializzato nelle preferenze LabelAlpha = self.LabelAlpha.value() LineAlpha = self.LineAlpha.value() PolygonAlpha = self.PolygonAlpha.value() labalpha = hex(int(LabelAlpha)) linalpha = hex(int(LineAlpha)) polalpha = hex(int(PolygonAlpha)) labalpha = labalpha.split('x') linalpha = linalpha.split('x') polalpha = polalpha.split('x') labalpha = labalpha[-1] linalpha = linalpha[-1] polalpha = polalpha[-1] if len(labalpha) == 1: labalpha = str('0')+labalpha if len(linalpha) == 1: linalpha = str('0')+linalpha if len(polalpha) == 1: polalpha = str('0')+polalpha colorlabel = VectorLabelColorName colorline = VectorLineColorName colorpolygon = VectorPolygonColorName colorlabel = colorlabel[1:] colorlabelR = colorlabel[0:2] colorlabelG = colorlabel[2:4] colorlabelB = colorlabel[4:6] colorlabel = colorlabelB+colorlabelG+colorlabelR colorlabel = str(labalpha)+colorlabel colorline = colorline[1:] colorlineR = colorline[0:2] colorlineG = colorline[2:4] colorlineB = colorline[4:6] colorline = colorlineB+colorlineG+colorlineR colorline = str(linalpha)+colorline colorpolygon = colorpolygon[1:] colorpolygonR = colorpolygon[0:2] colorpolygonG = colorpolygon[2:4] colorpolygonB = colorpolygon[4:6] colorpolygon = colorpolygonB+colorpolygonG+colorpolygonR colorpolygon = str(polalpha)+colorpolygon tessellate = 0 extrude = 0 kmldirectory = parseOutputconf()['kmldir'] if self.Tessellate.isChecked(): tessellate = 1 if self.Extrude.isChecked(): extrude = 1 kmldescr = self.kmllabel.text() kmlname = self.kmlname.text() self.kmlstr = """<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>%s</name> <open>0</open> <description>%s</description><Style id="Mystyle"> <LabelStyle> <color>%s</color> <colorMode>normal</colorMode> <scale>1</scale> </LabelStyle> <IconStyle> <Icon> <href>%s</href> </Icon> </IconStyle> <LineStyle> <color>%s</color> <colorMode>normal</colorMode> <tessellate>%s</tessellate> <width>%s</width> </LineStyle> <PolyStyle> <color>%s</color> <colorMode>normal</colorMode> </PolyStyle> </Style>""" % (kmlname, kmldescr, colorlabel, self.iconpath, colorline, tessellate, self.LineWidth.value(), colorpolygon) print self.kmlstr """
def hex(value, fill): return "0x" + __builtin__.hex(value).lstrip("0x").rstrip("L").zfill(fill).upper()
])) def find_hash(h): for api in api_hashes: if h in api.lower(): return api return None funcs = filter(lambda x: x is not None, map(find_hash, hashes)) for idx, func in enumerate(funcs): print( '0x46d + {_coconut_format_0} | {_coconut_format_1}:\t{_coconut_format_2}' .format(_coconut_format_0=(hex(idx * 4)), _coconut_format_1=(hex(0x46d + idx * 4)), _coconut_format_2=(func))) # 0x349 arg_1 = b'\x15\x44\xa8\xc0' # 0xc0a84415 arg_2 = b'\x39\x05' # 0x539 socket = bytearray(0x10) socket[0] = 0 socket[1] = 2 # ax = (arg_2 << 8) | (arg_2 >> 8) ax = arg_2[::-1] socket[2] = arg_2[0] socket[3] = arg_2[1] arg_1 = arg_1[::-1] socket[4] = arg_1[0]
def hex(): """Return UUID as hexidecimal""" return __builtin__.hex(int())[2:-1]
def savekml(self): # vedi di aggiungere zoom,range e view type ... magari link a immagini ??? # aggiungi un "salva in sqlite" il db deve essere inizializzato nelle preferenze LabelAlpha = self.LabelAlpha.value() LineAlpha = self.LineAlpha.value() PolygonAlpha = self.PolygonAlpha.value() labalpha = hex(int(LabelAlpha)) linalpha = hex(int(LineAlpha)) polalpha = hex(int(PolygonAlpha)) labalpha = labalpha.split('x') linalpha = linalpha.split('x') polalpha = polalpha.split('x') labalpha = labalpha[-1] linalpha = linalpha[-1] polalpha = polalpha[-1] if len(labalpha) == 1: labalpha = str('0')+labalpha if len(linalpha) == 1: linalpha = str('0')+linalpha if len(polalpha) == 1: polalpha = str('0')+polalpha colorlabel = VectorLabelColorName colorline = VectorLineColorName colorpolygon = VectorPolygonColorName colorlabel = colorlabel[1:] colorlabelR = colorlabel[0:2] colorlabelG = colorlabel[2:4] colorlabelB = colorlabel[4:6] colorlabel = colorlabelB+colorlabelG+colorlabelR colorlabel = str(labalpha)+colorlabel colorline = colorline[1:] colorlineR = colorline[0:2] colorlineG = colorline[2:4] colorlineB = colorline[4:6] colorline = colorlineB+colorlineG+colorlineR colorline = str(linalpha)+colorline colorpolygon = colorpolygon[1:] colorpolygonR = colorpolygon[0:2] colorpolygonG = colorpolygon[2:4] colorpolygonB = colorpolygon[4:6] colorpolygon = colorpolygonB+colorpolygonG+colorpolygonR colorpolygon = str(polalpha)+colorpolygon tessellate = 0 extrude = 0 kmldirectory = parseOutputconf()['kmldir'] if self.Tessellate.isChecked(): tessellate = 1 if self.Extrude.isChecked(): extrude = 1 kml = """<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>%s</name> <open>0</open> <description>some desription here</description><Style id="Mystyle"> <LabelStyle> <color>%s</color> <colorMode>normal</colorMode> <scale>1</scale> </LabelStyle> <IconStyle> <Icon> <href>%s</href> </Icon> </IconStyle> <LineStyle> <color>%s</color> <colorMode>normal</colorMode> <tessellate>%s</tessellate> <width>%s</width> </LineStyle> <PolyStyle> <color>%s</color> <colorMode>normal</colorMode> </PolyStyle> </Style><Placemark> <name>%s</name> <description><![CDATA[<div name="" id="id_main" align="center" dir="ltr" width="680"><table width="680" height="375"><tr>%s<td></td>]]></description> <visibility>0</visibility> <styleUrl>#Mystyle</styleUrl><LookAt> <longitude>%s</longitude> <latitude>%s</latitude> <altitude>%s</altitude> <range>%s</range> <tilt>%s</tilt> <heading>%s</heading> <altitudeMode>relativeToGround</altitudeMode> </LookAt><Point> <extrude>%s</extrude> <altitudeMode>relativeToGround</altitudeMode> <coordinates>%s,%s,%s</coordinates> </Point></Placemark></Document></kml>""" % (self.kmlname.text(), colorlabel, self.iconpath, colorline, tessellate, self.LineWidth.value(), colorpolygon, self.kmllabel.text(), self.description.toHtml(), self.lon, self.lat, self.Zoomchange, self.Rangechange, self.Pitchchange, self.Headchange, extrude, self.lon, self.lat, self.Offset.value()) kmldir = str(kmldirectory)+'/' kmltosave = kmldir+self.kmlname.text()+'.kml' f=codecs.open(kmltosave, 'w', 'UTF8' ) f.write(kml) f.close() kmz = self.compress_kml(str(kmltosave),str(self.iconpath))
def savekml(self): # vedi di aggiungere zoom,range e view type ... magari link a immagini ??? # aggiungi un "salva in sqlite" il db deve essere inizializzato nelle preferenze LabelAlpha = self.LabelAlpha.value() LineAlpha = self.LineAlpha.value() PolygonAlpha = self.PolygonAlpha.value() labalpha = hex(int(LabelAlpha)) linalpha = hex(int(LineAlpha)) polalpha = hex(int(PolygonAlpha)) labalpha = labalpha.split('x') linalpha = linalpha.split('x') polalpha = polalpha.split('x') labalpha = labalpha[-1] linalpha = linalpha[-1] polalpha = polalpha[-1] if len(labalpha) == 1: labalpha = str('0')+labalpha if len(linalpha) == 1: linalpha = str('0')+linalpha if len(polalpha) == 1: polalpha = str('0')+polalpha colorlabel = VectorLabelColorName colorline = VectorLineColorName colorpolygon = VectorPolygonColorName colorlabel = colorlabel[1:] colorlabelR = colorlabel[0:2] colorlabelG = colorlabel[2:4] colorlabelB = colorlabel[4:6] colorlabel = colorlabelB+colorlabelG+colorlabelR colorlabel = str(labalpha)+colorlabel colorline = colorline[1:] colorlineR = colorline[0:2] colorlineG = colorline[2:4] colorlineB = colorline[4:6] colorline = colorlineB+colorlineG+colorlineR colorline = str(linalpha)+colorline colorpolygon = colorpolygon[1:] colorpolygonR = colorpolygon[0:2] colorpolygonG = colorpolygon[2:4] colorpolygonB = colorpolygon[4:6] colorpolygon = colorpolygonB+colorpolygonG+colorpolygonR colorpolygon = str(polalpha)+colorpolygon tessellate = 0 extrude = 0 if self.Tessellate.isChecked(): tessellate = 1 if self.Extrude.isChecked(): extrude = 1 kml = """<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>%s</name> <open>0</open> <description>some desription here</description><Style id="Mystyle"> <LabelStyle> <color>%s</color> <colorMode>normal</colorMode> <scale>1</scale> </LabelStyle> <IconStyle> <Icon> <href>%s</href> </Icon> </IconStyle> <LineStyle> <color>%s</color> <colorMode>normal</colorMode> <tessellate>%s</tessellate> <width>%s</width> </LineStyle> <PolyStyle> <color>%s</color> <colorMode>normal</colorMode> </PolyStyle> </Style><Placemark> <name>%s</name> <description>%s</description> <visibility>0</visibility> <styleUrl>#Mystyle</styleUrl><LookAt> <longitude>%s</longitude> <latitude>%s</latitude> <altitude>%s</altitude> <range>%s</range> <tilt>%s</tilt> <heading>%s</heading> <altitudeMode>relativeToGround</altitudeMode> </LookAt><Point> <extrude>%s</extrude> <altitudeMode>relativeToGround</altitudeMode> <coordinates>%s,%s,%s</coordinates> </Point></Placemark></Document></kml>""" % (self.kmlname.text(), colorlabel, iconpath, colorline, tessellate, self.LineWidth.value(), colorpolygon, self.kmllabel.text(), self.description.toPlainText(), self.lon, self.lat, self.Zoomchange, self.Rangechange, self.Pitchchange, self.Headchange, extrude, self.lon, self.lat, self.Offset.value()) #print kml kmltosave = kmlpath+self.kmlname.text()+'.kml' #print kmltosave #kmltosave = kmltosave.replace("'","") f=open(str(kmltosave), 'w') f.write(kml) f.close() kmz = self.compress_kml(str(kmltosave),str(iconpath)) QMessageBox.information(self, 'debug', str(kmltosave)+' '+str(iconpath))
def hex(value): if value == 0: return "NULL" else: return "".join( ["0x", __builtin__.hex(value).lstrip("0x").rstrip("L").upper()])
def hex(value): if value == 0: return "NULL" else: return "".join(["0x" , __builtin__.hex(value).lstrip("0x").rstrip("L").upper()])
def savekml(self): # vedi di aggiungere zoom,range e view type ... magari link a immagini ??? # aggiungi un "salva in sqlite" il db deve essere inizializzato nelle preferenze LabelAlpha = self.LabelAlpha.value() LineAlpha = self.LineAlpha.value() PolygonAlpha = self.PolygonAlpha.value() labalpha = hex(int(LabelAlpha)) linalpha = hex(int(LineAlpha)) polalpha = hex(int(PolygonAlpha)) labalpha = labalpha.split('x') linalpha = linalpha.split('x') polalpha = polalpha.split('x') labalpha = labalpha[-1] linalpha = linalpha[-1] polalpha = polalpha[-1] if len(labalpha) == 1: labalpha = str('0') + labalpha if len(linalpha) == 1: linalpha = str('0') + linalpha if len(polalpha) == 1: polalpha = str('0') + polalpha colorlabel = VectorLabelColorName colorline = VectorLineColorName colorpolygon = VectorPolygonColorName colorlabel = colorlabel[1:] colorlabelR = colorlabel[0:2] colorlabelG = colorlabel[2:4] colorlabelB = colorlabel[4:6] colorlabel = colorlabelB + colorlabelG + colorlabelR colorlabel = str(labalpha) + colorlabel colorline = colorline[1:] colorlineR = colorline[0:2] colorlineG = colorline[2:4] colorlineB = colorline[4:6] colorline = colorlineB + colorlineG + colorlineR colorline = str(linalpha) + colorline colorpolygon = colorpolygon[1:] colorpolygonR = colorpolygon[0:2] colorpolygonG = colorpolygon[2:4] colorpolygonB = colorpolygon[4:6] colorpolygon = colorpolygonB + colorpolygonG + colorpolygonR colorpolygon = str(polalpha) + colorpolygon tessellate = 0 extrude = 0 kmldirectory = parseOutputconf()['kmldir'] if self.Tessellate.isChecked(): tessellate = 1 if self.Extrude.isChecked(): extrude = 1 kml = """<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>%s</name> <open>0</open> <description>some desription here</description><Style id="Mystyle"> <LabelStyle> <color>%s</color> <colorMode>normal</colorMode> <scale>1</scale> </LabelStyle> <IconStyle> <Icon> <href>%s</href> </Icon> </IconStyle> <LineStyle> <color>%s</color> <colorMode>normal</colorMode> <tessellate>%s</tessellate> <width>%s</width> </LineStyle> <PolyStyle> <color>%s</color> <colorMode>normal</colorMode> </PolyStyle> </Style><Placemark> <name>%s</name> <description><![CDATA[<div name="" id="id_main" align="center" dir="ltr" width="680"><table width="680" height="375"><tr>%s<td></td>]]></description> <visibility>0</visibility> <styleUrl>#Mystyle</styleUrl><LookAt> <longitude>%s</longitude> <latitude>%s</latitude> <altitude>%s</altitude> <range>%s</range> <tilt>%s</tilt> <heading>%s</heading> <altitudeMode>relativeToGround</altitudeMode> </LookAt><Point> <extrude>%s</extrude> <altitudeMode>relativeToGround</altitudeMode> <coordinates>%s,%s,%s</coordinates> </Point></Placemark></Document></kml>""" % ( self.kmlname.text(), colorlabel, self.iconpath, colorline, tessellate, self.LineWidth.value(), colorpolygon, self.kmllabel.text(), self.description.toHtml(), self.lon, self.lat, self.Zoomchange, self.Rangechange, self.Pitchchange, self.Headchange, extrude, self.lon, self.lat, self.Offset.value()) kmldir = str(kmldirectory) + '/' kmltosave = kmldir + self.kmlname.text() + '.kml' f = codecs.open(kmltosave, 'w', 'UTF8') f.write(kml) f.close() kmz = self.compress_kml(str(kmltosave), str(self.iconpath))
def savekml(self): # vedi di aggiungere zoom,range e view type ... magari link a immagini ??? # aggiungi un "salva in sqlite" il db deve essere inizializzato nelle preferenze LabelAlpha = self.LabelAlpha.value() LineAlpha = self.LineAlpha.value() PolygonAlpha = self.PolygonAlpha.value() labalpha = hex(int(LabelAlpha)) linalpha = hex(int(LineAlpha)) polalpha = hex(int(PolygonAlpha)) labalpha = labalpha.split('x') linalpha = linalpha.split('x') polalpha = polalpha.split('x') labalpha = labalpha[-1] linalpha = linalpha[-1] polalpha = polalpha[-1] if len(labalpha) == 1: labalpha = str('0') + labalpha if len(linalpha) == 1: linalpha = str('0') + linalpha if len(polalpha) == 1: polalpha = str('0') + polalpha colorlabel = VectorLabelColorName colorline = VectorLineColorName colorpolygon = VectorPolygonColorName colorlabel = colorlabel[1:] colorlabelR = colorlabel[0:2] colorlabelG = colorlabel[2:4] colorlabelB = colorlabel[4:6] colorlabel = colorlabelB + colorlabelG + colorlabelR colorlabel = str(labalpha) + colorlabel colorline = colorline[1:] colorlineR = colorline[0:2] colorlineG = colorline[2:4] colorlineB = colorline[4:6] colorline = colorlineB + colorlineG + colorlineR colorline = str(linalpha) + colorline colorpolygon = colorpolygon[1:] colorpolygonR = colorpolygon[0:2] colorpolygonG = colorpolygon[2:4] colorpolygonB = colorpolygon[4:6] colorpolygon = colorpolygonB + colorpolygonG + colorpolygonR colorpolygon = str(polalpha) + colorpolygon tessellate = 0 extrude = 0 if self.Tessellate.isChecked(): tessellate = 1 if self.Extrude.isChecked(): extrude = 1 kml = """<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>%s</name> <open>0</open> <description>some desription here</description><Style id="Mystyle"> <LabelStyle> <color>%s</color> <colorMode>normal</colorMode> <scale>1</scale> </LabelStyle> <IconStyle> <Icon> <href>%s</href> </Icon> </IconStyle> <LineStyle> <color>%s</color> <colorMode>normal</colorMode> <tessellate>%s</tessellate> <width>%s</width> </LineStyle> <PolyStyle> <color>%s</color> <colorMode>normal</colorMode> </PolyStyle> </Style><Placemark> <name>%s</name> <description>%s</description> <visibility>0</visibility> <styleUrl>#Mystyle</styleUrl><LookAt> <longitude>%s</longitude> <latitude>%s</latitude> <altitude>%s</altitude> <range>%s</range> <tilt>%s</tilt> <heading>%s</heading> <altitudeMode>relativeToGround</altitudeMode> </LookAt><Point> <extrude>%s</extrude> <altitudeMode>relativeToGround</altitudeMode> <coordinates>%s,%s,%s</coordinates> </Point></Placemark></Document></kml>""" % ( self.kmlname.text(), colorlabel, iconpath, colorline, tessellate, self.LineWidth.value(), colorpolygon, self.kmllabel.text(), self.description.toPlainText(), self.lon, self.lat, self.Zoomchange, self.Rangechange, self.Pitchchange, self.Headchange, extrude, self.lon, self.lat, self.Offset.value()) #print kml kmltosave = kmlpath + self.kmlname.text() + '.kml' #print kmltosave #kmltosave = kmltosave.replace("'","") f = open(str(kmltosave), 'w') f.write(kml) f.close() kmz = self.compress_kml(str(kmltosave), str(iconpath)) QMessageBox.information(self, 'debug', str(kmltosave) + ' ' + str(iconpath))