mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
added startclockify timer to launcher actions
This commit is contained in:
parent
cf0cebf42e
commit
2565b08542
1 changed files with 40 additions and 0 deletions
40
pype/plugins/launcher/actions/StartClockify.py
Normal file
40
pype/plugins/launcher/actions/StartClockify.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
from avalon import api, io
|
||||
from pype.clockify import ClockifyAPI
|
||||
from pype.api import Logger
|
||||
log = Logger.getLogger(__name__, "start_clockify")
|
||||
|
||||
|
||||
class StartClockify(api.Action):
|
||||
|
||||
name = "start_clockify_timer"
|
||||
label = "Start Timer - Clockify"
|
||||
icon = "clockify_icon"
|
||||
order = 500
|
||||
|
||||
def is_compatible(self, session):
|
||||
"""Return whether the action is compatible with the session"""
|
||||
if "AVALON_TASK" in session:
|
||||
return True
|
||||
return False
|
||||
|
||||
def process(self, session, **kwargs):
|
||||
clockapi = ClockifyAPI()
|
||||
project_name = session['AVALON_PROJECT']
|
||||
asset_name = session['AVALON_ASSET']
|
||||
task_name = session['AVALON_TASK']
|
||||
|
||||
description = asset_name
|
||||
asset = io.find_one({
|
||||
'type': 'asset',
|
||||
'name': asset_name
|
||||
})
|
||||
if asset is not None:
|
||||
desc_items = asset.get('data', {}).get('parents', [])
|
||||
desc_items.append(asset_name)
|
||||
description = '/'.join(desc_items)
|
||||
|
||||
clockapi.start_time_entry(
|
||||
description=description,
|
||||
project_name=project_name,
|
||||
task_name=task_name,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue