saintbyte / openbmap

Automatically exported from code.google.com/p/openbmap
Other
1 stars 1 forks source link

DB loader script fails if first file is krank #61

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run DB loader script, making sure the first file it is going to process is 
malformed.

What is the expected output? What do you see instead?
Expected: report that a malformed file was found, rest of files imported cleanly
Instead: Script reports first file as krank, then exits.

What version of the product are you using? On what operating system?

Please provide any additional information below.

Error message is:

---> Krank file found:  V1_log20140221185700-wifi.xml
Traceback (most recent call last):
  File "1 add_raw_wifis_to_db.py", line 77, in <module>
    if (tree.getroot().attrib.get('swid') == 'Radiobeacon'):
NameError: name 'tree' is not defined

Reason: Upon encountering a krank file, the exception handler closes the file, 
then tries to read from tree (which is the XML tree). When a krank file is 
encountered, tree is not altered. 

Result:
* When a file has been added successfully and the next one is krank, the file 
preceding the krank one will be added a secind time.
* When the first file is krank, the script tries to access an uninitialized 
object. 

Solution:
In 
tools/wifi_db_builder/1 add_raw_wifis_to_db.py
after line 66, add a continue statement (after file.close()). This will cause 
the script to skip the rest of the current loop iteration when a krank file is 
found and proceed immediately to the next one.

The cell loader script probably suffers from the same bug and the fix should be 
the same.

Original issue reported on code.google.com by mich...@vonglasow.com on 21 Feb 2014 at 8:42

GoogleCodeExporter commented 9 years ago
Hey Michael,

thx for reporting, is now fixed with r092db7f01fa0

Cheers
Toby

Original comment by wish7code on 22 Feb 2014 at 12:05