Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dreadnought committed Jun 24, 2018
1 parent 6ca0788 commit 6728a39
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.pyc
.pybuild/
build/
debian/kismon/
5 changes: 2 additions & 3 deletions kismon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ def parse_line(self, line):
try:
data[cap_columns[y]] = column
except:
print("Parser error:", cap, y, len(columns), \
len(cap_columns), data)
print("Parser error:", cap, y, len(columns), len(cap_columns), data)
print(repr(line))
y += 1

Expand Down Expand Up @@ -247,7 +246,7 @@ def __init__ (self, server=None):
self.client = Client()
self.is_running = False
self.queue = {}
if server != None:
if server is not None:
self.client.server = server

def stop(self):
Expand Down
6 changes: 3 additions & 3 deletions kismon/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def queue_handler(self, server_id):
gps = data
if data["fix"] > 1:
fix = (data["lat"], data["lon"])
if self.config['tracks']['store'] == True:
if self.config['tracks']['store']:
self.tracks.add_point_to_track(server_name, data['lat'], data['lon'], data['alt'])
break
except IndexError:
Expand Down Expand Up @@ -303,7 +303,7 @@ def quit(self):
self.config['kismet']['servers'].remove(None)
self.config_handler.write()
self.networks.save(self.networks_file, force=True)
if self.config['tracks']['store'] == True:
if self.config['tracks']['store']:
self.tracks.save()

def add_network_to_map(self, mac):
Expand All @@ -328,7 +328,7 @@ def add_network_to_map(self, mac):

def main():
core = Core()
if core.main_window.gtkwin == None:
if core.main_window.gtkwin is None:
sys.exit()
try:
Gtk.main()
Expand Down
6 changes: 3 additions & 3 deletions kismon/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ def on_file_import(self, widget):
file_import_window.gtkwin.set_modal(True)

def on_file_export(self, widget, export_format, extension, amount):
dialog = Gtk.FileChooserDialog(title="Export as %s" % (export_format),
parent=self.gtkwin, action=Gtk.FileChooserAction.SAVE)
dialog = Gtk.FileChooserDialog(title="Export as %s" % export_format,
parent=self.gtkwin, action=Gtk.FileChooserAction.SAVE)
dialog.add_button('gtk-save', Gtk.ResponseType.OK)
dialog.add_button('gtk-cancel', Gtk.ResponseType.CANCEL)
dialog.set_do_overwrite_confirmation(True)
Expand All @@ -494,7 +494,7 @@ def on_file_export(self, widget, export_format, extension, amount):
if dialog.run() == Gtk.ResponseType.OK:
filename = dialog.get_filename()
dialog.destroy()
if filename == False:
if not filename:
return

if amount == "Filtered":
Expand Down
10 changes: 5 additions & 5 deletions kismon/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def set_position(self, lat, lon, force=False):
if self.is_position_invalid(lat, lon):
return
self.osm.gps_clear()
self.osm.gps_add(lat, lon, heading=OsmGpsMap.MAP_INVALID);
self.osm.gps_add(lat, lon, heading=OsmGpsMap.MAP_INVALID)

self.config["last_position"] = "%s/%s" % (lat, lon)

def set_center_and_zoom(self, lat, lon, zoom):
Expand Down Expand Up @@ -298,7 +298,7 @@ def update_marker(self, marker, key, lat, lon):
except KeyError:
new = True

if new == True:
if new:
self.add_image(lat, lon, key, marker.color)

marker.lat = lat
Expand Down Expand Up @@ -357,9 +357,9 @@ def start_moving(self):
self.set_position(float(lat), float(lon))

def on_map_pressed(self, actor, event):
if event != None:
if event is not None:
self.osm.grab_focus()
if event.x >= 32 and event.x < 48 and event.y >= 32 and event.y < 48:
if 32 <= event.x < 48 and 32 <= event.y < 48:
self.start_moving()

def locate_marker(self, key):
Expand Down
23 changes: 13 additions & 10 deletions kismon/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def apply_filters(self):
self.start_queue()

def check_filter(self, mac, network):
if self.config["filter_type"][network["type"]] == False:
if not self.config["filter_type"][network["type"]]:
return False

crypts = decode_cryptset(network["cryptset"])
Expand All @@ -174,7 +174,7 @@ def check_filter(self, mac, network):
crypt = "wep"
else:
crypt = "other"
if self.config["filter_crypt"][crypt] == False:
if not self.config["filter_crypt"][crypt]:
return False

if self.config["filter_regexpr"]["ssid"] != "":
Expand Down Expand Up @@ -313,7 +313,7 @@ def add_bssid_data(self, bssid, server_id):
network["channel"] = bssid["channel"]
network["lasttime"] = bssid["lasttime"]
network["signal_dbm"]["last"] = bssid["signal_dbm"]

network["firsttime"] = min(network["firsttime"], bssid["firsttime"])
network["signal_dbm"]["min"] = min(network["signal_dbm"]["min"], bssid["minsignal_dbm"])
network["signal_dbm"]["max"] = min(network["signal_dbm"]["max"], bssid["maxsignal_dbm"])
Expand Down Expand Up @@ -365,8 +365,8 @@ def add_network_data(self, mac, data):
else:
newer = False
if (network["lat"] == 0.0 and network["lon"] == 0.0) or \
(((signal and data_signal and network["signal_dbm"]["max"] < data["signal_dbm"]["max"]) or \
(not signal and data_signal)) and data["lat"] != 0.0 and data["lon"] != 0.0):
(((signal and data_signal and network["signal_dbm"]["max"] < data["signal_dbm"]["max"]) or
(not signal and data_signal)) and data["lat"] != 0.0 and data["lon"] != 0.0):
network["lat"] = data["lat"]
network["lon"] = data["lon"]
if newer or network["ssid"] == "":
Expand All @@ -392,6 +392,9 @@ def import_networks(self, filetype, filename):
parser = Netxml()
elif filetype == "csv":
parser = CSV()
else:
print("unknown filetype")
return 0

parser.parse(filename)

Expand All @@ -413,7 +416,7 @@ def export_networks(self, export_format, filename, networks=None, tracks=None, f
self.export_networks_mappoint(filename, networks)

def export_networks_netxml(self, filename, networks):
locale.setlocale(locale.LC_TIME, 'C');
locale.setlocale(locale.LC_TIME, 'C')
f = open(filename, "w")
f.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
f.write('<!DOCTYPE detection-run SYSTEM "http://kismetwireless.net/kismet-3.1.0.dtd">\n')
Expand Down Expand Up @@ -538,7 +541,7 @@ def export_networks_kmz(self, filename, networks, tracks, filtered):
"".join(folders[crypt])
))

if tracks != None:
if tracks is not None:
if filtered:
track_filter = self.config['filter_networks']['export']
else:
Expand Down Expand Up @@ -636,8 +639,8 @@ def parse(self, filename):
"network": None,
"encryption": {}
}
locale.setlocale(locale.LC_TIME, 'C');
locale.setlocale(locale.LC_TIME, 'C')

p = xml.parsers.expat.ParserCreate()
p.buffer_text = True #avoid chunked data
p.StartElementHandler = self.parse_start_element
Expand Down Expand Up @@ -734,7 +737,7 @@ def __init__(self):
self.networks = {}

def parse(self, filename):
locale.setlocale(locale.LC_TIME, 'C');
locale.setlocale(locale.LC_TIME, 'C')
f = open(filename)
head = f.readline().split(";")[:-1]
for line in f.readlines():
Expand Down
2 changes: 1 addition & 1 deletion kismon/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_client_test_data():
('status', {'text': 'Detected new managed network "test", BSSID 00:26:4D:4A:1C:11, encryption yes, channel 1, 54.00 mbit', 'flags': 2}),
('info', {'noise': 0, 'datapackets': 2, 'crypt': 2, 'clients': 0, 'packets': 58, 'rate': 0, 'llcpackets': 56, 'dropped': 0, 'numerrorsources': 0, 'numsources': 1, 'filtered': 0, 'networks': 13}),
]
return (test_lines, result_split_line, result_parse_line)
return test_lines, result_split_line, result_parse_line

def core_tests(test_core):
test_networks = networks()
Expand Down
3 changes: 1 addition & 2 deletions kismon/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ def export_kml(self, export_filter):
filter_time = self.starttime
else:
filter_time = 0
output = []
output.append("<Folder><name>Tracks</name>")
output = ["<Folder><name>Tracks</name>"]
sessions = self.group_to_sessions(filter_time)
time_format = "%a %b %d %H:%M:%S %Y"
for track_name in sessions:
Expand Down
2 changes: 1 addition & 1 deletion kismon/widgets/networklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def on_comment_editing_done(self, widget):
self.add_network(self.network_selected)

def prepare_network_servers(self, value):
if len(value) == 0 or value == None:
if len(value) == 0 or value is None:
servers = None
servers_str = None
else:
Expand Down
4 changes: 2 additions & 2 deletions kismon/widgets/servertab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
except ImportError:
from windows import ChannelWindow

class ServerTab():
class ServerTab:
def __init__(self, server_id, map, config, client_threads, client_start, client_stop, set_server_tab_label, on_server_remove_clicked):
self.server_id = server_id
self.config = config
Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(self, server_id, map, config, client_threads, client_start, client_
self.gps_expander = gps_expander
self.init_gps_table(server_id)

if self.map != None:
if self.map is not None:
track_expander = Gtk.Expander()
track_expander.set_label("GPS Track")
table = self.init_track_table(server_id)
Expand Down

0 comments on commit 6728a39

Please sign in to comment.