Skip to content

Instantly share code, notes, and snippets.

@papr
Last active August 30, 2018 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papr/87c4ab1f3b533510c4585fee6c8dd430 to your computer and use it in GitHub Desktop.
Save papr/87c4ab1f3b533510c4585fee6c8dd430 to your computer and use it in GitHub Desktop.
'''
(*)~----------------------------------------------------------------------------------
Pupil Helpers
Copyright (C) 2012-2016 Pupil Labs
Distributed under the terms of the GNU Lesser General Public License (LGPL v3.0).
License details are in the file license.txt, distributed as part of this software.
----------------------------------------------------------------------------------~(*)
'''
import logging
from time import time
from plugin import Plugin
logger = logging.getLogger(__name__)
class Unix_Time_Sync(Plugin):
def __init__(self, g_pool):
super().__init__(g_pool)
if self.ok_to_change():
difference = self.g_pool.get_now() - time()
self.g_pool.timebase.value = difference
logger.info("Synced Pupil time to Unix time")
else:
logger.error(
"Request to change timebase during recording ignored."
" Turn off recording first and try again."
)
self.alive = False
def ok_to_change(self):
for p in self.g_pool.plugins:
if p.class_name == "Recorder":
if p.running:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment