Skip to content

Commit

Permalink
Fix fresh installs and add some logging (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
aw-was-here authored Mar 2, 2023
1 parent f71c383 commit 36ca1b1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions nowplaying/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import faulthandler
import logging
import multiprocessing
import platform
import socket
import sys

Expand Down Expand Up @@ -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')

Expand Down
3 changes: 3 additions & 0 deletions nowplaying/processes/trackpoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
22 changes: 13 additions & 9 deletions nowplaying/settingsui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '''
Expand Down Expand 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()
Expand Down Expand Up @@ -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()
Expand Down
19 changes: 15 additions & 4 deletions nowplaying/systemtray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'])
Expand All @@ -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!')
Expand All @@ -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!')
Expand Down

0 comments on commit 36ca1b1

Please sign in to comment.