Last active
August 30, 2018 13:37
-
-
Save papr/87c4ab1f3b533510c4585fee6c8dd430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
(*)~---------------------------------------------------------------------------------- | |
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