clockify actions moved into clockify module

This commit is contained in:
Jakub Trllo 2019-04-19 21:36:29 +02:00
parent aafd55bd22
commit cc205f35dc
5 changed files with 34 additions and 21 deletions

View file

@ -35,6 +35,28 @@ class ClockifyModule:
self.set_menu_visibility()
def process_modules(self, modules):
if 'FtrackModule' in modules:
actions_path = os.path.sep.join([
os.path.dirname(__file__),
'ftrack_actions'
])
current = os.environ('FTRACK_ACTIONS_PATH', '')
if current:
current += os.pathsep
os.environ['FTRACK_ACTIONS_PATH'] = current + actions_path
if 'AvalonApps' in modules:
from launcher import lib
actions_path = os.path.sep.join([
os.path.dirname(__file__),
'launcher_actions'
])
current = os.environ.get('AVALON_ACTIONS', '')
if current:
current += os.pathsep
os.environ['AVALON_ACTIONS'] = current + actions_path
def start_timer_check(self):
self.bool_thread_check_running = True
if self.thread_timer_check is None:

View file

@ -17,7 +17,9 @@ class StartClockify(BaseAction):
#: Action description.
description = 'Starts timer on clockify'
#: roles that are allowed to register this action
icon = 'https://clockify.me/assets/images/clockify-logo.png'
icon = '{}/app_icons/clockify.png'.format(
os.environ.get('PYPE_STATICS_SERVER', '')
)
#: Clockify api
clockapi = ClockifyAPI()

View file

@ -21,7 +21,9 @@ class SyncClocify(BaseAction):
#: roles that are allowed to register this action
role_list = ['Pypeclub', 'Administrator']
#: icon
icon = 'https://clockify.me/assets/images/clockify-logo-white.svg'
icon = '{}/app_icons/clockify-white.png'.format(
os.environ.get('PYPE_STATICS_SERVER', '')
)
#: CLockifyApi
clockapi = ClockifyAPI()

View file

@ -1,9 +1,7 @@
from avalon import api, io
from pype.api import Logger
try:
from pype.clockify import ClockifyAPI
except Exception:
pass
from pype.clockify import ClockifyAPI
log = Logger().get_logger(__name__, "clockify_start")
@ -14,13 +12,10 @@ class ClockifyStart(api.Action):
label = "Clockify - Start Timer"
icon = "clockify_icon"
order = 500
exec("try: clockapi = ClockifyAPI()\nexcept: clockapi = None")
clockapi = ClockifyAPI()
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

View file

@ -1,8 +1,5 @@
from avalon import api, io
try:
from pype.clockify import ClockifyAPI
except Exception:
pass
from pype.clockify import ClockifyAPI
from pype.api import Logger
log = Logger().get_logger(__name__, "clockify_sync")
@ -13,16 +10,11 @@ class ClockifySync(api.Action):
label = "Sync to Clockify"
icon = "clockify_white_icon"
order = 500
exec(
"try:\n\tclockapi = ClockifyAPI()"
"\n\thave_permissions = clockapi.validate_workspace_perm()"
"\nexcept:\n\tclockapi = None"
)
clockapi = ClockifyAPI()
have_permissions = clockapi.validate_workspace_perm()
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):