-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
282 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# coding=utf-8 | ||
from __future__ import (absolute_import, division, print_function, unicode_literals) | ||
|
||
import time | ||
import sys, os | ||
import traceback | ||
from os.path import dirname, join, isdir | ||
|
||
APP_NAME = "KoHighlights" | ||
APP_DIR = dirname(os.path.abspath(sys.argv[0])) | ||
os.chdir(APP_DIR) # Set the current working directory to the app's directory | ||
SETTINGS_DIR = join(os.environ['APPDATA'], APP_NAME) | ||
os.makedirs(SETTINGS_DIR) if not isdir(SETTINGS_DIR) else None | ||
|
||
|
||
def except_hook(class_type, value, trace_back): | ||
""" Print the error to a log file | ||
""" | ||
name = join(SETTINGS_DIR, "error_log_{}.txt".format(time.strftime("%Y-%m-%d"))) | ||
with open(name, "a") as log: | ||
log.write('\nCrash@{}\n'.format(time.strftime("%Y-%m-%d %H:%M:%S"))) | ||
traceback.print_exception(class_type, value, trace_back, file=open(name, "a")) | ||
sys.__excepthook__(class_type, value, trace_back) | ||
|
||
|
||
sys.excepthook = except_hook | ||
|
||
import gzip, json | ||
|
||
try: | ||
with gzip.GzipFile(join(SETTINGS_DIR, 'settings.json.gz'), 'rb') as settings: | ||
app_config = json.loads(settings.read()) | ||
except IOError: # first run | ||
app_config = {} | ||
|
||
FIRST_RUN = not bool(app_config) | ||
TITLE, AUTHOR, TYPE, PERCENT, MODIFIED, PATH = range(6) | ||
PAGE, HIGHLIGHT_TEXT, DATE, PAGE_ID, COMMENT = range(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.