Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
kitabatake1013 committed Aug 31, 2022
2 parents 590bb82 + 88ce599 commit a64c651
Show file tree
Hide file tree
Showing 25 changed files with 951 additions and 654 deletions.
45 changes: 31 additions & 14 deletions AppBase.py
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):
Expand Down Expand Up @@ -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):
"""設定ファイルを読み込む。なければデフォルト設定を適用し、設定ファイルを書く。"""
Expand All @@ -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):
"""翻訳を初期化する。"""
Expand Down
24 changes: 22 additions & 2 deletions ConfigManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from logging import getLogger


import errorCodes

class ConfigManager(configparser.ConfigParser):
def __init__(self):
Expand All @@ -31,7 +31,27 @@ def read(self,fileName):

def write(self):
self.log.info("write configFile:"+self.fileName)
with open(self.fileName,"w", encoding='UTF-8') as f: return super().write(f)
try:
with open(self.fileName,"w", encoding='UTF-8') as f: super().write(f)
return errorCodes.OK
except PermissionError as e:
self.log.warning("write failed." + str(e))
return errorCodes.ACCESS_DENIED
except FileNotFoundError as e:
self.log.warning("write failed." + str(e))
dirName = os.path.dirname(self.fileName)
self.log.info("try to create directory:"+dirName)
try:
os.makedirs(dirName, exist_ok=True)
except:
self.log.error("auto directory creation failed.")
return errorCodes.ACCESS_DENIED
try:
with open(self.fileName,"w", encoding='UTF-8') as f: super().write(f)
return errorCodes.OK
except:
self.log.error("save failed.")
return errorCodes.ACCESS_DENIED

def __getitem__(self,key):
try:
Expand Down
2 changes: 1 addition & 1 deletion TCV.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def exchandler(type, exc, tb):
except:
pass
else:
simpleDialog.winDialog("error", "An error has occured. Contact to the developer for further assistance. Detail:" + "\n".join(msg[-2:]))
simpleDialog.winDialog("error", "An error has occurred. Contact to the developer for further assistance. Detail:" + "\n".join(msg[-2:]))
try:
f=open("errorLog.txt", "a")
f.writelines(msg)
Expand Down
25 changes: 25 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,28 @@ def OnExit(self):
#戻り値は無視される
return 0

def getProxyInfo(self):
"""プロキシサーバーの情報を取得
:return: (URL, port)のタプル
:rtype: tuple
"""
data = os.environ.get("HTTP_PROXY")
self.log.debug("Retrieving proxy information from environment variable...")
if data == None:
self.log.info("Proxy information could not be found.")
return (None, None)
self.log.debug("configured data: %s" %data)
separator = data.rfind(":")
if separator == -1:
self.log.info("Validation Error.")
return (None, None)
url = data[:separator]
port = data[separator + 1:]
try:
port = int(port)
except ValueError:
self.log.info("Validation Error.")
return (None, None)
self.log.info("Proxy URL: %s, Port: %s." %(url, port))
return (url, port)
4 changes: 2 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#アプリケーション基本情報
APP_NAME="TCV"
APP_FULL_NAME = "TwitCasting Viewer"
APP_VERSION="3.2.1"
APP_VERSION="3.2.2"
APP_LAST_RELEASE_DATE = "2021-07-24"
APP_ICON = None
APP_COPYRIGHT_YEAR="2019-2021"
APP_COPYRIGHT_YEAR="2019-2022"
APP_LICENSE="GNU General Public License2.0 or later"
APP_DEVELOPERS="Kazto Kitabatake, ACT Laboratory"
APP_DEVELOPERS_URL="https://actlab.org/"
Expand Down
Binary file modified locale/en-us/LC_MESSAGES/messages.mo
Binary file not shown.
Loading

0 comments on commit a64c651

Please sign in to comment.