コード例 #1
0
class NotificationHandler(object):
    def __init__(self):
        self.adx_inv_manager= DeviceManager()

    def info(self, ctxt, publisher_id, event_type, payload, metadata):
        LOG.info(event_type)
        if str(event_type).startswith("compute.instance"):
            #LOG.info("RECEIVED MESSAGE: %r" % (payload, ))
            image_url=str(payload['image_ref_url'])

            vadx_image_id = CONFIG.get("DEFAULT", "vadx_image_ids")
            if vadx_image_id in image_url:
                LOG.info("vadx instance notification received ")
                LOG.info("RECEIVED MESSAGE: %r" % (payload, ))
                self.adx_inv_manager.process_notification(event_type,payload)
                return
            else:
                LOG.info("Notification is not for vadx")
        else:
            #LOG.info("RECEIVED MESSAGE: %r" % (payload, ))
            pass
            

    def warn(self, ctxt, publisher_id, event_type, payload, metadata):
        pass

    def error(self, ctxt, publisher_id, event_type, payload, metadata):
        pass

    def debug(self, ctx, publisher_id, event_type, payload, metadata):
        pass
コード例 #2
0
ファイル: card_dump.py プロジェクト: jazzu/CardDump
def udev_event_callback(action, device):
    global copy_thread, message_q
    if not copy_thread:
        copy_thread = DeviceManager(kwargs={
            'return_q': message_q,
            'action': action,
            'device': device
        })
        copy_thread.start()
コード例 #3
0
def sigterm_handler():
    global _amqp_client

    DeviceManager.destroy_instance()
    DeviceZtpManager.destroy_instance()
    DeviceJobManager.destroy_instance()

    if _amqp_client is not None:
        _amqp_client.stop()
コード例 #4
0
def sigterm_handler():
    global _amqp_client

    DeviceManager.destroy_instance()
    DeviceZtpManager.destroy_instance()
    DeviceJobManager.destroy_instance()

    if _amqp_client is not None:
        _amqp_client.stop()
コード例 #5
0
def init():
    global s_channel
    global s_stub
    global s_device_manager

    start_perfdog_service(PERFDOG_SERVICE_PATH)
    s_channel = grpc.insecure_channel(
        '%s:%s' % (PERFDOG_SERVICE_IP, PERFDOG_SERVICE_PORT),
        options=[('grpc.max_receive_message_length', 100 * 1024 * 1024)])
    s_stub = perfdog_pb2_grpc.PerfDogServiceStub(s_channel)
    s_stub.loginWithToken(perfdog_pb2.Token(token=PERFDOG_SERVICE_TOKEN))

    s_device_manager = DeviceManager(s_stub)
    s_device_manager.start()
コード例 #6
0
class DeviceServiceTestCase(unittest.TestCase):
    def setUp(self):
        self.device_manager = DeviceManager()

    def test_get_connected_devices(self):
        devices = self.device_manager.get_connected_devices()
        print("devices", devices)
        self.assertIsNotNone(devices)
        self.assertTrue(len(devices) > 0)

    def test_listener(self):
        listener = DeviceChangeListener()
        self.device_manager.register_device_change_listener(listener)
        while True:
            pass
コード例 #7
0
 def __init__(self, config_file_directory):
     self.config_file_directory = config_file_directory
     self.update_config()
     if self.config["board_type"] == "raspberry_pi":
         import RPi.GPIO as GPIO
         GPIO.setmode(GPIO.BOARD)
     self.device_manager = DeviceManager(self.config["devices"],
                                         self.config["board_type"],
                                         self.device_manager_callback)
     self.communication_manager = CommunicationManager(
         self.config["communication_protocols"],
         self.communication_manager_send_callback,
         self.communication_manager_receive_callback)
     time.sleep(5)
     self.device_manager.read_all()
