Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Event before the loading of the plugins. #277

Merged
merged 3 commits into from Oct 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions eg/Classes/AutostartItem.py
Expand Up @@ -20,6 +20,30 @@
import eg
from MacroItem import MacroItem
from TreeItem import HINT_MOVE_INSIDE, HINT_MOVE_AFTER
from datetime import datetime


class Time(object):
_datetime = None

def __init__(self):
self._datetime = datetime.now()

def __getattr__(self, item):
return getattr(self._datetime, item)

def __str__(self):
t_fmt = '%A, %B %d{}, %Y @ %H:%M:%S %p'
if 4 <= self.day <= 20 or 24 <= self.day <= 30:
t_fmt = t_fmt.format('th')
else:
t_fmt = t_fmt.format(
["st", "nd", "rd"][self.day % 10 - 1]
)
return self.strftime(t_fmt)

def __repr__(self):
return self.__str__()

class AutostartItem(MacroItem):
xmlTag = "Autostart"
Expand Down Expand Up @@ -69,6 +93,15 @@ def Enable(self, flag=True):
# never disable the Autostart item
pass

def Execute(self):
event = eg.EventGhostEvent(
prefix='EventGhost',
suffix='Startup',
payload=Time()
)
event.Execute()
MacroItem.Execute(self)

@eg.LogIt
@eg.AssertInActionThread
def UnloadPlugins(self):
Expand Down