mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-11 05:30:17 +00:00
change logging format to %
This commit is contained in:
parent
fe3f610878
commit
0c88302053
15
index.py
15
index.py
@ -18,16 +18,12 @@ from ui.startup.databaseChecker import DatabaseChecker, DatabaseCheckerResult
|
||||
rootLogger = logging.getLogger("root")
|
||||
rootLogger.setLevel(logging.DEBUG)
|
||||
|
||||
rootLoggerFormatter = logging.Formatter(
|
||||
"[{levelname}]{asctime}|{name}: {msg}", "%m-%d %H:%M:%S", "{"
|
||||
)
|
||||
|
||||
|
||||
def handle_exception(exc_type, exc_value, exc_traceback):
|
||||
if issubclass(exc_type, KeyboardInterrupt):
|
||||
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||
return
|
||||
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||
|
||||
if issubclass(exc_type, KeyboardInterrupt):
|
||||
return
|
||||
rootLogger.critical(
|
||||
"Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)
|
||||
)
|
||||
@ -46,6 +42,11 @@ if __name__ == "__main__":
|
||||
ymd = now.strftime("%Y%m%d")
|
||||
hms = now.strftime("%H%M%S")
|
||||
|
||||
rootLoggerFormatter = logging.Formatter(
|
||||
"[%(asctime)s/%(levelname)s]%(name)s: %(message)s",
|
||||
"%m-%d %H:%M:%S",
|
||||
style="%",
|
||||
)
|
||||
rootLoggerFileHandler = logging.FileHandler(
|
||||
str(logFolder / f"arcaea-offline-pyside-ui-{ymd}-{hms}_debug.log"),
|
||||
encoding="utf-8",
|
||||
|
@ -140,7 +140,11 @@ class OcrQueueModel(QAbstractListModel):
|
||||
return True
|
||||
else:
|
||||
logger.warning(
|
||||
f"{repr(self)} setData at row {index.row()} with role {role} and value {value} rejected."
|
||||
"%r setData at row %d with role %d and value %s rejected!",
|
||||
self,
|
||||
index.row(),
|
||||
role,
|
||||
value,
|
||||
)
|
||||
return False
|
||||
|
||||
@ -150,7 +154,7 @@ class OcrQueueModel(QAbstractListModel):
|
||||
|
||||
@iccOption.setter
|
||||
def iccOption(self, opt: IccOption):
|
||||
logger.debug(f"ICC option changed to {opt}")
|
||||
logger.debug("ICC option changed to %s", opt)
|
||||
self.__iccOption = opt
|
||||
|
||||
@overload
|
||||
@ -159,8 +163,7 @@ class OcrQueueModel(QAbstractListModel):
|
||||
image: str,
|
||||
runnable: OcrRunnable = None,
|
||||
process_func: Callable[[Optional[str], QImage, Any], Score] = None,
|
||||
):
|
||||
...
|
||||
): ...
|
||||
|
||||
@overload
|
||||
def addItem(
|
||||
@ -168,8 +171,7 @@ class OcrQueueModel(QAbstractListModel):
|
||||
image: QImage,
|
||||
runnable: OcrRunnable = None,
|
||||
process_func: Callable[[Optional[str], QImage, Any], Score] = None,
|
||||
):
|
||||
...
|
||||
): ...
|
||||
|
||||
def addItem(
|
||||
self,
|
||||
@ -179,7 +181,7 @@ class OcrQueueModel(QAbstractListModel):
|
||||
):
|
||||
if isinstance(image, str):
|
||||
if image in self.imagePaths or not QFileInfo(image).exists():
|
||||
logger.warning(f"Attempting to add an invalid file {image}")
|
||||
logger.warning("Attempting to add an invalid file %s", image)
|
||||
return
|
||||
imagePath = image
|
||||
if self.iccOption == IccOption.TryFix:
|
||||
@ -223,7 +225,7 @@ class OcrQueueModel(QAbstractListModel):
|
||||
index = self.index(row, 0)
|
||||
imagePath: str = index.data(self.ImagePathRole)
|
||||
qImage: QImage = index.data(self.ImageQImageRole)
|
||||
logger.debug(f"update request: {result}@row{row}")
|
||||
logger.debug("update request: %r@row%d", result, row)
|
||||
processOcrResultFunc = index.data(self.ProcessOcrResultFuncRole)
|
||||
|
||||
chart, scoreInsert = processOcrResultFunc(imagePath, qImage, result)
|
||||
@ -294,8 +296,8 @@ class OcrQueueModel(QAbstractListModel):
|
||||
self.__items.pop(row)
|
||||
self.endRemoveRows()
|
||||
return
|
||||
except Exception as e:
|
||||
logger.exception(f"Error accepting {repr(item)}")
|
||||
except Exception:
|
||||
logger.exception("Error accepting %r", item)
|
||||
return
|
||||
|
||||
def acceptItems(self, __rows: list[int], ignoreValidate: bool = False):
|
||||
|
@ -28,7 +28,9 @@ class DbScoreTableModel(DbTableModel):
|
||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.id"),
|
||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.chart"),
|
||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.score"),
|
||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.potential"),
|
||||
QCoreApplication.translate(
|
||||
"DbScoreTableModel", "horizontalHeader.potential"
|
||||
),
|
||||
# fmt: on
|
||||
]
|
||||
|
||||
@ -154,7 +156,7 @@ class DbScoreTableModel(DbTableModel):
|
||||
self.syncDb()
|
||||
return True
|
||||
except Exception:
|
||||
logger.exception(f"Table[Score]: Cannot remove row {row}")
|
||||
logger.exception("Table[Score]: Cannot remove row %s", row)
|
||||
return False
|
||||
|
||||
def removeRow(self, row: int, parent=...):
|
||||
|
@ -6,10 +6,10 @@ from arcaea_offline_ocr.b30.chieri.v4.ocr import ChieriBotV4Ocr
|
||||
from arcaea_offline_ocr.b30.shared import B30OcrResultItem
|
||||
from PySide6.QtGui import QImage
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from ui.extends.components.ocrQueue import OcrRunnable
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ChieriV4OcrRunnable(OcrRunnable):
|
||||
def __init__(self, ocr: ChieriBotV4Ocr, component):
|
||||
|
@ -41,7 +41,7 @@ class AndrealExecuteRunnable(QRunnable):
|
||||
self.signals.completed.emit(self.jsonPath, imageBytes)
|
||||
except Exception as e:
|
||||
imageBytes = None
|
||||
logger.exception(f"{self.__class__.__name__} error")
|
||||
logger.exception("%s error", self.__class__.__name__)
|
||||
self.signals.error.emit(self.jsonPath, str(e))
|
||||
finally:
|
||||
os.unlink(self.jsonPath)
|
||||
@ -84,7 +84,10 @@ class AndrealHelper(QObject):
|
||||
|
||||
def request(self, jsonPath: str, arguments: list[str]):
|
||||
logger.debug(
|
||||
f"{self.__class__.__name__} received request {jsonPath=} {arguments=}"
|
||||
"%s received request jsonPath=%r arguments=%r",
|
||||
self.__class__.__name__,
|
||||
jsonPath,
|
||||
arguments,
|
||||
)
|
||||
runnable = AndrealExecuteRunnable(self.andrealExecutable, jsonPath, arguments)
|
||||
runnable.signals.error.connect(self.error)
|
||||
|
@ -126,7 +126,7 @@ class RatingClassSelector(QWidget):
|
||||
elif ratingClass in range(len(self.buttons)):
|
||||
button = self.buttons[ratingClass]
|
||||
else:
|
||||
logger.debug(f"Cannot select {ratingClass=}, condition check failed")
|
||||
logger.debug("Cannot select ratingClass=%s, condition check failed", ratingClass)
|
||||
return
|
||||
|
||||
if not button.isEnabled():
|
||||
|
@ -192,7 +192,7 @@ class SongIdSelector(Ui_SongIdSelector, QWidget):
|
||||
self.fillSongIdComboBox()
|
||||
return True
|
||||
else:
|
||||
logger.warning(f'Attempting to select an unknown pack "{packId}"')
|
||||
logger.warning("Attempting to select an unknown pack [%s]", packId)
|
||||
return False
|
||||
|
||||
def selectSongId(self, songId: str) -> bool:
|
||||
@ -202,7 +202,8 @@ class SongIdSelector(Ui_SongIdSelector, QWidget):
|
||||
return True
|
||||
else:
|
||||
logger.warning(
|
||||
f'Attempting to select an unknown song "{songId}", maybe try selecting a pack first?'
|
||||
"Attempting to select an unknown song [%s], maybe try selecting a pack first?",
|
||||
songId,
|
||||
)
|
||||
return False
|
||||
|
||||
|
@ -91,7 +91,7 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
||||
session.commit()
|
||||
databaseUpdateSignals.songAddOrDelete.emit()
|
||||
itemNum = len([item for item in parser.parse() if isinstance(item, instance)])
|
||||
logger.info(f"updated {itemNum} {logName} from {path}")
|
||||
logger.info("updated %d %s from %s", itemNum, logName, path)
|
||||
return itemNum
|
||||
|
||||
def importPacklist(self, packlistPath):
|
||||
@ -161,7 +161,7 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
||||
return
|
||||
|
||||
try:
|
||||
logger.info(f"Importing {apkFile}")
|
||||
logger.info("Importing %s", apkFile)
|
||||
|
||||
with zipfile.ZipFile(apkFile) as zf:
|
||||
packlistPath = zipfile.Path(zf) / "assets" / "songs" / "packlist"
|
||||
@ -193,7 +193,9 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
||||
db = Database()
|
||||
parser = St3ScoreParser(dbFile)
|
||||
logger.info(
|
||||
f"Got {len(parser.parse())} items from {dbFile}, writing into database..."
|
||||
"Got %d items from %s, writing into database...",
|
||||
len(parser.parse()),
|
||||
dbFile,
|
||||
)
|
||||
with db.sessionmaker() as session:
|
||||
parser.write_database(session)
|
||||
@ -218,7 +220,9 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
||||
db = Database()
|
||||
parser = ArcaeaOnlineParser(apiResultFile)
|
||||
logger.info(
|
||||
f"Got {len(parser.parse())} items from {apiResultFile}, writing into database..."
|
||||
"Got %d items from %s, writing into database...",
|
||||
len(parser.parse()),
|
||||
apiResultFile,
|
||||
)
|
||||
with db.sessionmaker() as session:
|
||||
parser.write_database(session)
|
||||
|
Loading…
x
Reference in New Issue
Block a user