mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 13:24:54 +01:00
clockify actions try to import Clockify API and won't crash if not successful
This commit is contained in:
parent
b8766ca3e1
commit
34a915a063
2 changed files with 20 additions and 5 deletions
|
|
@ -1,6 +1,10 @@
|
|||
from avalon import api, io
|
||||
from pype.clockify import ClockifyAPI
|
||||
from pype.api import Logger
|
||||
try:
|
||||
from pype.clockify import ClockifyAPI
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
log = Logger.getLogger(__name__, "clockify_start")
|
||||
|
||||
|
||||
|
|
@ -10,10 +14,13 @@ class ClockifyStart(api.Action):
|
|||
label = "Clockify - Start Timer"
|
||||
icon = "clockify_icon"
|
||||
order = 500
|
||||
clockapi = ClockifyAPI()
|
||||
|
||||
exec("try: clockapi = ClockifyAPI()\nexcept: clockapi = None")
|
||||
|
||||
def is_compatible(self, session):
|
||||
"""Return whether the action is compatible with the session"""
|
||||
if self.clockapi is None:
|
||||
return False
|
||||
if "AVALON_TASK" in session:
|
||||
return True
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
from avalon import api, io
|
||||
from pype.clockify import ClockifyAPI
|
||||
try:
|
||||
from pype.clockify import ClockifyAPI
|
||||
except Exception:
|
||||
pass
|
||||
from pype.api import Logger
|
||||
log = Logger.getLogger(__name__, "clockify_sync")
|
||||
|
||||
|
|
@ -10,11 +13,16 @@ class ClockifySync(api.Action):
|
|||
label = "Sync to Clockify"
|
||||
icon = "clockify_white_icon"
|
||||
order = 500
|
||||
clockapi = ClockifyAPI()
|
||||
have_permissions = clockapi.validate_workspace_perm()
|
||||
exec(
|
||||
"try:\n\tclockapi = ClockifyAPI()"
|
||||
"\n\thave_permissions = clockapi.validate_workspace_perm()"
|
||||
"\nexcept:\n\tclockapi = None"
|
||||
)
|
||||
|
||||
def is_compatible(self, session):
|
||||
"""Return whether the action is compatible with the session"""
|
||||
if self.clockapi is None:
|
||||
return False
|
||||
return self.have_permissions
|
||||
|
||||
def process(self, session, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue