Example #1
0
def main(args=sys.argv):
    """This is an example program of how to use the PresentKey widget"""
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)

        #if arguments.gpg:
        #    keyid = arguments.file
        #    ctx = gpgme.Context()
        #    found_keys = gpg.gpg_get_keylist(ctx, keyid)
        #    # We take the first item we found and export the actual keydata
        #    fpr = found_keys[0].subkeys[0].fpr
        #    keydata = gpg.extract_keydata(ctx, fpr, True)
        #else:
        #    keydata = open(arguments.file, 'r').read()
        fpr = arguments.fpr

        app = KeyPresent()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
        except AttributeError:
            pass

        exit_status = app.run(fpr)

        return exit_status


    finally:
        logging.shutdown()
Example #2
0
def main():
    # These imports were moved here because the keysign module
    # can be imported without wanting to run it, e.g. setup.py
    # imports the __version__
    import logging, sys, signal
    
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import GLib, Gtk
    
    from .MainWindow import MainWindow

    logging.basicConfig(stream=sys.stderr,
        level=logging.DEBUG,
        format='%(name)s (%(levelname)s): %(message)s')

    app = MainWindow()

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
    except AttributeError:
        pass

    exit_status = app.run(None)

    return exit_status
Example #3
0
def main():
    # These imports were moved here because the keysign module
    # can be imported without wanting to run it, e.g. setup.py
    # imports the __version__
    import logging, sys, signal

    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import GLib, Gtk

    from .MainWindow import MainWindow

    logging.basicConfig(stream=sys.stderr,
                        level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')

    app = MainWindow()

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  lambda *args: app.quit(), None)
    except AttributeError:
        pass

    exit_status = app.run(None)

    return exit_status
Example #4
0
def main(args=sys.argv):
    """This is an example program of how to use the PresentKey widget"""
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)
        
        #if arguments.gpg:
        #    keydata = export_keydata(next(get_usable_keys(keyid)))
        #else:
        #    keydata = open(arguments.file, 'r').read()
        fpr = arguments.fpr

        app = KeyPresent()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
        except AttributeError:
            pass
    
        exit_status = app.run(fpr)
    
        return exit_status

        
    finally:
        logging.shutdown()
Example #5
0
def main(args=sys.argv):
    """This is an example program of how to use the PresentKey widget"""
    logging.basicConfig(stream=sys.stderr,
                        level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)

        #if arguments.gpg:
        #    keydata = export_keydata(next(get_usable_keys(keyid)))
        #else:
        #    keydata = open(arguments.file, 'r').read()
        fpr = arguments.fpr

        app = KeyPresent()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                      lambda *args: app.quit(), None)
        except AttributeError:
            pass

        exit_status = app.run(fpr)

        return exit_status

    finally:
        logging.shutdown()
Example #6
0
def main(args=sys.argv):
    """This is an example program of how to use the PresentKey widget"""
    logging.basicConfig(stream=sys.stderr,
                        level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)

        #if arguments.gpg:
        #    keyid = arguments.file
        #    keyring = Keyring()
        #    # this is a dict {fpr: key-instance}
        #    found_keys = keyring.get_keys(keyid)
        #    # We take the first item we found and export the actual keydata
        #    fpr = found_keys.items()[0][0]
        #    keyring.export_data(fpr=fpr, secret=False)
        #    keydata = keyring.context.stdout
        #else:
        #    keydata = open(arguments.file, 'r').read()
        fpr = arguments.fpr

        app = KeyPresent()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                      lambda *args: app.quit(), None)
        except AttributeError:
            pass

        exit_status = app.run(fpr)

        return exit_status

    finally:
        logging.shutdown()
Example #7
0
def main(args=sys.argv):
    """This is an example program of how to use the PresentKey widget"""
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)
        
        #if arguments.gpg:
        #    keyid = arguments.file
        #    keyring = Keyring()
        #    # this is a dict {fpr: key-instance}
        #    found_keys = keyring.get_keys(keyid)
        #    # We take the first item we found and export the actual keydata
        #    fpr = found_keys.items()[0][0]
        #    keyring.export_data(fpr=fpr, secret=False)
        #    keydata = keyring.context.stdout
        #else:
        #    keydata = open(arguments.file, 'r').read()
        fpr = arguments.fpr

        app = KeyPresent()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
        except AttributeError:
            pass
    
        exit_status = app.run(fpr)
    
        return exit_status

        
    finally:
        logging.shutdown()
def main():
    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : Gtk.main_quit(), None)
    except AttributeError:
        pass

    app = MainWindow()
    exit_status = app.run(None)
    return exit_status
def main():
    app = Application()

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
    except AttributeError:
        pass

    exit_status = app.run(None)
    return exit_status
Example #10
0
 def __on_activate(self, app):
     logger.debug("UpdateApplication activated")
     self.__updater = _Updater()
     if not self.__delay:
         self.__updater.startup_init_update_timer()
     else:
         self.__updater.start_update_timer()
     signals = [SIGINT, SIGTERM, SIGHUP]
     for signal in signals:
         GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal,
                                   self.__on_unix_signal)
     self.__main_loop.run()
Example #11
0
def main():
    from . import gtkexcepthook
    app = MainWindow()

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
    except AttributeError:
        pass

    exit_status = app.run(None)

    return exit_status
Example #12
0
def gui(survey, cmdline):
    filter = clifilter.clifilter(survey, cmdline['filter'])
    provider = Provider(survey, filter)
    if not provider.images:
        log.error(_("The survey does not have any images! Please add images (and run recognize) before using the GUI."))
        return 1

    try:
        # Exit the mainloop if Ctrl+C is pressed in the terminal.
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : Gtk.main_quit(), None)
    except AttributeError:
        # Whatever, it is only to enable Ctrl+C anyways
        pass

    MainWindow(provider).run()
Example #13
0
File: gui.py Project: crabhi/sdaps
def gui(survey, cmdline):
    filter = clifilter.clifilter(survey, cmdline['filter'])
    provider = Provider(survey, filter)
    if not provider.images:
        log.error(_("The survey does not have any images! Please add images (and run recognize) before using the GUI."))
        return 1

    try:
        # Exit the mainloop if Ctrl+C is pressed in the terminal.
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : Gtk.main_quit(), None)
    except AttributeError:
        # Whatever, it is only to enable Ctrl+C anyways
        pass

    MainWindow(provider).run()
Example #14
0
def main(args=[]):
    log = logging.getLogger(__name__)
    log.debug('Running main with args: %s', args)
    if not args:
        args = []
    Gst.init(None)

    app = App()
    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  lambda *args: reactor.callFromThread(reactor.stop), None)
    except AttributeError:
        pass
    reactor.registerGApplication(app)
    reactor.run()
Example #15
0
def main(args=[]):
    log = logging.getLogger(__name__)
    log.debug('Running main with args: %s', args)
    if not args:
        args = []
    Gst.init(None)

    app = App()
    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  lambda *args: reactor.callFromThread(reactor.stop), None)
    except AttributeError:
        pass
    reactor.registerGApplication(app)
    reactor.run()
Example #16
0
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')

    # We need to have GStreamer initialised before creating a BarcodeReader
    Gst.init(sys.argv)
    app = SimpleInterface()

    try:
        # Exit the mainloop if Ctrl+C is pressed in the terminal.
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
    except AttributeError:
        # Whatever, it is only to enable Ctrl+C anyways
        pass

    app.run()
Example #17
0
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    br = BarcodeReader()
    Gst.init(sys.argv)

    try:
        # Exit the mainloop if Ctrl+C is pressed in the terminal.
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : Gtk.main_quit(), None)
    except AttributeError:
        # Whatever, it is only to enable Ctrl+C anyways
        pass

    #GLib.idle_add(br.run)

    SimpleInterface()
    Gtk.main()
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    br = BarcodeReader()
    Gst.init(sys.argv)

    try:
        # Exit the mainloop if Ctrl+C is pressed in the terminal.
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : Gtk.main_quit(), None)
    except AttributeError:
        # Whatever, it is only to enable Ctrl+C anyways
        pass

    #GLib.idle_add(br.run)

    SimpleInterface()
    Gtk.main()
Example #19
0
def main(args=[]):
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(name)s (%(levelname)s): %(message)s')
    log = logging.getLogger(__name__)
    log.debug('Running main with args: %s', args)
    if not args:
        args = []
    Gst.init(None)

    app = KeysignApp()
    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  lambda *args: reactor.callFromThread(reactor.stop), None)
    except AttributeError:
        pass
    reactor.registerGApplication(app)
    reactor.run()
Example #20
0
def main(args=[]):
    logging.basicConfig(level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    log = logging.getLogger(__name__)
    log.debug('Running main with args: %s', args)
    if not args:
        args = []
    Gst.init(None)

    app = KeysignApp()
    try:
        GLib.unix_signal_add_full(
            GLib.PRIORITY_HIGH, signal.SIGINT,
            lambda *args: reactor.callFromThread(reactor.stop), None)
    except AttributeError:
        pass
    reactor.registerGApplication(app)
    reactor.run()
Example #21
0
def main():
    # These imports were moved here because the keysign module
    # can be imported without wanting to run it, e.g. setup.py
    # imports the __version__
    import logging, sys, signal
    
    from gi.repository import GLib, Gtk
    
    from .MainWindow import MainWindow

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : Gtk.main_quit(), None)
    except AttributeError:
        pass

    app = MainWindow()
    exit_status = app.run(None)

    return exit_status
Example #22
0
def main(args=sys.argv):
    """This is an example program of how to use the Keys widget"""
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)
        
        app = Keys()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
        except AttributeError:
            pass
    
        exit_status = app.run(None)
    
        return exit_status

        
    finally:
        logging.shutdown()
