Skip to content

Commit

Permalink
no console window
Browse files Browse the repository at this point in the history
  • Loading branch information
Tusky committed Aug 10, 2018
1 parent ea6ca0d commit bf38e32
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
11 changes: 9 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import time
from typing import TYPE_CHECKING

from api.discord_presence import DiscordPresence
from api.kodi import Kodi
from util.config import Configurations
from util.system_tray import SysTray

running = True
if TYPE_CHECKING:
pass


class App:
play_icon = '\u25B6'
pause_icon = '\u275A\u275A'
running = True
update_rate = 1

def __init__(self, configuration):
self._config = configuration
Expand Down Expand Up @@ -60,12 +64,15 @@ def run(self):
discord = DiscordPresence(self._config.client_id)
kodi = self.get_kodi_connection()
while self.running:
time.sleep(1) # update every second (no reason to update faster)
time.sleep(self.update_rate)
if self.update_rate > 1:
kodi = self.get_kodi_connection() # refresh settings, since it was put on timeout
kodi_info = kodi.get_currently_playing_item()
if not kodi_info['failed_connection']:
self.update_rate = 1
self.update_discord(discord, kodi_info)
else:
kodi = self.get_kodi_connection() # check maybe settings changed meanwhile
self.update_rate = 30


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

# base = 'Win32GUI'
base = None
base = 'Win32GUI'

executables = [Executable('app.py', base=base, icon='kodi-icon.ico', targetName="KoDiscord.exe")]

Expand Down
6 changes: 6 additions & 0 deletions util/error_handling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import logging

logging.basicConfig(filename='KoDiscord.log', level=logging.INFO)


class ErrorHandler:
def __init__(self, message):
self.message = message
logging.info(message)
print(message)

0 comments on commit bf38e32

Please sign in to comment.