def loadfile(self,filename): self.clear_gpb() self.filename=filename f=open(filename, "r") gpb=settings.new_gpb_root() text_format.Merge( f.read(), gpb) f.close() self.create_toplevel(gpb)
def slot_gpbobject_updated(self, treewidget): topmessage=treewidget.topLevelItem(0) o=settings.new_gpb_root() buildgpb.Builder( o, topmessage ) warning = "" if not o.IsInitialized() : warning = "WARNING, gpb object is incomplete\n" self.setText(warning + text_format.MessageToString(o))
def save_gpb(self): o=settings.new_gpb_root() topmessage=self.topLevelItem(0) buildgpb.Builder( o, topmessage ) if not o.IsInitialized() : msgBox = QMessageBox() msgBox.setText("The GPB Object tree is incomplete. This is a bug, The file can not be saved") msgBox._exec() return filename = QFileDialog.getSaveFileName(self, "save gpb file", self.filename) if not filename : return self.filename=filename f=open(filename,"w") f.write( text_format.MessageToString(o)) f.close() settings.update_settings_file(loadfile=filename)
#!/usr/bin/python import sys, struct, google from socket import * import settings if __name__ == '__main__' : s=socket(AF_INET, SOCK_STREAM) s.connect( ('',5009) ) settings.read_settings_file() while True: bytes=s.recv(4) # mx header if bytes < 0 : break mxct = struct.unpack("<l", bytes)[0] print mxct bytes= s.recv(mxct) gpb=settings.new_gpb_root() gpb.ParseFromString( bytes ) print google.protobuf.text_format.MessageToString(gpb)