Skip to content

Commit

Permalink
Script/entrypoint refactor for Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesridgway committed Aug 29, 2021
1 parent 1a8441a commit e335cd2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion devdeck/devdeck.py → devdeck/deck_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from devdeck.deck_context import DeckContext


class DevDeck:
class DeckManager:
def __init__(self, deck):
self.__logger = logging.getLogger('devdeck')
self.__deck = deck
Expand Down
File renamed without changes.
Empty file removed devdeck/logging/__init__.py
Empty file.
14 changes: 7 additions & 7 deletions bin/devdeck → devdeck/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
import logging
import os
import sys
Expand All @@ -8,12 +7,13 @@

from StreamDeck.DeviceManager import DeviceManager

from devdeck.devdeck import DevDeck
from devdeck.logging.filters import InfoFilter
from devdeck.deck_manager import DeckManager
from devdeck.filters import InfoFilter
from devdeck.settings.devdeck_settings import DevDeckSettings
from devdeck.settings.validation_error import ValidationError

if __name__ == "__main__":

def main():
os.makedirs(os.path.join(str(Path.home()), '.devdeck'), exist_ok=True)

root = logging.getLogger('devdeck')
Expand Down Expand Up @@ -72,11 +72,11 @@
deck.close()
continue

dev_deck = DevDeck(deck)
deck_manager = DeckManager(deck)

# Instantiate deck
main_deck = deck_settings.deck_class()(None, **deck_settings.settings())
dev_deck.set_active_deck(main_deck)
deck_manager.set_active_deck(main_deck)

for t in threading.enumerate():
if t is threading.currentThread():
Expand All @@ -86,5 +86,5 @@
try:
t.join()
except KeyboardInterrupt as ex:
dev_deck.close()
deck_manager.close()
deck.close()
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def get_version():
url='https://github.com/jamesridgway/devdeck',
license='MIT',
packages=find_packages(),
scripts=['bin/devdeck'],
entry_points={
'console_scripts': [
'devdeck = devdeck.main:main'
]
},
install_requires=install_reqs,
include_package_data=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from assertpy import assert_that

from devdeck.devdeck import DevDeck
from devdeck.deck_manager import DeckManager


class TestDevDeck:
class TestDeckManager:
@mock.patch('StreamDeck.Devices.StreamDeck.StreamDeck')
@mock.patch('StreamDeck.Devices.StreamDeck.StreamDeck')
def test_set_active_deck(self, first_mock_deck, second_mock_deck):
dev_deck = DevDeck(first_mock_deck)
dev_deck = DeckManager(first_mock_deck)

assert_that(dev_deck.get_active_deck()).is_none()

Expand All @@ -25,7 +25,7 @@ def test_set_active_deck(self, first_mock_deck, second_mock_deck):
@mock.patch('StreamDeck.Devices.StreamDeck.StreamDeck')
@mock.patch('StreamDeck.Devices.StreamDeck.StreamDeck')
def test_pop_active_deck(self, first_mock_deck, second_mock_deck):
dev_deck = DevDeck(first_mock_deck)
dev_deck = DeckManager(first_mock_deck)

# Two active decks and the second is active
dev_deck.set_active_deck(first_mock_deck)
Expand All @@ -38,7 +38,7 @@ def test_pop_active_deck(self, first_mock_deck, second_mock_deck):

@mock.patch('StreamDeck.Devices.StreamDeck.StreamDeck')
def test_pop_active_deck_does_not_remove_root_deck(self, first_mock_deck):
dev_deck = DevDeck(first_mock_deck)
dev_deck = DeckManager(first_mock_deck)
dev_deck.set_active_deck(first_mock_deck)
assert_that(dev_deck.get_active_deck()).is_equal_to(first_mock_deck)

Expand All @@ -48,7 +48,7 @@ def test_pop_active_deck_does_not_remove_root_deck(self, first_mock_deck):

@mock.patch('StreamDeck.Devices.StreamDeck.StreamDeck')
def test_key_callback_propogates_to_active_deck(self, first_mock_deck):
dev_deck = DevDeck(first_mock_deck)
dev_deck = DeckManager(first_mock_deck)
dev_deck.set_active_deck(first_mock_deck)

# Pressed
Expand Down

0 comments on commit e335cd2

Please sign in to comment.