diff --git a/README.md b/README.md index 827c4ae..5676a23 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ Various utilities. -## License: GPL v3 \ No newline at end of file +Requires Python 3, versions below 3.4 might work but are not tested. + +## License: GPL v3 diff --git a/captureviewer.ini b/captureviewer.ini new file mode 100644 index 0000000..55c153a --- /dev/null +++ b/captureviewer.ini @@ -0,0 +1,7 @@ +[paths] +db_path= +[parse] +creations=True +serializations=True +game_messages=True +normal_packets=True diff --git a/captureviewer.pyw b/captureviewer.pyw index ed3c8c6..7bc6231 100644 --- a/captureviewer.pyw +++ b/captureviewer.pyw @@ -2,7 +2,9 @@ import configparser import math import os import sqlite3 +import sys import tkinter.filedialog as filedialog +import tkinter.messagebox as messagebox import xml.etree.ElementTree as ET import zipfile from collections import OrderedDict @@ -111,7 +113,12 @@ class CaptureViewer(viewer.Viewer): super().__init__() config = configparser.ConfigParser() config.read("captureviewer.ini") - self.db = sqlite3.connect(config["paths"]["db_path"]) + try: + self.db = sqlite3.connect(config["paths"]["db_path"]) + except: + messagebox.showerror("Can not open database", "Make sure db_path in the INI is set correctly.") + sys.exit() + self.enable_game_messages = "gamemessages_path" in config["paths"] if self.enable_game_messages: gamemsg_xml = ET.parse(config["paths"]["gamemessages_path"]) @@ -122,13 +129,13 @@ class CaptureViewer(viewer.Viewer): self.objects = [] self.lot_data = {} - self.parse_creations = BooleanVar(value=config["parse"].get("creations", True)) - self.parse_serializations = BooleanVar(value=config["parse"].get("serializations", True)) + self.parse_creations = BooleanVar(value=config["parse"]["creations"]) + self.parse_serializations = BooleanVar(value=config["parse"]["serializations"]) if self.enable_game_messages: - self.parse_game_messages = BooleanVar(value=config["parse"].get("game_messages", True)) + self.parse_game_messages = BooleanVar(value=config["parse"]["game_messages"]) else: self.parse_game_messages = BooleanVar(value=False) - self.parse_normal_packets = BooleanVar(value=config["parse"].get("normal_packets", True)) + self.parse_normal_packets = BooleanVar(value=config["parse"]["normal_packets"]) self.create_widgets() def create_widgets(self): diff --git a/luzviewer.ini b/luzviewer.ini new file mode 100644 index 0000000..b3ef3d0 --- /dev/null +++ b/luzviewer.ini @@ -0,0 +1,2 @@ +[paths] +db_path= diff --git a/luzviewer.pyw b/luzviewer.pyw index 47e385d..910b4cc 100644 --- a/luzviewer.pyw +++ b/luzviewer.pyw @@ -1,8 +1,10 @@ import configparser import os.path import sqlite3 +import sys import tkinter.filedialog as filedialog +import tkinter.messagebox as messagebox from tkinter import END, Menu import viewer @@ -13,7 +15,11 @@ class LUZViewer(viewer.Viewer): super().__init__() config = configparser.ConfigParser() config.read("luzviewer.ini") - self.db = sqlite3.connect(config["paths"]["db_path"]) + try: + self.db = sqlite3.connect(config["paths"]["db_path"]) + except: + messagebox.showerror("Can not open database", "Make sure db_path in the INI is set correctly.") + sys.exit() self.create_widgets() def create_widgets(self):