Example #23
0
def main(args=sys.argv):
    """This is an example program of how to use the Keys widget"""
    logging.basicConfig(stream=sys.stderr,
                        level=logging.DEBUG,
                        format='%(name)s (%(levelname)s): %(message)s')
    try:
        arguments = parse_command_line(args)

        app = Keys()
        try:
            GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                      lambda *args: app.quit(), None)
        except AttributeError:
            pass

        exit_status = app.run(None)

        return exit_status

    finally:
        logging.shutdown()
Example #24
0
def main():
    # These imports were moved here because the keysign module
    # can be imported without wanting to run it, e.g. setup.py
    # imports the __version__
    import logging, sys, signal

    from gi.repository import GLib, Gtk

    from .MainWindow import MainWindow

    app = MainWindow()

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  lambda *args: app.quit(), None)
    except AttributeError:
        pass

    exit_status = app.run(None)

    return exit_status
Example #25
0
    def __init__(self, elementname="fsrtpconference"):
        GObject.GObject.__init__(self)
        self.pipeline = Gst.Pipeline()
        GLib.unix_signal_add_full(0, signal.SIGINT, self.g_int_handler, None,)
        signal.signal(signal.SIGINT, self.int_handler)
        #self.pipeline.get_bus().set_sync_handler(self.sync_handler, None)
        self.pipeline.get_bus().add_watch(0, self.async_handler, None)
        self.conf = Gst.ElementFactory.make(elementname, None)
        self.notifier = Farstream.ElementAddedNotifier()
        self.notifier.add(self.pipeline)
        self.notifier.set_default_properties(self.conf)

        self.pipeline.add(self.conf)
        if VIDEO:
            self.videosource = FsUIVideoSource(self.pipeline)
            self.videosession = FsUISession(self.conf, self.videosource)
        if AUDIO:
            self.audiosource = FsUIAudioSource(self.pipeline)
            self.audiosession = FsUISession(self.conf, self.audiosource)
            #self.adder = None
        self.pipeline.set_state(Gst.State.PLAYING)
Example #26
0
    def __init__(self, elementname="fsrtpconference"):
        GObject.GObject.__init__(self)
        self.pipeline = Gst.Pipeline()
        GLib.unix_signal_add_full(0, signal.SIGINT, self.g_int_handler, None,)
        signal.signal(signal.SIGINT, self.int_handler)
        #self.pipeline.get_bus().set_sync_handler(self.sync_handler, None)
        self.pipeline.get_bus().add_watch(0, self.async_handler, None)
        self.conf = Gst.ElementFactory.make(elementname, None)
        self.notifier = Farstream.ElementAddedNotifier()
        self.notifier.add(self.pipeline)
        self.notifier.set_default_properties(self.conf)

        self.pipeline.add(self.conf)
        if VIDEO:
            self.videosource = FsUIVideoSource(self.pipeline)
            self.videosession = FsUISession(self.conf, self.videosource)
        if AUDIO:
            self.audiosource = FsUIAudioSource(self.pipeline)
            self.audiosession = FsUISession(self.conf, self.audiosource)
            #self.adder = None
        self.pipeline.set_state(Gst.State.PLAYING)
    procStdErr = create_procpipe(stderrPipeName, on_proc_stderr)

    if (os.path.exists("/var/log/syslog")):
        syslogHandler = FileTailer("/var/log/syslog", filter_syslog_line,
                                   syslog_err)
        syslogHandler.start()

    if "unix_signal_add" in dir(GLib):
        GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, on_sigterm,
                             runner)
        GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, on_sigterm,
                             runner)
        GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGHUP, on_sigterm,
                             runner)
    else:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGTERM,
                                  on_sigterm, runner)
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  on_sigterm, runner)
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGHUP,
                                  on_sigterm, runner)

    #unlock the phone
    powerd = subprocess.Popen(["powerd-cli", "display", "on"],
                              stdout=subprocess.DEVNULL,
                              stderr=subprocess.DEVNULL)
    sessionBus = dbus.SessionBus()
    unityGreeter = sessionBus.get_object('com.canonical.UnityGreeter', '/')
    unityGreeterIFace = dbus.Interface(
        unityGreeter, dbus_interface='com.canonical.UnityGreeter')
    unityGreeterIFace.HideGreeter()
Example #28
0
        # we could have possibly pressed this button, i.e.
        # from the keypresentwidget or the result page
        log.debug("Send Headerbutton %r clicked! %r", button, args)
        current = self.send_app.stack.get_visible_child()
        klw = self.send_app.klw
        kpw = self.send_app.kpw
        # If we are in the keypresentwidget
        if current == kpw:
            self.send_stack.set_visible_child(klw)
            self.send_app.deactivate()
        # Else we are in the result page
        else:
            self.send_stack.remove(current)
            self.send_app.set_saved_child_visible()
            self.send_app.on_key_activated(None, self.send_app.key)

    def on_header_button_clicked(self, button, *args):
        log.debug("Headerbutton %r clicked! %r", button, args)
        return self.on_send_header_button_clicked(button, *args)

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    app = App()
    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
                                  lambda *args: reactor.callFromThread(reactor.stop), None)
    except AttributeError:
        pass
    reactor.registerGApplication(app)
    reactor.run()