-
Notifications
You must be signed in to change notification settings - Fork 4
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
25 changed files
with
951 additions
and
654 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 |
---|---|---|
@@ -1,23 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
#Application Initializer | ||
#Copyright (C) 2019-2022 yamahubuki <[email protected]> | ||
|
||
|
||
import accessible_output2.outputs | ||
from accessible_output2.outputs.base import OutputError | ||
import sys | ||
import datetime | ||
import gettext | ||
import logging | ||
import wx | ||
import glob | ||
import locale | ||
import logging | ||
import logging.handlers | ||
import os | ||
import sys | ||
import traceback | ||
import win32api | ||
import datetime | ||
from logging import getLogger, FileHandler, Formatter | ||
import wx | ||
|
||
import constants | ||
import DefaultSettings | ||
import views.langDialog | ||
import simpleDialog | ||
import os | ||
import traceback | ||
import views.langDialog | ||
|
||
from accessible_output2.outputs.base import OutputError | ||
|
||
|
||
class MainBase(wx.App): | ||
def __init__(self): | ||
|
@@ -90,19 +95,30 @@ def _InitSpeech(self): | |
|
||
def InitLogger(self): | ||
"""ログ機能を初期化して準備する。""" | ||
ex = "" | ||
try: | ||
self.hLogHandler=FileHandler(constants.LOG_FILE_NAME, mode="w", encoding="UTF-8") | ||
self.deleteAllLogs() | ||
except Exception as e: | ||
ex = "".join(traceback.TracebackException.from_exception(e).format()) | ||
try: | ||
self.hLogHandler=logging.handlers.RotatingFileHandler(constants.LOG_FILE_NAME, mode="w", encoding="UTF-8", maxBytes=2**20*256, backupCount=5) | ||
self.hLogHandler.setLevel(logging.DEBUG) | ||
self.hLogFormatter=Formatter("%(name)s - %(levelname)s - %(message)s (%(asctime)s)") | ||
self.hLogFormatter=logging.Formatter("%(name)s - %(levelname)s - %(message)s (%(asctime)s)") | ||
self.hLogHandler.setFormatter(self.hLogFormatter) | ||
logger=getLogger(constants.LOG_PREFIX) | ||
logger=logging.getLogger(constants.LOG_PREFIX) | ||
logger.setLevel(logging.DEBUG) | ||
logger.addHandler(self.hLogHandler) | ||
except Exception as e: | ||
traceback.print_exc() | ||
self.log=getLogger(constants.LOG_PREFIX+".Main") | ||
self.log=logging.getLogger(constants.LOG_PREFIX+".Main") | ||
r="executable" if self.frozen else "interpreter" | ||
self.log.info("Starting"+constants.APP_NAME+" "+constants.APP_VERSION+" as %s!" % r) | ||
if ex: | ||
self.log.error("failed to deleteAllLogs().\n"+ex) | ||
|
||
def deleteAllLogs(self): | ||
for i in glob.glob("%s*" % constants.LOG_FILE_NAME): | ||
os.remove(i) | ||
|
||
def LoadSettings(self): | ||
"""設定ファイルを読み込む。なければデフォルト設定を適用し、設定ファイルを書く。""" | ||
|
@@ -111,7 +127,8 @@ def LoadSettings(self): | |
#初回起動 | ||
self.config.read_dict(DefaultSettings.initialValues) | ||
self.config.write() | ||
self.hLogHandler.setLevel(self.config.getint("general","log_level",20,0,50)) | ||
if self.log.hasHandlers(): | ||
self.hLogHandler.setLevel(self.config.getint("general","log_level",20,0,50)) | ||
|
||
def InitTranslation(self): | ||
"""翻訳を初期化する。""" | ||
|
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
Binary file not shown.
Oops, something went wrong.