logging to Updater added

This commit is contained in:
Dominik Demuth 2023-01-20 18:25:29 +01:00
parent aa33706f5b
commit bc14b26a5f
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
from __future__ import annotations from __future__ import annotations
import sys
from functools import lru_cache from functools import lru_cache
from os import getenv, stat from os import getenv, stat
from os.path import exists from os.path import exists
@ -13,6 +14,8 @@ import requests
from numpy import linspace from numpy import linspace
from scipy.interpolate import interp1d from scipy.interpolate import interp1d
from nmreval.lib.logger import logger
from ..Qt import QtGui, QtWidgets, QtCore from ..Qt import QtGui, QtWidgets, QtCore
@ -109,6 +112,7 @@ class UpdateDialog(QtWidgets.QDialog):
self.setLayout(layout) self.setLayout(layout)
def look_for_updates(self, filename=None): def look_for_updates(self, filename=None):
logger.info(f'Looking for updates, compare to file {filename}')
# Download zsync file of latest Appimage, look for SHA-1 hash and compare with hash of AppImage # Download zsync file of latest Appimage, look for SHA-1 hash and compare with hash of AppImage
is_updateble, m_time_file, m_time_zsync = self.updater.get_update_information(filename) is_updateble, m_time_file, m_time_zsync = self.updater.get_update_information(filename)
@ -193,6 +197,7 @@ class Downloader(QtCore.QObject):
@QtCore.pyqtSlot(list) @QtCore.pyqtSlot(list)
def run_download(self, args: list[str]): def run_download(self, args: list[str]):
logger.info(f'Download with args {args}')
process = subprocess.Popen(['zsync'] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, universal_newlines=True) process = subprocess.Popen(['zsync'] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, universal_newlines=True)
while True: while True:
nextline = process.stdout.readline().strip() nextline = process.stdout.readline().strip()
@ -268,6 +273,9 @@ class Updater:
m_time_zsync, checksum_zsync, appname = Updater.get_zsync() m_time_zsync, checksum_zsync, appname = Updater.get_zsync()
m_time_file, checksum_file = Updater.get_appimage_info(filename) m_time_file, checksum_file = Updater.get_appimage_info(filename)
logger.info(f'zsync information {m_time_zsync}, {checksum_zsync}, {appname}')
logger.info(f'file information {m_time_file}, {checksum_zsync}')
if not ((checksum_file is not None) and (checksum_zsync is not None)): if not ((checksum_file is not None) and (checksum_zsync is not None)):
return None, m_time_file, m_time_zsync return None, m_time_file, m_time_zsync
else: else:

View File

@ -7,7 +7,7 @@ ERROR_LOG = config_paths() / 'errors.log'
# initialize logger stuff # initialize logger stuff
FORMAT = '%(asctime)s - %(levelname)s - %(name)s : %(message)s' FORMAT = '%(asctime)s - %(levelname)s - %(name)s : %(message)s'
DATEFMT = '%d/%m/%Y %H:%M:%S' DATEFMT = '%d/%m/%Y %H:%M:%S'
LEVEL = logging.ERROR LEVEL = logging.INFO
myformatter = logging.Formatter(fmt=FORMAT, datefmt=DATEFMT) myformatter = logging.Formatter(fmt=FORMAT, datefmt=DATEFMT)
logging.basicConfig(level=LEVEL, format=FORMAT, datefmt=DATEFMT) logging.basicConfig(level=LEVEL, format=FORMAT, datefmt=DATEFMT)