Changeset 3320
- Timestamp:
- 08/03/08 17:24:31 (5 years ago)
- Location:
- branch/BluetoothScanner/umitBluetooth
- Files:
-
- 4 added
- 3 removed
- 3 modified
-
btcore.py (modified) (1 diff)
-
db/btdb.dat (deleted)
-
db/btdb.db (added)
-
interface.py (modified) (1 diff)
-
io.py (modified) (4 diffs)
-
long.ubt (deleted)
-
parser.py (added)
-
pixmaps/Thumbs.db (added)
-
short.ubt (deleted)
-
test.ubt (added)
Legend:
- Unmodified
- Added
- Removed
-
branch/BluetoothScanner/umitBluetooth/btcore.py
r3171 r3320 104 104 btmacsearch = [""] 105 105 btnamesearch = [""] 106 # btdb.d atsearch107 if(os.path.exists(os.path.join("db", "btdb.d at"))):106 # btdb.db search 107 if(os.path.exists(os.path.join("db", "btdb.db"))): 108 108 print "start manufac detection" 109 btdb_dir = os.path.abspath(os.path.join("db", "btdb.d at"))109 btdb_dir = os.path.abspath(os.path.join("db", "btdb.db")) 110 110 btdb = open(btdb_dir, "rb") 111 111 while ((len(btname)-1) > count): -
branch/BluetoothScanner/umitBluetooth/interface.py
r3171 r3320 93 93 vbox1.pack_start(hbox1, False, False) 94 94 95 #Button96 self.scanbutton = gtk.Button("Probe Devices")97 self.scanbutton.connect("clicked", self.enter_cb)98 hbox1.pack_start(self.scanbutton, False, True, 540)99 100 95 #Progressbar 101 96 self.progb = gtk.ProgressBar() 102 97 self.progb.set_text("") 103 98 self.progb.set_fraction(0) 104 hbox1.pack_end(self.progb, False, True, 10) 99 hbox1.pack_end(self.progb, False, False, 5) 100 101 #Button 102 self.scanbutton = gtk.Button("Probe Devices") 103 self.scanbutton.connect("clicked", self.enter_cb) 104 hbox1.pack_end(self.scanbutton, False, False, 0) 105 105 106 106 # Paned -
branch/BluetoothScanner/umitBluetooth/io.py
r3171 r3320 25 25 26 26 import btcore 27 import parser 27 28 28 29 class io: … … 39 40 save_file, extension = os.path.splitext(save_file) 40 41 save_file = save_file + ".ubt" 41 outfile = open (save_file, "w") 42 string = "" 43 doc = XMLDocument("UmitBT", name="ubt") 42 44 while (len(btcore.btname)-1) > count: 43 45 count += 1 44 field1 = "<i1>" + btcore.btname[count] + "</i1>" 45 field2 = "<i2>" + btcore.btmac[count] + "</i2>" 46 field3 = "<i3>" + btcore.btmanu[count] + "</i3>" 47 field4 = "<i4>" + btcore.btsdp[count] + "</i4>" 48 event = field1 + field2 + field3 + field4 49 outfile.writelines(event) 50 outfile.close() 46 table = doc.add("table", name=str(count)) 47 table.add("info", name="BTname", value=btcore.btname[count]) 48 table.add("info", name="BTmac", value=btcore.btmac[count]) 49 table.add("info", name="BTmanu", value=btcore.btmanu[count]) 50 table.add("info", name="BTsdp", value=btcore.btsdp[count]) 51 print doc 52 string = doc 53 outfile = open (save_file, "w") 54 outfile.write(string.doc.toprettyxml(" ")) 55 outfile.close() 51 56 52 57 def load(self): … … 59 64 print "OPEN FILENAME : " + extension 60 65 if(load_file and extension == ".ubt"): 61 for line in inFile: 62 count+=1 63 btnamebuf, buffer = line.split("</i1>") 64 btnamebuf = string.replace(btnamebuf, "<i1>", "") 65 print btnamebuf 66 btmacbuf, buffer2 = buffer.split("</i2>") 67 btmacbuf = string.replace(btmacbuf, "<i2>", "") 68 print btmacbuf 69 btmanubuf, buffer3 = buffer2.split("</i3>") 70 btmanubuf = string.replace(btmanubuf, "<i3>", "") 71 print btmanubuf 72 btsdpbuf, buffer4 = buffer3.split("</i4>") 73 btsdpbuf = string.replace(btsdpbuf, "<i4>", "") 74 print btsdpbuf 75 #string formatting \ remove newline 76 btcore.btname.append(btnamebuf) 77 btcore.btmac.append(btmacbuf) 78 btcore.btmanu.append(btmanubuf) 79 btcore.btsdp.append(btsdpbuf) 80 #btname[count] = string.replace(btname[count], "\n", " ") 66 xml_load = inFile.read() 67 ndoc = XMLDocument() 68 ndoc.parseString(str(xml_load)) 69 root = ndoc.getAll("UmitBT") 70 if root: 71 db = root[0] 72 print "Database:", db["ubt"] 73 for table in db.getAll("table"): 74 print "Table:", table["name"] 75 for field in db.getAll("info"): 76 print "Field:", field["name"], "- Type:", field["value"] 77 if(field["name"] == "BTname"): 78 btcore.btname.append(field["value"]) 79 elif(field["name"] == "BTmac"): 80 btcore.btmac.append(field["value"]) 81 elif(field["name"] == "BTmanu"): 82 btcore.btmac.append(field["value"]) 83 elif(field["name"] == "BTsdp"): 84 btcore.btsdp.append(field["value"]) 85 else: 86 print "I/O error encountered!" 87 81 88 else: 82 89 print "File Load error!" 90 83 91 84 92 def file_browse(self, dialog_action, file_name=""): … … 120 128 121 129 def clear_buffer(self): 122 btcore.btname = [""]123 btcore.btmac = [""]124 btcore.btmanu = [""]125 btcore.btsdp = [""]130 btcore.btname = [""] 131 btcore.btmac = [""] 132 btcore.btmanu = [""] 133 btcore.btsdp = [""]
