示例#1
0
def main(argv):
    mainloop = GObject.MainLoop()
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    notify2.init(_("Time Slider"))

    noteManager = NoteManager()

    try:
        mainloop.run()
    except:
        print("Exiting")
示例#2
0
def main(argv):
    mainloop = gobject.MainLoop()
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    gobject.threads_init()
    pynotify.init(_("Time Slider"))

    noteManager = NoteManager()

    try:
        mainloop.run()
    except:
        print "Exiting"
示例#3
0
def main(argv):
    mainloop = gobject.MainLoop()
    dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
    gobject.threads_init()
    pynotify.init(_("Time Slider"))

    noteManager = NoteManager()

    try:
        mainloop.run()
    except:
        print "Exiting"
示例#4
0
def main(argv):

    # Check SMF invocation environment
    if os.getenv("SMF_FMRI") == None or os.getenv("SMF_METHOD") != "start":
        sys.stderr.write("Command line invocation of %s unsupported.\n" \
                         % (sys.argv[0]))
        sys.stderr.write(
            "This command is intended for smf(5) invocation only.\n")
        sys.exit(smf.SMF_EXIT_ERR_NOSMF)

    # Daemonise the service.
    create_daemon()

    # The user security attributes checked are the following:
    # Note that UID == 0 will match any profile search so
    # no need to check it explicitly.
    syslog.openlog("time-sliderd", 0, syslog.LOG_DAEMON)
    rbacp = RBACprofile()
    if rbacp.has_profile("ZFS File System Management"):

        gobject.threads_init()

        # Tell dbus to use the gobject mainloop for async ops
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        # Register a bus name with the system dbus daemon
        systemBus = dbus.SystemBus()
        name = dbus.service.BusName("org.opensolaris.TimeSlider", systemBus)

        # Create and start the snapshot manger. Takes care of
        # auto snapshotting service and auto cleanup.
        snapshot = SnapshotManager(systemBus)
        snapshot.start()
        gobject.timeout_add(2000, monitor_threads, snapshot)

        mainloop = gobject.MainLoop()
        try:
            mainloop.run()
        except KeyboardInterrupt:
            mainloop.quit()
            sys.exit(smf.SMF_EXIT_OK)
    else:
        syslog.syslog(syslog.LOG_ERR,
               "%s has insufficient privileges to run time-sliderd!" \
               % rbacp.name)
        syslog.closelog()
        sys.exit(smf.SMF_EXIT_ERR_PERM)
    syslog.closelog()
    sys.exit(smf.SMF_EXIT_OK)
示例#5
0
def main(argv):

    # Check SMF invocation environment
    if os.getenv("SMF_FMRI") == None or os.getenv("SMF_METHOD") != "start":
        sys.stderr.write("Command line invocation of %s unsupported.\n" \
                         % (sys.argv[0]))
        sys.stderr.write("This command is intended for smf(5) invocation only.\n")
        sys.exit(smf.SMF_EXIT_ERR_NOSMF)

    # Daemonise the service.
    create_daemon()

    # The user security attributes checked are the following:
    # Note that UID == 0 will match any profile search so
    # no need to check it explicitly.
    syslog.openlog("time-sliderd", 0, syslog.LOG_DAEMON)
    rbacp = RBACprofile()
    if rbacp.has_profile("ZFS File System Management"):

        gobject.threads_init()

        # Tell dbus to use the gobject mainloop for async ops
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        # Register a bus name with the system dbus daemon
        systemBus = dbus.SystemBus()
        name = dbus.service.BusName("org.opensolaris.TimeSlider", systemBus)

        # Create and start the snapshot manger. Takes care of
        # auto snapshotting service and auto cleanup.
        snapshot = SnapshotManager(systemBus)
        snapshot.start()
        gobject.timeout_add(2000, monitor_threads, snapshot)

        mainloop = gobject.MainLoop()
        try:
            mainloop.run()
        except KeyboardInterrupt:
            mainloop.quit()
            sys.exit(smf.SMF_EXIT_OK)
    else:
        syslog.syslog(syslog.LOG_ERR,
               "%s has insufficient privileges to run time-sliderd!" \
               % rbacp.name)
        syslog.closelog()    
        sys.exit(smf.SMF_EXIT_ERR_PERM)
    syslog.closelog()
    sys.exit(smf.SMF_EXIT_OK)
示例#6
0
    def __init__(self):
        bus = dbus.SystemBus()
        obj = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
        hal = dbus.Interface(obj, "org.freedesktop.Hal.Manager")
        hal.connect_to_signal("DeviceAdded", self.device_added)
        hal.connect_to_signal("DeviceRemoved", self.device_removed)
        hal.GetAllDevices(reply_handler=self.reply_handler, error_handler=self.error_handler)

    def reply_handler(self, devices):
        for device in devices:
            print device

    def error_handler(self, error):
        print "Fatal error: "
        print error

    def device_removed(self, device):
        print " device removed "
        print device

    def device_added(self, device):
        print " device added "
        print device


if __name__ == "__main__":
    DBusGMainLoop(set_as_default=True)
    at = AsyncTest()
    mainloop = gobject.MainLoop()
    mainloop.run()
示例#7
0
    for n in range(begin, end):
        string1 += chr(n)

    print len(string1)

    lcd.DisplayText(0, string1)
    lcd.DisplayText(1, hex(begin) + "    ")

    time.sleep(2)

