mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
added thread that check each 5 seconds if any timer is running
This commit is contained in:
parent
40c2ccd9d7
commit
463c574e88
1 changed files with 28 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import threading
|
||||
from app import style
|
||||
from app.vendor.Qt import QtWidgets
|
||||
from pype.clockify import ClockifySettings, ClockifyAPI
|
||||
|
|
@ -12,7 +13,9 @@ class ClockifyModule:
|
|||
self.clockapi = ClockifyAPI()
|
||||
self.widget_settings = ClockifySettings(main_parent, self)
|
||||
|
||||
self.thread_timer_check = None
|
||||
# Bools
|
||||
self.bool_thread_check_running = False
|
||||
self.bool_api_key_set = False
|
||||
self.bool_workspace_set = False
|
||||
self.bool_timer_run = False
|
||||
|
|
@ -24,17 +27,39 @@ class ClockifyModule:
|
|||
return
|
||||
|
||||
workspace = os.environ.get('CLOCKIFY_WORKSPACE', None)
|
||||
print(workspace)
|
||||
self.bool_workspace_set = self.clockapi.set_workspace(workspace)
|
||||
if self.bool_workspace_set is False:
|
||||
# TODO show message to user
|
||||
print("Nope Workspace: clockify.py - line 29")
|
||||
return
|
||||
if self.clockapi.get_in_progress() is not None:
|
||||
self.bool_timer_run = True
|
||||
|
||||
self.bool_thread_check_running = True
|
||||
self.start_timer_check()
|
||||
|
||||
self.set_menu_visibility()
|
||||
|
||||
def change_timer_run(self, bool_run):
|
||||
self.bool_timer_run = bool_run
|
||||
self.set_menu_visibility()
|
||||
|
||||
def start_timer_check(self):
|
||||
if self.thread_timer_check is None:
|
||||
self.thread_timer_check = threading.Thread(
|
||||
target=self.check_running
|
||||
)
|
||||
self.thread_timer_check.daemon = True
|
||||
self.thread_timer_check.start()
|
||||
|
||||
def check_running(self):
|
||||
import time
|
||||
while self.bool_thread_check_running is True:
|
||||
if self.clockapi.get_in_progress() is not None:
|
||||
self.bool_timer_run = True
|
||||
else:
|
||||
self.bool_timer_run = False
|
||||
self.set_menu_visibility()
|
||||
time.sleep(5)
|
||||
|
||||
def stop_timer(self):
|
||||
self.clockapi.finish_time_entry()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue