|
|
@ -21,21 +21,22 @@ storage_path = config.get('General', 'storage_path')
|
|
|
|
class Timer:
|
|
|
|
class Timer:
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def schedule(cls, time, data):
|
|
|
|
def schedule(cls, time, data):
|
|
|
|
|
|
|
|
command = '/usr/bin/python3 {0} \'{1}\''.format(__file__, json.dumps(data))
|
|
|
|
|
|
|
|
env = ((k, v) for k, v in os.environ.items() if k.startswith('CHEDDAR_KNIGHT'))
|
|
|
|
subprocess.run((
|
|
|
|
subprocess.run((
|
|
|
|
|
|
|
|
'/usr/bin/sudo',
|
|
|
|
'/usr/bin/systemd-run',
|
|
|
|
'/usr/bin/systemd-run',
|
|
|
|
'--user',
|
|
|
|
'--uid=nobody', '--gid=nobody',
|
|
|
|
'--working-directory={0}'.format(pathlib.Path(__file__).parent),
|
|
|
|
*['--setenv={0}={1}'.format(k, v) for k, v in env],
|
|
|
|
'--timer-property=AccuracySec=1s',
|
|
|
|
'--timer-property=AccuracySec=1s',
|
|
|
|
'--on-calendar={0}'.format(time.strftime('%Y-%m-%d %H:%M:%S UTC')),
|
|
|
|
'--on-calendar={0}'.format(time.astimezone().strftime('%Y-%m-%d %H:%M:%S')),
|
|
|
|
'/usr/bin/python3',
|
|
|
|
'/bin/sh', '-c', 'cd {0} && {1}'.format(pathlib.Path(__file__).parent, command)
|
|
|
|
__file__,
|
|
|
|
|
|
|
|
json.dumps(data)
|
|
|
|
|
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def execute(cls, data):
|
|
|
|
def execute(cls, data):
|
|
|
|
queue = persistqueue.SQLiteQueue(storage_path)
|
|
|
|
queue = persistqueue.SQLiteQueue(storage_path)
|
|
|
|
queue.put(data)
|
|
|
|
queue.put(('youtube', data))
|
|
|
|
queue.task_done()
|
|
|
|
queue.task_done()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|