Beispiel #1
0
    def runWithArguments(self, arguments):
        for _context in self.contexts:
            if _context.isActive():
                return 1

        argValues = processArguments(arguments)
        delay = argValues["delay"]

        savePathValue = argValues["savePath"]

        context = AppContext(argValues)
        if savePathValue != "":
            pic_name = os.path.basename(savePathValue)
            if pic_name == "":
                return 1
            else:
                if not os.path.exists(os.path.dirname(savePathValue)):
                    return 1

        context.settings = self._createContextSettings()
        context.finished.connect(self._contextFinished)
        context.needSound.connect(self._contextNeedSound)
        context.needOSD.connect(self._contextNeedOSD)
        self.contexts.append(context)

        if delay > 0:
            notificationsInterface.notify(
                _("Deepin Screenshot"),
                _("Deepin Screenshot will start after %s seconds.") % delay)
            '''If run the program frequently, the QTimer sometimes do not invoke the event, so replace QTimer with SafeTimer'''
            SafeTimer.singleShot(delay, context.main)
        else:
            context.main()

        return 0
    def runWithArguments(self, arguments):
        for _context in self.contexts:
            if _context.isActive():
                return 1

        argValues = processArguments(arguments)
        delay = argValues["delay"]

        savePathValue = argValues["savePath"]

        context = AppContext(argValues)
        if savePathValue != "":
            pic_name = os.path.basename(savePathValue)
            if pic_name == "":
                return 1
            else :
                if not os.path.exists(os.path.dirname(savePathValue)):
                    return 1

        context.settings = self._createContextSettings()
        context.finished.connect(self._contextFinished)
        context.needSound.connect(self._contextNeedSound)
        context.needOSD.connect(self._contextNeedOSD)
        self.contexts.append(context)

        if delay > 0:
            notificationsInterface.notify(_("Deepin Screenshot"),
            _("Deepin Screenshot will start after %s seconds.") % delay)
            '''If run the program frequently, the QTimer sometimes do not invoke the event, so replace QTimer with SafeTimer'''
            SafeTimer.singleShot(delay, context.main)
        else:
            context.main()

        return 0
    def runWithArguments(self, arguments):
        for _context in self.contexts:
            if _context.isActive():
                return

        argValues = processArguments(arguments)
        delay = argValues["delay"]

        self._sound = QSound(SOUND_FILE)
        self._sound.setLoops(1)

        context = AppContext(argValues)
        context.settings = self._createContextSettings()
        context.finished.connect(self._contextFinished)
        context.needSound.connect(self._contextNeedSound)
        context.needOSD.connect(self._contextNeedOSD)
        self.contexts.append(context)

        if delay > 0:
            notificationsInterface.notify(_("Deepin Screenshot"),
            _("Deepin Screenshot will start after %s seconds.") % delay)

        QTimer.singleShot(max(0, delay * 1000), context.main)
Beispiel #4
0
    def __init__(self):
        def get_input_handlers(controller, app_config):
            handlers = [PygameInputHandler(controller, app_config)]
            try:
                from pi_input_handler import PiInputHandler

                handlers.append(PiInputHandler(controller, app_config))
            except ImportError:
                print('Unable to import raspberrypi input handler')
            return handlers

        def get_zoneminder_client(app_config):
            zm_client = ZoneMinderClient(app_config.config[SERVER_HOST],
                                         app_config.config[SERVER_PORT],
                                         app_config.config[ZM_WEB_PATH],
                                         app_config.config[USER_NAME],
                                         app_config.config[PASSWORD],
                                         app_config.config[ZMS_WEB_PATH])
            return zm_client

        config = AppConfig()
        event_bus = EventBus()
        client = get_zoneminder_client(config)
        self.app_state = AppState()
        self.app_context = AppContext(config, client, event_bus)

        self.display = PygameDisplay(config)
        self.display.init()
        self.app_context.display_size = self.display.get_display_size()

        zm_stream_component = MonitorStreamComponent(self.app_context)
        group_selector_component = GroupSelectorComponent(self.app_context)
        monitor_selector_component = MonitorSelectorComponent(self.app_context)
        shutdown_prompt_component = ShutdownPromptSelector(self.app_context)
        menu_selector = MenuSelector(self.app_context)
        startup_component = StartUpComponent(self.app_context)
        self.component_manager = AppComponentManager(
            self.display, event_bus, startup_component, zm_stream_component, [
                group_selector_component, monitor_selector_component,
                shutdown_prompt_component, menu_selector
            ])
        self.input_manager = InputManager(get_input_handlers(
            event_bus, config))
        self.app_controller = AppController(self.app_context,
                                            self.input_manager, self.app_state)
        self.task_manager = TaskManager(event_bus)
Beispiel #5
0
            self.do_auto_cycle()
            return

    #def ihbit_cycle():
    #    for


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Persephone CAN Bus sprinkler System')
    parser.add_argument('config', help='config filename')
    parser.add_argument('canstruct', help='canstruct config filename')
    parser.add_argument('interface', help='SocketCAN interface')
    args = parser.parse_args()

    context = AppContext()
    context.config = yaml.load(open(args.config, 'r'))
    context.can_interface = args.interface
    context.bus = can.interface.Bus(channel=args.interface,
                                    bustype='socketcan_ctypes')

    canstruct_cfg = yaml.load(open(args.canstruct, 'r'))
    context.canstruct = pycanstruct.CANStruct(
        canstruct_cfg[canstruct_cfg.keys()[0]])

    p = Persephone(context)
    p.load()
    p.start()

palette = [
    ('banner', 'white', 'dark cyan'),
Beispiel #6
0
from app_context import AppContext

if __name__ == '__main__':
    app_context = AppContext()
    print("State: %s" % app_context.state)
    print("Config: %s" % app_context.config)
    print("Loaded plugins: %s" % list(app_context.plugins.keys()))
    print("All set, app started.")