Ejemplo n.º 1
0
    def __init__(self, mainloop, callback, *args):
        """Creates an EyetrackerBrowser:
        
        Arguments:
           - mainloop: a Mainloop or MainloopThread to defer callbacks on
           - callback: the callable to use for events
           - *args: (optional) passed to the callback
        """
        _check_init()

        self._mainloop = None
        self._callback_args = args
        
        if not callable(callback):
            raise TypeError("callback must be callable")
        self._callback = callback
        self._callback_lock = threading.Lock()
        
        if mainloop is None:
            raise ValueError("EyetrackerBrowser requires the mainloop argument")
        
        if isinstance(mainloop, MainloopThread):
            self._mainloop = mainloop.mainloop
        elif isinstance(self._mainloop, Mainloop):
            self._mainloop = mainloop
        else:
            raise TypeError("EyetrackerBrowser requires the mainloop argument to be of type Mainloop or MainloopThread")
        
        self._device_browser = tetio.DeviceBrowser(self._mainloop.mainloop, self._on_device_event_handler)
Ejemplo n.º 2
0
def begin_upgrade(mainloop,
                  package_path,
                  device_info,
                  completed_handler,
                  progress_handler,
                  cancancel_handler):
    """
        Parameters:
            - mainloop: either a Mainloop or MainloopThread
            - package_path: path to a tobiipkg file
            - device_info: an EyetrackerInfo
            - completed_handler: will be called like this:
                    completed_handler(error_code)
            - progress_handler: will be called like this:
                    progress_handler(current_step, number_of_steps, step_percentage)
    """
    _check_init()
    
    _require_callable(completed_handler, optional=False, argument_name="completed_handler")
    _require_callable(progress_handler, optional=True, argument_name="progress_handler")
    _require_callable(cancancel_handler, optional=True, argument_name="cancancel_handler")
        
    package_bytes = _load_package_file(package_path)
    if len(package_bytes) == 0:
        raise ValueError("file '%s' was empty" % (package_path))
    
    tetio.upgrade_begin(_get_native_mainloop(mainloop),
                             package_bytes,
                             _get_native_device_info(device_info),
                             completed_handler,
                             progress_handler,
                             cancancel_handler)
Ejemplo n.º 3
0
def package_is_compatible_with_device(mainloop, package_path, device_info):
    _check_init()
    
    package_bytes = _load_package_file(package_path)    
    if len(package_bytes) == 0:
        raise ValueError("file '%s' was empty" % (package_path))
        
    return tetio.upgrade_package_is_compatible(_get_native_mainloop(mainloop),
                                                    package_bytes,
                                                    _get_native_device_info(device_info))
Ejemplo n.º 4
0
 def __init__(self, mainloop=None, delay_start=False):
     """Creates a new MainloopThread and either attaches an
     existing Mainloop to it or creates a new Mainloop.
     The argument delay_start (default: False) controls whether
     the thread should be started directly or not.
     """
     _check_init()
     
     if mainloop is None:
         self._mainloop = Mainloop()
     else:
         self._mainloop = mainloop
     
     self._thread = None
     if not delay_start:
         self.start()
Ejemplo n.º 5
0
    def __init__(self, mainloop=None, delay_start=False):
        """Creates a new MainloopThread and either attaches an
        existing Mainloop to it or creates a new Mainloop.
        The argument delay_start (default: False) controls whether
        the thread should be started directly or not.
        """
        _check_init()

        if mainloop is None:
            self._mainloop = Mainloop()
        else:
            self._mainloop = mainloop

        self._thread = None
        if not delay_start:
            self.start()
Ejemplo n.º 6
0
    def __init__(self, device_info):
        _check_init()

        self._device_info = device_info
Ejemplo n.º 7
0
 def __init__(self):
     _check_init()
     self.mainloop = tetio.Mainloop()
Ejemplo n.º 8
0
 def __init__(self):
     _check_init()
     self.mainloop = tetio.Mainloop()
    def __init__(self, device_info):
        _check_init()

        self._device_info = device_info