Skip to content

Commit

Permalink
Merge pull request #168 from djotaku/6.2.1
Browse files Browse the repository at this point in the history
6.2.1 - a little code cleanup
  • Loading branch information
djotaku authored Aug 16, 2021
2 parents 513ee94 + 30aa2dc commit 0ccfaf7
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 27 deletions.
11 changes: 10 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#v6.w.2
#v6.2.1
## Release Notes
### User-Facing Changes
- A fix so that the font changes for the tracker window that are saved in preferences are applied upon startup..

### Developer-Facing or API Changes
- cleaned up some duplicate code in call_tracker.py
- cleaned up logging code

#v6.2
## Release Notes
### User-Facing Changes

Expand Down
4 changes: 2 additions & 2 deletions eldonationtracker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "6.2.0"
__version__ = "6.2.1"

base_api_url: str = "https://www.extra-life.org/api"
api_version_suffix: str = "?version=1.2"
api_version_suffix: str = "?version=1.2"
5 changes: 2 additions & 3 deletions eldonationtracker/api/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass, field
import logging
from rich import print # type ignore
from rich.logging import RichHandler # type ignore
from rich.logging import RichHandler # type ignore
import time

import eldonationtracker.utils.extralife_io
Expand All @@ -12,9 +12,8 @@
from eldonationtracker import base_api_url

# logging
LOG_FORMAT = '%(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, handlers=[RichHandler(markup=True, show_path=False)])
participant_log = logging.getLogger("Participant")
participant_log.setLevel(logging.INFO)


class Participant:
Expand Down
3 changes: 1 addition & 2 deletions eldonationtracker/api/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
from eldonationtracker.api import donation as donation

# logging
LOG_FORMAT = '%(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, handlers=[RichHandler(markup=True, show_path=False)])
team_log = logging.getLogger("Team:")
team_log.setLevel(logging.INFO)


class Team:
Expand Down
9 changes: 8 additions & 1 deletion eldonationtracker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
import signal
import sys
import time
import logging
from rich import print # type ignore
from rich.logging import RichHandler # type ignore

import eldonationtracker.api.participant as participant
import eldonationtracker.utils.extralife_io as extralife_io


def exit_triggered(a_signal, frame):
print("\nExiting...")
print("[green]\nExiting...[/green]")
sys.exit(0)


# logging
LOG_FORMAT = '%(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, handlers=[RichHandler(markup=True, show_path=False)])

if __name__ == '__main__':
signal.signal(signal.SIGINT, exit_triggered)
participant_conf = extralife_io.ParticipantConf()
Expand Down
8 changes: 8 additions & 0 deletions eldonationtracker/gui.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# type: ignore

"""Launch the GUI."""
import logging
from rich.logging import RichHandler # type ignore

import eldonationtracker.ui.call_main_gui as the_gui


# logging
LOG_FORMAT = '%(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, handlers=[RichHandler(markup=True, show_path=False)])


if __name__ == '__main__':
the_gui.main()
44 changes: 26 additions & 18 deletions eldonationtracker/ui/call_tracker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
"""A window that displays the last donation. Useful during streaming."""

import logging
from rich.logging import RichHandler # type ignore

from PyQt5.QtWidgets import QDialog, QGraphicsScene, QGraphicsPixmapItem
from PyQt5.QtCore import QUrl
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent # type: ignore
from PyQt5.QtGui import QFont, QColor

from eldonationtracker.ui.tracker import *

# logging
LOG_FORMAT = '%(name)s: %(message)s'
call_tracker_log = logging.getLogger("Call_Tracker")
call_tracker_log.setLevel(logging.INFO)


class MyForm(QDialog):
"""The class to hold the tracker window."""
Expand All @@ -32,6 +40,7 @@ def __init__(self, participant_conf, participant):
self.font.setPointSize(self.font_size)
self.font.setItalic(self.font_italic)
self.font.setWeight(self.font_bold)
self.ui.Donation_label.setFont(self.font)
if self.font_color_value:
self.font_color = QColor()
self.font_color.setRgb(self.font_color_value[0], self.font_color_value[1], self.font_color_value[2],
Expand All @@ -54,7 +63,7 @@ def __init__(self, participant_conf, participant):
# timer to update the main text
self.timer = QtCore.QTimer(self)
self.timer.setSingleShot(False)
self.timer.setInterval(20000) # milliseconds
self.timer.setInterval(15000) # milliseconds
self.timer.timeout.connect(self._load_and_unload)
self.timer.start()

Expand All @@ -68,14 +77,9 @@ def _load_sound(self):
self.donation_sound = QMediaContent(QUrl.fromLocalFile(sound_to_play))
self.donation_player.setMedia(self.donation_sound)

def load_and_unload_test(self):
"""Trigger the tracker functionality.
This causes the image and sound to load so that the
user can test to see how it's going to look on their OBS
or XSplit screen as well as to make sure they can hear
the sound. Called by ui.py.
"""
def _load_and_unload_helper(self):
"""Used both by the test code and the actual load and unload code."""
call_tracker_log.debug("The load and unload helper was called.")
self._load_image()
self._load_elements()
self._load_sound()
Expand All @@ -86,18 +90,22 @@ def load_and_unload_test(self):
unload_timer.timeout.connect(self._unload_elements)
unload_timer.start()

def load_and_unload_test(self):
"""Trigger the tracker functionality.
This causes the image and sound to load so that the
user can test to see how it's going to look on their OBS
or XSplit screen as well as to make sure they can hear
the sound. Called by ui.py.
"""
self._load_and_unload_helper()

def _load_and_unload(self):
self.folders = self.participant_conf.get_text_folder_only()
call_tracker_log.debug("Checking if there are new donations.")
if self.participant.new_donation:
self._load_image()
self._load_elements()
self._load_sound()
self.donation_player.play()
unload_timer = QtCore.QTimer(self)
unload_timer.setSingleShot(True)
unload_timer.setInterval(5000) # milliseconds
unload_timer.timeout.connect(self._unload_elements)
unload_timer.start()
call_tracker_log.debug("There WAS a new donation!!!")
self._load_and_unload_helper()

def _load_elements(self):
self.scene.addItem(self.item)
Expand Down

0 comments on commit 0ccfaf7

Please sign in to comment.