-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
85 additions
and
37 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
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,20 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
#ConfigManager | ||
#Copyright (C) 2019-2020 yamahubuki <[email protected]> | ||
#Copyright (C) 2019-2022 yamahubuki <[email protected]> | ||
|
||
import os | ||
import configparser | ||
import logging | ||
from logging import getLogger | ||
|
||
|
||
import errorCodes | ||
|
||
class ConfigManager(configparser.ConfigParser): | ||
def __init__(self): | ||
super().__init__(interpolation=None) | ||
self.identifier="ConfigManager" | ||
self.log=getLogger(self.identifier) | ||
self.log.debug("Create config instance") | ||
self.fileName = None | ||
|
||
def read(self,fileName): | ||
self.fileName=fileName | ||
|
@@ -31,7 +32,33 @@ 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 getFileName(self): | ||
return self.fileName | ||
|
||
def getAbsFileName(self): | ||
return os.path.abspath(self.fileName) | ||
|
||
def __getitem__(self,key): | ||
try: | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version": "1.3.0", "release_date": "2021-12-18"} | ||
{"version": "1.3.1", "release_date": "2022-02-02"} |
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,7 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
#main view | ||
#Copyright (C) 2019 Yukio Nozawa <[email protected]> | ||
#Copyright (C) 2019-2021 yamahubuki <[email protected]> | ||
#Copyright (C) 2019-2022 yamahubuki <[email protected]> | ||
|
||
|
||
import wx | ||
|
@@ -206,23 +206,19 @@ def OnMenuSelect(self,event): | |
#先頭の@はいらないので対策。入力時はあってもなくても良い | ||
prm = re.sub("@?(.*)","\\1", prm) | ||
|
||
self.log.debug("add user: %s" % prm) | ||
if self.parent.service.isUserRegistered(prm)==True: | ||
errorDialog(_("指定されたユーザは既に登録済みです。"),self.parent.hFrame) | ||
self.log.warning("user %s already registered." % prm) | ||
return errorCodes.DUPLICATED | ||
user = self.parent.service.getUserInfo(prm) | ||
if user in (errorCodes.PEING_ERROR,errorCodes.NOT_FOUND): | ||
self.showError(user) | ||
return user | ||
if yesNoDialog(_("ユーザ追加"),_("以下のユーザを追加しますか?\n\nID:%(id)d\n%(name)s(%(account)s)") % {"id":user.id,"name":user.name,"account":user.account},self.parent.hFrame)==wx.ID_NO: | ||
self.log.debug("add user:canceled by user") | ||
return | ||
if self.parent.service.addUser(user)==errorCodes.OK: | ||
ret = self.parent.service.addUser(user) | ||
if ret==errorCodes.OK: | ||
dialog(_("登録完了"),_("ユーザの登録に成功しました。今回登録したユーザの回答を表示するには、ビューを再読み込みしてください。"),self.parent.hFrame) | ||
self.log.info("user %s added!" % prm) | ||
else: | ||
errorDialog(_("ユーザの登録に失敗しました。"),self.parent.hFrame) | ||
self.showError(ret) | ||
self.log.error("add user:failed.") | ||
|
||
if selected==menuItemsStore.getRef("FILE_POST_QUESTION"): | ||
|
@@ -632,6 +628,8 @@ def showError(self,code,parent=None): | |
errorDialog(_("不明なエラーの為、ログインに失敗しました。サイトの仕様変更や、お使いのインターネット接続の障害が考えられます。まずは、ブラウザから同じIDでログインできるか確認してください。\nブラウザから正常にログインできる場合には、サイトの仕様変更が考えられますので、このメッセージと利用したIDの種類を添えて開発者までお問い合わせください。"),parent) | ||
elif code==errorCodes.LOGIN_RECAPTCHA_NEEDED: | ||
errorDialog(_("ログインに失敗しました。ログインに際してRECAPTCHA(ロボットでないことの確認)が要求されています。同じIDでブラウザからログインした後、再度お試しください。"),parent) | ||
elif code == errorCodes.DUPLICATED: | ||
errorDialog(_("指定されたユーザは既に登録済みです。")) | ||
elif code != errorCodes.OK: | ||
errorDialog(_("不明なエラー%(code)dが発生しました。大変お手数ですが、本ソフトの実行ファイルのあるディレクトリに生成された%(log)sを添付し、作者までご連絡ください。") %{"code":code,"log":constants.LOG_FILE_NAME},parent) | ||
return | ||
|
@@ -681,7 +679,8 @@ def setKeymap(self, identifier,ttl, keymap=None,filter=None): | |
newMap[identifier.upper()][menuData[name]]=key | ||
else: | ||
newMap[identifier.upper()][menuData[name]]="" | ||
newMap.write() | ||
if newMap.write() != errorCodes.OK: | ||
errorDialog(_("設定の保存に失敗しました。下記のファイルへのアクセスが可能であることを確認してください。") + "\n" + self.config.getAbsFileName()) | ||
return True | ||
|
||
# ログイン状態を確認し、必要ならログインする | ||
|