bprox = bus.get_object('ca.infoglobe.peephole',
                       '/ca/infoglobe/peephole/LCDs/PicoLCD/Buttons/F1')

button = dbus.Interface(bprox, dbus_interface='ca.infoglobe.peephole.Button')


def button_pressed_callback():
    button.SetBacklight(True)
    time.sleep(0.1)
    button.SetBacklight(False)


#while True:
#    button.SetBacklight(True)
#    button.SetBacklight(False)

#lcd.connect_to_signal("ButtonPressed", button_pressed_callback)
button.connect_to_signal("Pressed", button_pressed_callback)

mainloop.run()
示例#8
0
def main(argv):

    parser = argparse.ArgumentParser()
    parser.add_argument('--foreground', action='store_true', help='Do not daemonize', default=False)
    parser.add_argument('--config', '-c', type=str, help='Configuration file', default='/etc/time-slider/timesliderd.conf')
    parser.add_argument('--configdump', action='store_true', help='Dump default values in config file format', default=False)
    args, _ = parser.parse_known_args()

    logger = logging.getLogger('time-slider')
    logger.setLevel(logging.DEBUG)
    if args.foreground:
        handler = logging.StreamHandler()
        handler.setFormatter(logging.Formatter('%(message)s'))
    else:
        handler = SysLogHandler(address='/dev/log')
        handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s', '%b %d %H:%M:%S time-sliderd:'))
    handler.setLevel(logging.DEBUG)
    logger.addHandler(handler)

    if args.configdump:
        timesliderconfig.configdump()
        sys.exit(smf.SMF_EXIT_OK)

    timesliderconfig.configfile = args.config

    # Daemonise the service.
    if not args.foreground:
        create_daemon()

    # The user security attributes checked are the following:
    # Note that UID == 0 will match any profile search so
    # no need to check it explicitly.
    rbacp = RBACprofile()
    if rbacp.has_profile("ZFS File System Management"):

        gobject.threads_init()

        # Tell dbus to use the gobject mainloop for async ops
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        # Register a bus name with the system dbus daemon
        systemBus = dbus.SystemBus()
        name = dbus.service.BusName("org.opensolaris.TimeSlider", systemBus)

        # Create and start the snapshot manger. Takes care of
        # auto snapshotting service and auto cleanup.
        snapshot = SnapshotManager(systemBus)
        snapshot.start()
        gobject.timeout_add(2000, monitor_threads, snapshot)

        mainloop = gobject.MainLoop()
        try:
            mainloop.run()
        except KeyboardInterrupt:
            mainloop.quit()
            sys.exit(smf.SMF_EXIT_OK)
    else:
        logger.error( \
               "%s has insufficient privileges to run time-sliderd!" \
               % rbacp.name)
        sys.exit(smf.SMF_EXIT_ERR_PERM)
    sys.exit(smf.SMF_EXIT_OK)
示例#9
0
def main(argv):

    parser = argparse.ArgumentParser()
    parser.add_argument('--foreground',
                        action='store_true',
                        help='Do not daemonize',
                        default=False)
    parser.add_argument('--config',
                        '-c',
                        type=str,
                        help='Configuration file',
                        default='/etc/time-slider/timesliderd.conf')
    parser.add_argument('--configdump',
                        action='store_true',
                        help='Dump default values in config file format',
                        default=False)
    args, _ = parser.parse_known_args()

    logger = logging.getLogger('time-slider')
    logger.setLevel(logging.DEBUG)
    if args.foreground:
        handler = logging.StreamHandler()
        handler.setFormatter(logging.Formatter('%(message)s'))
    else:
        handler = SysLogHandler(address='/dev/log')
        handler.setFormatter(
            logging.Formatter('%(asctime)s %(levelname)s: %(message)s',
                              '%b %d %H:%M:%S time-sliderd:'))
    handler.setLevel(logging.DEBUG)
    logger.addHandler(handler)

    if args.configdump:
        timesliderconfig.configdump()
        sys.exit(smf.SMF_EXIT_OK)

    timesliderconfig.configfile = args.config

    # Daemonise the service.
    if not args.foreground:
        create_daemon()

    # The user security attributes checked are the following:
    # Note that UID == 0 will match any profile search so
    # no need to check it explicitly.
    rbacp = RBACprofile()
    if rbacp.has_profile("ZFS File System Management"):

        gobject.threads_init()

        # Tell dbus to use the gobject mainloop for async ops
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        # Register a bus name with the system dbus daemon
        systemBus = dbus.SystemBus()
        name = dbus.service.BusName("org.opensolaris.TimeSlider", systemBus)

        # Create and start the snapshot manger. Takes care of
        # auto snapshotting service and auto cleanup.
        snapshot = SnapshotManager(systemBus)
        snapshot.start()
        gobject.timeout_add(2000, monitor_threads, snapshot)

        mainloop = gobject.MainLoop()
        try:
            mainloop.run()
        except KeyboardInterrupt:
            mainloop.quit()
            sys.exit(smf.SMF_EXIT_OK)
    else:
        logger.error( \
               "%s has insufficient privileges to run time-sliderd!" \
               % rbacp.name)
        sys.exit(smf.SMF_EXIT_ERR_PERM)
    sys.exit(smf.SMF_EXIT_OK)