コード例 #8
0
 def device_send(self, job_template, job_input, is_delete, retry):
     config_str = json.dumps(job_input, sort_keys=True)
     self.push_config_state = PushConfigState.PUSH_STATE_IN_PROGRESS
     start_time = None
     config_size = 0
     forced_cfg_push = self.physical_router.forced_cfg_push
     try:
         config_size = len(config_str)
         current_config_hash = md5(config_str).hexdigest()
         if self.last_config_hash is None or (
                 current_config_hash != self.last_config_hash
                 or forced_cfg_push):
             self._logger.info(
                 "Config push for %s(%s) using job template %s, "
                 "forced_push %s" %
                 (self.physical_router.name, self.physical_router.uuid,
                  str(job_template), forced_cfg_push))
             self._logger.debug(
                 "Abstract config: %s" %
                 json.dumps(job_input, indent=4, sort_keys=True))
             device_manager = DeviceManager.get_instance()
             job_handler = JobHandler(
                 job_template, job_input, [self.physical_router.uuid],
                 device_manager.get_api_server_config(), self._logger,
                 device_manager._amqp_client,
                 self.physical_router.transaction_id,
                 self.physical_router.transaction_descr,
                 device_manager._args)
             self.commit_stats['total_commits_sent_since_up'] += 1
             start_time = time.time()
             job_handler.push(**device_manager.get_job_status_config())
             end_time = time.time()
             self.commit_stats['commit_status_message'] = 'success'
             self.commit_stats['last_commit_time'] = \
                 datetime.datetime.fromtimestamp(
                 end_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(end_time -
                                                             start_time)
             self.last_config_hash = current_config_hash
         else:
             self._logger.debug("not pushing since no config change"
                                " detected")
         self.push_config_state = PushConfigState.PUSH_STATE_SUCCESS
     except Exception as e:
         self._logger.error("Router %s: %s" %
                            (self.physical_router.management_ip, repr(e)))
         self._logger.error("Abstract config: %s" %
                            json.dumps(job_input, indent=4, sort_keys=True))
         self.commit_stats[
             'commit_status_message'] = 'failed to apply config,\
                                             router response: ' + e.message
         if start_time is not None:
             self.commit_stats['last_commit_time'] = \
                 datetime.datetime.fromtimestamp(
                 start_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(time.time() -
                                                             start_time)
         self.push_config_state = PushConfigState.PUSH_STATE_RETRY if retry\
             else PushConfigState.PUSH_STATE_FAILED
     return config_size
コード例 #9
0
class SystemManager:

    config_file_directory = None
    config = {}
    device_manager, communication_manager = None, None

    #Updates config according to config file

    def update_config(self):
        logging.info("Config updated")
        with open(self.config_file_directory) as config_file:
            self.config = json.loads(config_file.read())
            logging.debug("New config : " + json.dumps(self.config))

    def device_manager_callback(self, data):
        self.communication_manager.send_all(data)

    def communication_manager_send_callback(self):
        pass

    def communication_manager_receive_callback(self, data):
        pass

    def __init__(self, config_file_directory):
        self.config_file_directory = config_file_directory
        self.update_config()

        if self.config["board_type"] == "raspberry_pi":
            import RPi.GPIO as GPIO
            GPIO.setmode(GPIO.BOARD)

        self.device_manager = DeviceManager(self.config["devices"],
                                            self.config["board_type"],
                                            self.device_manager_callback)
        if self.device_manager.connected > 0:
            self.communication_manager = CommunicationManager(
                self.config["communication_protocols"],
                self.communication_manager_send_callback,
                self.communication_manager_receive_callback)
        else:
            print('no sensor initiated')
            exit()

        time.sleep(5)
        self.device_manager.read_all()
コード例 #10
0
 def device_send(self, job_template, job_input, is_delete, retry):
     config_str = json.dumps(job_input, sort_keys=True)
     self.push_config_state = PushConfigState.PUSH_STATE_IN_PROGRESS
     start_time = None
     config_size = 0
     try:
         config_size = len(config_str)
         current_config_hash = md5(config_str).hexdigest()
         if self.last_config_hash is None or\
                 current_config_hash != self.last_config_hash:
             self._logger.info("Config push for %s(%s) using job template %s" %
                       (self.physical_router.name, self.physical_router.uuid,
                        str(job_template)))
             self._logger.debug("Abstract config: %s" %
                                json.dumps(job_input, indent=4,
                                           sort_keys=True))
             device_manager = DeviceManager.get_instance()
             job_handler = JobHandler(job_template, job_input,
                                      None if is_delete else
                                      [self.physical_router.uuid],
                                      device_manager.get_api_server_config(),
                                      self._logger,
                                      device_manager._amqp_client,
                                      device_manager._args)
             self.commit_stats['total_commits_sent_since_up'] += 1
             start_time = time.time()
             job_handler.push(**device_manager.get_job_status_config())
             end_time = time.time()
             self.commit_stats['commit_status_message'] = 'success'
             self.commit_stats['last_commit_time'] = \
                     datetime.datetime.fromtimestamp(
                     end_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(
                     end_time - start_time)
             self.last_config_hash = current_config_hash
         else:
             self._logger.debug("not pushing since no config change"
                                " detected")
         self.push_config_state = PushConfigState.PUSH_STATE_SUCCESS
     except Exception as e:
         self._logger.error("Router %s: %s" %
                            (self.physical_router.management_ip, repr(e)))
         self._logger.error("Abstract config: %s" %
                            json.dumps(job_input, indent=4,
                                       sort_keys=True))
         self.commit_stats[
                 'commit_status_message'] = 'failed to apply config,\
                                             router response: ' + e.message
         if start_time is not None:
             self.commit_stats['last_commit_time'] = \
                     datetime.datetime.fromtimestamp(
                         start_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(
                     time.time() - start_time)
         self.push_config_state = PushConfigState.PUSH_STATE_RETRY if retry\
             else PushConfigState.PUSH_STATE_FAILED
     return config_size
コード例 #11
0
def run_device_manager(dm_logger, args):
    global _amqp_client
    global _zookeeper_client

    dm_logger.notice("Elected master Device Manager node. Initializing... ")
    dm_logger.introspect_init()
    DeviceZtpManager.get_instance().set_active()
    DeviceManager(dm_logger, args, _zookeeper_client, _amqp_client)
    if _amqp_client._consumer_gl is not None:
        gevent.joinall([_amqp_client._consumer_gl])
コード例 #12
0
 def device_send(self, job_template, job_input, is_delete, retry):
     config_str = json.dumps(job_input, sort_keys=True)
     self.push_config_state = PushConfigState.PUSH_STATE_IN_PROGRESS
     start_time = None
     config_size = 0
     try:
         config_size = len(config_str)
         current_config_hash = md5(config_str).hexdigest()
         if self.last_config_hash is None or\
                 current_config_hash != self.last_config_hash:
             self._logger.info("config push for %s(%s) using job template %s" %
                       (self.physical_router.name, self.physical_router.uuid,
                        str(job_template)))
             self._logger.debug("playbook send message: %s" %
                                json.dumps(job_input, indent=4,
                                           sort_keys=True))
             device_manager = DeviceManager.get_instance()
             job_handler = JobHandler(job_template, job_input,
                                      None if is_delete else
                                      [self.physical_router.uuid],
                                      device_manager.get_analytics_config(),
                                      device_manager.get_vnc(), self._logger)
             self.commit_stats['total_commits_sent_since_up'] += 1
             start_time = time.time()
             job_handler.push()
             end_time = time.time()
             self.commit_stats['commit_status_message'] = 'success'
             self.commit_stats['last_commit_time'] = \
                     datetime.datetime.fromtimestamp(
                     end_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(
                     end_time - start_time)
             self.last_config_hash = current_config_hash
         else:
             self._logger.debug("not pushing since no config change"
                                " detected")
         self.push_config_state = PushConfigState.PUSH_STATE_SUCCESS
     except Exception as e:
         self._logger.error("Router %s: %s" %
                            (self.physical_router.management_ip, e.message))
         self.commit_stats[
                 'commit_status_message'] = 'failed to apply config,\
                                             router response: ' + e.message
         if start_time is not None:
             self.commit_stats['last_commit_time'] = \
                     datetime.datetime.fromtimestamp(
                         start_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(
                     time.time() - start_time)
         self.push_config_state = PushConfigState.PUSH_STATE_RETRY if retry\
             else PushConfigState.PUSH_STATE_FAILED
     return config_size
コード例 #13
0
 def _get_cameras(self):
     dev_manager = DeviceManager()
     cams = []
     if not dev_manager.devices:
         return []
     for dev in dev_manager.devices:
         if dev is Undefined:
             continue
         if not hasattr(dev, 'provides'):
             continue
         if IOService.services_all(self.requires, dev.provides):
             cams.append(dev)
     return cams
コード例 #14
0
ファイル: scan_axes.py プロジェクト: jmosbacher/SRMControl
 def find_devices(self):
     dev_manager = DeviceManager()
     cntrlrs = []
     if not dev_manager.devices:
         return []
     for dev in dev_manager.devices:
         if dev is Undefined:
             continue
         if not hasattr(dev, 'controller'):
             continue
         if not hasattr(dev, 'provides'):
             continue
         if IOService.services_all(self.requires, dev.controller.provides):
             cntrlrs.append(dev.controller)
     return cntrlrs
コード例 #15
0
def main(_args) -> int:
    manager = DeviceManager()

    manager.register_device("coherent_pwr",
                            DummySwitch(COHERENT_PIN, "coherent_pwr"))
    manager.register_device("hercules_pwr",
                            DummySwitch(COHERENT_PIN, "hercules_pwr"))

    # Don't register board, its an internal device
    board = DummyBoard()
    board.hardware_init()
    board.add_hardware(manager.get_device("coherent_pwr"))
    board.add_hardware(manager.get_device("hercules_pwr"))

    ipc = TCPEndpoint(TCP_ADDRESS, manager)
    ipc.start()

    board.hardware_cleanup()
    return 0
コード例 #16
0
 def device_send(self, job_template, job_input, retry):
     config_str = json.dumps(job_input)
     self.push_config_state = PushConfigState.PUSH_STATE_INIT
     start_time = None
     config_size = 0
     try:
         self._logger.debug("playbook send message: %s" % config_str)
         config_size = len(config_str)
         device_manager = DeviceManager.get_instance()
         job_handler = JobHandler(job_template, job_input,
                                  [self.physical_router.uuid],
                                  device_manager.get_analytics_config(),
                                  device_manager.get_vnc(), self._logger)
         self.commit_stats['total_commits_sent_since_up'] += 1
         start_time = time.time()
         job_handler.push()
         end_time = time.time()
         self.commit_stats['commit_status_message'] = 'success'
         self.commit_stats['last_commit_time'] = \
                 datetime.datetime.fromtimestamp(
                 end_time).strftime('%Y-%m-%d %H:%M:%S')
         self.commit_stats['last_commit_duration'] = str(
                 end_time - start_time)
         self.push_config_state = PushConfigState.PUSH_STATE_SUCCESS
     except Exception as e:
         self._logger.error("Router %s: %s" %
                            (self.physical_router.management_ip, e.message))
         self.commit_stats[
                 'commit_status_message'] = 'failed to apply config,\
                                             router response: ' + e.message
         if start_time is not None:
             self.commit_stats['last_commit_time'] = \
                     datetime.datetime.fromtimestamp(
                         start_time).strftime('%Y-%m-%d %H:%M:%S')
             self.commit_stats['last_commit_duration'] = str(
                     time.time() - start_time)
         self.push_config_state = PushConfigState.PUSH_STATE_RETRY if retry\
             else PushConfigState.PUSH_STATE_FAILED
     return config_size
コード例 #17
0
    def _managers_default(self):
        c = []
        try:
            from experiment_manager import ExperimentManager
            c.append(ExperimentManager())
        except:
            pass
        try:
            from device_manager import DeviceManager
            c.append(DeviceManager())
        except:
            pass
        try:
            from control_manager import ControlManager
            c.append(ControlManager())
        except:
            pass
        try:
            from global_state_manager import GlobalStateManager
            c.append(GlobalStateManager())
        except:
            pass

        return c
コード例 #18
0
#!/usr/bin/env python

from device_manager import DeviceManager

if __name__ == '__main__':
    import sys

    from PyQt5.QtWidgets import QApplication

    app = QApplication(sys.argv)

    dev_manager = DeviceManager()
    dev_manager.show()

sys.exit(app.exec_())
コード例 #19
0
ファイル: main.py プロジェクト: renatofilho/BluezApp
import sys

from device_model import DeviceListModel
from service_model import ServiceListModel
from device_manager import DeviceManager

if __name__ == '__main__':
    QApplication.setGraphicsSystem("raster")
    app = QApplication(sys.argv)

    view = QDeclarativeView()
    engine = view.engine()
    engine.quit.connect(app.quit)

    if len(sys.argv) > 1:
        manager = DeviceManager(sys.argv[1])
    else:
        manager = DeviceManager()

    deviceListModel = DeviceListModel(manager)
    serviceListModel = ServiceListModel()
    deviceListModel.deviceSelected.connect(serviceListModel.loadDevice)

    view.rootContext().setContextProperty("deviceManager", manager)
    view.rootContext().setContextProperty("deviceListModel", deviceListModel)
    view.rootContext().setContextProperty("serviceListModel", serviceListModel)

    context = view.rootContext()

    view.setSource(QUrl('./qml/bluez.qml'))
    view.setMinimumSize(480, 800)
コード例 #20
0
 def test_stop_all_devices(self):
     dm = DeviceManager()
     assert True is dm.stop_all_devices()
コード例 #21
0
 def __init__(self):
     self.adx_inv_manager= DeviceManager()
コード例 #22
0
ファイル: card_dump.py プロジェクト: jazzu/CardDump
def udev_event_callback(action, device):
    global copy_thread, message_q
    if not copy_thread:
        copy_thread = DeviceManager(kwargs={'return_q': message_q, 'action': action, 'device': device})
        copy_thread.start()
コード例 #23
0
 def test_is_device_open(self):
     dm = DeviceManager()
     assert True is dm.is_device_open('dev_name')
コード例 #24
0
 def test_get_all_devices_status(self):
     dm = DeviceManager()
     assert [True] == dm.get_all_devices_status()
コード例 #25
0
ファイル: card_dump.py プロジェクト: jazzu/CardDump
def main(args):
    # Set up GUI
    pygame.init()
    pygame.mouse.set_visible(False)
    screen = pygame.display.set_mode((320, 240), 0, 32)
    pygame.display.set_caption('Card Dump')

    touch_ui.set_screen(screen)

    # Set up udev event monitoring
    udev_context = pyudev.Context()
    udev_monitor = pyudev.Monitor.from_netlink(udev_context)

    # Monitor all storage device related signals
    udev_monitor.filter_by('block', 'partition')
    global observer
    observer = pyudev.MonitorObserver(udev_monitor, udev_event_callback)
    observer.start()

    # Mount and check USB attached partitions for either "DCIM" or "card-dump" indicator
    # (friendly names are in ID_FS_LABEL(_ENC) property of a device)
    # sub-routine returns a three item tuple of lists. First is source candidate list,
    # second is destination candidate list, and third is the empty media list.
    source_candidates, destination_candidates, empties = DeviceManager.list_media()

    # if only one DCIM folder: use it as source
    # if multiple DCIM folders: which one is copied on this run?
    # if only one card-dump folder: use it as destination
    # if multiple card-dump folders: which one is used as destination on this run?

    source_set, destination_set = False, False

    if len(source_candidates) == 1:
        DeviceManager.set_source = source_candidates[0]
        source_set = True
    elif len(source_candidates) > 1:
        # Too many source candidates - ask user which one to copy
        # TODO: Implement "Too many source candidates"
        list(source_candidates)
    else:
        # No source candidates, one might be attached later
        list(source_candidates)

    if len(destination_candidates) == 1:
        DeviceManager.set_destination = destination_candidates[0]
        destination_set = True
    elif len(destination_candidates) > 1:
        # Too many destination candidates - ask user which one to copy
        # TODO: Implement "Too many destination candidates"
        list(destination_candidates)
    else:
        # No destination candidates, one might be attached later
        list(destination_candidates)

    # If there is at least one available "empty" USB media, and no source is set, ask the user
    # Is this in any way a proper scenario? I mean, if there's no DCIM folder, do we still offer user the
    # possibility of dump that card?
    if len(empties) > 0 and not source_set:
        list(empties)

    # If there is still at least one available "empty" USB media, and no destination is set, ask the user
    if len(empties) > 0 and not destination_set:
        list(empties)

    touch_ui.quit_button()
    pygame.display.flip()
    running = True

    while running:
        for event in pygame.event.get():
            if event.type == QUIT:
                clean_up()
                sys.exit()
                running = False
            elif event.type == pygame.MOUSEBUTTONDOWN:
                # All interactions need to go here?
                # What's the pattern to check for GUI events?

                if touch_ui.quit_box_rect.collidepoint(pygame.mouse.get_pos()):
                    clean_up()
                    sys.exit()
                    running = False
                elif touch_ui.start_copy_rect.collidepoint(pygame.mouse.get_pos()):
                    touch_ui.mock_start_copy(inverse=True)
                    pygame.display.flip()
                    print("Start copying...")

                    # Manual call for testing purposes
                    udev_event_callback('add', 'foo')

            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                clean_up(observer)
                running = False

        try:
            touch_ui.update_progress_bar(message_q.get_nowait())
            pygame.display.flip()
        except Queue.Empty:
            continue

        pygame.display.update()
コード例 #26
0
 def test_get_failed_devices(self):
     dm = DeviceManager()
     assert [True] == dm.get_failed_devices()
コード例 #27
0
 def test_open_all_devices(self):
     dm = DeviceManager()
     assert True is dm.open_all_devices()
コード例 #28
0
 def test_access_device(self):
     dm = DeviceManager()
     assert True is dm.access_device('dev')
コード例 #29
0
 def test_test_device(self):
     dm = DeviceManager()
     assert True is DeviceManagertest_device('dev').
コード例 #30
0
 def test_get_device_status(self):
     dm = DeviceManager()
     assert True is dm.get_device_status('dev_name')
コード例 #31
0
ファイル: card_dump.py プロジェクト: jazzu/CardDump
def main(args):
    # Set up GUI
    pygame.init()
    pygame.mouse.set_visible(False)
    screen = pygame.display.set_mode((320, 240), 0, 32)
    pygame.display.set_caption('Card Dump')

    touch_ui.set_screen(screen)

    # Set up udev event monitoring
    udev_context = pyudev.Context()
    udev_monitor = pyudev.Monitor.from_netlink(udev_context)

    # Monitor all storage device related signals
    udev_monitor.filter_by('block', 'partition')
    global observer
    observer = pyudev.MonitorObserver(udev_monitor, udev_event_callback)
    observer.start()

    # Mount and check USB attached partitions for either "DCIM" or "card-dump" indicator
    # (friendly names are in ID_FS_LABEL(_ENC) property of a device)
    # sub-routine returns a three item tuple of lists. First is source candidate list,
    # second is destination candidate list, and third is the empty media list.
    source_candidates, destination_candidates, empties = DeviceManager.list_media(
    )

    # if only one DCIM folder: use it as source
    # if multiple DCIM folders: which one is copied on this run?
    # if only one card-dump folder: use it as destination
    # if multiple card-dump folders: which one is used as destination on this run?

    source_set, destination_set = False, False

    if len(source_candidates) == 1:
        DeviceManager.set_source = source_candidates[0]
        source_set = True
    elif len(source_candidates) > 1:
        # Too many source candidates - ask user which one to copy
        # TODO: Implement "Too many source candidates"
        list(source_candidates)
    else:
        # No source candidates, one might be attached later
        list(source_candidates)

    if len(destination_candidates) == 1:
        DeviceManager.set_destination = destination_candidates[0]
        destination_set = True
    elif len(destination_candidates) > 1:
        # Too many destination candidates - ask user which one to copy
        # TODO: Implement "Too many destination candidates"
        list(destination_candidates)
    else:
        # No destination candidates, one might be attached later
        list(destination_candidates)

    # If there is at least one available "empty" USB media, and no source is set, ask the user
    # Is this in any way a proper scenario? I mean, if there's no DCIM folder, do we still offer user the
    # possibility of dump that card?
    if len(empties) > 0 and not source_set:
        list(empties)

    # If there is still at least one available "empty" USB media, and no destination is set, ask the user
    if len(empties) > 0 and not destination_set:
        list(empties)

    touch_ui.quit_button()
    pygame.display.flip()
    running = True

    while running:
        for event in pygame.event.get():
            if event.type == QUIT:
                clean_up()
                sys.exit()
                running = False
            elif event.type == pygame.MOUSEBUTTONDOWN:
                # All interactions need to go here?
                # What's the pattern to check for GUI events?

                if touch_ui.quit_box_rect.collidepoint(pygame.mouse.get_pos()):
                    clean_up()
                    sys.exit()
                    running = False
                elif touch_ui.start_copy_rect.collidepoint(
                        pygame.mouse.get_pos()):
                    touch_ui.mock_start_copy(inverse=True)
                    pygame.display.flip()
                    print("Start copying...")

                    # Manual call for testing purposes
                    udev_event_callback('add', 'foo')

            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                clean_up(observer)
                running = False

        try:
            touch_ui.update_progress_bar(message_q.get_nowait())
            pygame.display.flip()
        except Queue.Empty:
            continue

        pygame.display.update()
コード例 #32
0
 def test_load_devices_from_db(self):
     dm = DeviceManager()
     assert True is dm.load_devices_from_db()
コード例 #33
0
def sighup_handler():
    if DeviceManager.get_instance() is not None:
        DeviceManager.get_instance().sighup_handler()
コード例 #34
0
 def setUp(self):
     self.device_manager = DeviceManager()
コード例 #35
0
def sighup_handler():
    if DeviceManager.get_instance() is not None:
        DeviceManager.get_instance().sighup_handler()
コード例 #36
0
 def test_close_all_devices(self):
     dm = DeviceManager()
     assert True is dm.close_all_devices()
コード例 #37
0
 def test_test_all_devices(self):
     dm = DeviceManager()
     assert [{"device_name": "xyz", "status": True}
             ] == dm.test_all_devices()
コード例 #38
0
 def test_update_device_property(self):
     dm = DeviceManager()
     assert True is dm.update_device_property('device')