Changeset 3320

Show
Ignore:
Timestamp:
08/03/08 17:24:31 (5 years ago)
Author:
devtar
Message:

Update on interface. UmitBT I/O draft. UBT parser

Location:
branch/BluetoothScanner/umitBluetooth
Files:
4 added
3 removed
3 modified

Legend:

Unmodified
Added
Removed
  • branch/BluetoothScanner/umitBluetooth/btcore.py

    r3171 r3320  
    104104        btmacsearch = [""] 
    105105        btnamesearch = [""] 
    106         # btdb.dat search                
    107         if(os.path.exists(os.path.join("db", "btdb.dat"))): 
     106        # btdb.db search                 
     107        if(os.path.exists(os.path.join("db", "btdb.db"))): 
    108108                print "start manufac detection" 
    109                 btdb_dir = os.path.abspath(os.path.join("db", "btdb.dat")) 
     109                btdb_dir = os.path.abspath(os.path.join("db", "btdb.db")) 
    110110                btdb = open(btdb_dir, "rb") 
    111111                while ((len(btname)-1) > count): 
  • branch/BluetoothScanner/umitBluetooth/interface.py

    r3171 r3320  
    9393        vbox1.pack_start(hbox1, False, False) 
    9494 
    95         #Button 
    96         self.scanbutton = gtk.Button("Probe Devices") 
    97         self.scanbutton.connect("clicked", self.enter_cb) 
    98         hbox1.pack_start(self.scanbutton, False, True, 540) 
    99  
    10095        #Progressbar 
    10196        self.progb = gtk.ProgressBar() 
    10297        self.progb.set_text("") 
    10398        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) 
    105105 
    106106        # Paned 
  • branch/BluetoothScanner/umitBluetooth/io.py

    r3171 r3320  
    2525 
    2626import btcore 
     27import parser 
    2728 
    2829class io: 
     
    3940         save_file, extension = os.path.splitext(save_file) 
    4041         save_file = save_file + ".ubt" 
    41          outfile = open (save_file, "w") 
     42         string = "" 
     43         doc = XMLDocument("UmitBT", name="ubt") 
    4244         while (len(btcore.btname)-1) > count: 
    4345                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() 
    5156 
    5257   def load(self):     
     
    5964         print "OPEN FILENAME : " + extension 
    6065         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 
    8188         else: 
    8289             print "File Load error!" 
     90                         
    8391 
    8492   def file_browse(self, dialog_action, file_name=""): 
     
    120128    
    121129   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 = [""]