From 36ca1b126f0f611fac20e7500e40fe1265c8ab03 Mon Sep 17 00:00:00 2001 From: Allen Wittenauer Date: Thu, 2 Mar 2023 10:25:46 -0800 Subject: [PATCH] Fix fresh installs and add some logging (#694) --- CHANGELOG.md | 7 +++++++ nowplaying/__main__.py | 6 ++++-- nowplaying/processes/trackpoll.py | 3 +++ nowplaying/settingsui.py | 22 +++++++++++++--------- nowplaying/systemtray.py | 19 +++++++++++++++---- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de4ff51d..23bb3ba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog +## Version 4.0.1 - 2023-03-02 + +* Do not crash if a Native Instruments directory exists + without a Traktor installation. +* Log the platform in the debug log. +* Make the installer actually install. + ## Version 4.0.0 - 2023-02-27 ### Major Changes diff --git a/nowplaying/__main__.py b/nowplaying/__main__.py index fab470b7..0cf9c5cf 100755 --- a/nowplaying/__main__.py +++ b/nowplaying/__main__.py @@ -3,6 +3,7 @@ #import faulthandler import logging import multiprocessing +import platform import socket import sys @@ -31,8 +32,9 @@ def run_bootstrap(bundledir=None): # point this should be configurable but this is good enough for now socket.setdefaulttimeout(5.0) logpath = nowplaying.bootstrap.setuplogging(rotate=True) - logging.info('starting up v%s', - nowplaying.version.get_versions()['version']) + plat = platform.platform() + logging.info('starting up v%s on %s', + nowplaying.version.get_versions()['version'], plat) nowplaying.upgrade.upgrade(bundledir=bundledir) logging.debug('ending upgrade') diff --git a/nowplaying/processes/trackpoll.py b/nowplaying/processes/trackpoll.py index 67264608..192f0148 100755 --- a/nowplaying/processes/trackpoll.py +++ b/nowplaying/processes/trackpoll.py @@ -113,6 +113,9 @@ async def run(self): threading.current_thread().name = 'TrackPoll' socket.setdefaulttimeout(5.0) + if not self.config.cparser.value('settings/input', defaultValue=None): + logging.debug('Waiting for user to configure source input.') + # sleep until we have something to do while not self.stopevent.is_set() and not self.config.getpause( ) and not self.config.cparser.value('settings/input', diff --git a/nowplaying/settingsui.py b/nowplaying/settingsui.py index 82480407..a2425eed 100755 --- a/nowplaying/settingsui.py +++ b/nowplaying/settingsui.py @@ -47,17 +47,19 @@ def __init__(self, tray, beam): } self.uihelp = None - - def post_tray_init(self): - ''' after the systemtray is fully loaded, do this ''' - self.load_qtui() - if not self.config.iconfile: self.tray.cleanquit() self.qtui.setWindowIcon(QIcon(str(self.config.iconfile))) - self.settingsclasses['twitchchat'].update_twitchbot_commands( - self.config) + + def post_tray_init(self): + ''' after the systemtray is fully loaded, do this ''' + + # if system hasn't been initialized, then + # twitch chat files are irrelevant + if self.config.initialized: + self.settingsclasses['twitchchat'].update_twitchbot_commands( + self.config) def load_qtui(self): # pylint: disable=too-many-branches, too-many-statements ''' load the base UI and wire it up ''' @@ -739,7 +741,9 @@ def on_cancel_button(self): self.upd_win() self.qtui.close() - if not self.config.cparser.value('settings/input', defaultValue=None): + if not self.config.cparser.value( + 'settings/input', + defaultValue=None) or not self.config.initialized: self.tray.cleanquit() @Slot() @@ -792,7 +796,7 @@ def on_save_button(self): self.tray.action_pause.setEnabled(True) def show(self): - ''' show the system tram ''' + ''' show the system tray ''' if self.tray: self.tray.settings_action.setEnabled(False) self.upd_win() diff --git a/nowplaying/systemtray.py b/nowplaying/systemtray.py index e07bfb77..7d24bd51 100755 --- a/nowplaying/systemtray.py +++ b/nowplaying/systemtray.py @@ -3,7 +3,8 @@ import logging -from PySide6.QtWidgets import QApplication, QErrorMessage, QMenu, QMessageBox, QSystemTrayIcon # pylint: disable=no-name-in-module +from PySide6.QtWidgets import ( # pylint: disable=no-name-in-module + QApplication, QErrorMessage, QMenu, QMessageBox, QSystemTrayIcon) from PySide6.QtGui import QAction, QActionGroup, QIcon # pylint: disable=no-name-in-module from PySide6.QtCore import QFileSystemWatcher # pylint: disable=no-name-in-module @@ -237,6 +238,11 @@ def cleanquit(self): self.subprocesses.stop_all_processes() + self.config.get() + if not self.config.initialized: + self.config.cparser.clear() + self.config.cparser.sync() + app = QApplication.instance() logging.info('shutting qapp down v%s', nowplaying.version.get_versions()['version']) @@ -245,15 +251,14 @@ def cleanquit(self): def installer(self): ''' make some guesses as to what the user needs ''' plugin = self.config.cparser.value('settings/input', defaultValue=None) - if not self.config.validate_source(plugin): + if plugin and not self.config.validate_source(plugin): self.config.cparser.remove('settings/input') msgbox = QErrorMessage() msgbox.showMessage( f'Configured source {plugin} is not supported. Reconfiguring.') msgbox.show() msgbox.exec() - elif not self.config.cparser.value('settings/input', - defaultValue=None): + elif not plugin: msgbox = QMessageBox() msgbox.setText('New installation! Thanks! ' 'Determining setup. This operation may take a bit!') @@ -266,7 +271,13 @@ def installer(self): for plugin in plugins: if plugins[plugin].install(): + self.config.cparser.setValue('settings/input', + plugin.split('.')[-1]) break + + twitchchatsettings = nowplaying.twitch.chat.TwitchChatSettings() + twitchchatsettings.update_twitchbot_commands(self.config) + msgbox = QMessageBox() msgbox.setText('Basic configuration hopefully in place. ' 'Please verify the Source and configure an output!')