예제 #1
0
파일: daemon.py 프로젝트: cas--/everpad
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    try:
        os.mkdir(os.path.expanduser('~/.everpad/'))
        os.mkdir(os.path.expanduser('~/.everpad/data/'))
    except OSError:
        pass
    parser = argparse.ArgumentParser()
    parser.add_argument('--verbose',
                        action='store_true',
                        help='verbose output')
    parser.add_argument('--version',
                        '-v',
                        action='store_true',
                        help='show version')
    args = parser.parse_args(sys.argv[1:])
    if args.version:
        print_version()
    fp = open('/tmp/everpad-provider-%s.lock' % getpass.getuser(), 'w')
    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        app = ProviderApp(args.verbose, sys.argv)
        app.exec_()
    except IOError:
        print "everpad-provider already ran"
예제 #2
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    parser = argparse.ArgumentParser()
    parser.add_argument('attach', type=str, nargs='?', help='attach file to new note')
    parser.add_argument('--open', type=int, help='open note')
    parser.add_argument('--create', action='store_true', help='create new note')
    parser.add_argument('--all-notes', action='store_true', help='show all notes window')
    parser.add_argument('--settings', action='store_true', help='settings and management')
    parser.add_argument('--replace', action='store_true', help='replace already runned')
    parser.add_argument('--version', '-v', action='store_true', help='show version')
    args = parser.parse_args(sys.argv[1:])
    if args.version:
        print_version()
    if args.replace:
        try:
            pad = get_pad()
            pad.kill()
        except dbus.exceptions.DBusException:
            pass
    fp = open('/tmp/everpad-%s.lock' % getpass.getuser(), 'w')
    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
        app = PadApp(sys.argv)
        app.setApplicationName('everpad')
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        session_bus = dbus.SessionBus()
        app.provider = get_provider(session_bus)
        app.provider.connect_to_signal(
            'sync_state_changed',
            app.on_sync_state_changed,
            dbus_interface="com.everpad.provider",
        )
        app.launcher = get_launcher('application://everpad.desktop', session_bus, '/')
        bus = dbus.service.BusName("com.everpad.App", session_bus)
        service = EverpadService(app, session_bus, '/EverpadService')
        if args.open:
            app.indicator.open(args.open)
        if args.create:
            app.indicator.create()
        if args.settings:
            app.indicator.show_management()
        if args.attach:
            app.indicator.create(args.attach)
        if args.all_notes:
            app.indicator.show_all_notes()
        app.exec_()
    except IOError:
        pad = get_pad()
        if args.open:
            pad.open(args.open)
        if args.create:
            pad.create()
        if args.settings:
            pad.settings()
        if args.attach:
            pad.create_wit_attach(args.attach)
        if args.all_notes:
            pad.all_notes()
        sys.exit(0)
예제 #3
0
파일: daemon.py 프로젝트: MikeyG/gevernote
def main():
    # ctrl-c terminates the process gracefully
    # http://docs.python.org/dev/library/signal.html
    # http://pymotw.com/2/signal/
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # create everpad directories - _create_dirs local
    _create_dirs(['~/.everpad/', '~/.everpad/data/', '~/.everpad/logs/'])

    # parse args using funky python built-in stuff
    # {none}, verbose, or version
    # ref: http://docs.python.org/2/howto/argparse.html
    parser = argparse.ArgumentParser()
    parser.add_argument('--verbose',
                        action='store_true',
                        help='verbose output')
    parser.add_argument('--version',
                        '-v',
                        action='store_true',
                        help='show version')
    parser.add_argument('--debug',
                        '-d',
                        action='store_true',
                        help='debug output')
    args = parser.parse_args(sys.argv[1:])

    # print version (tools.py) and exit. print_version executes sys.exit(0)
    # after printing
    if args.version:
        print_version()

    # lockfile using usr name getpass.getuser()
    # start main loop or error out
    fp = open('/tmp/gvernote-provider-%s.lock' % getpass.getuser(), 'w')

    try:

        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)

        # ref: http://dbus.freedesktop.org/doc/dbus-python/api/
        # set_as_default is given and is true, set the new main
        # loop as the default for all new Connection or Bus instances
        # allows this script to receive DBus calls
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

        # SlavikZ - Fix occasional everpad-provider segfaults 050814
        # http://dbus.freedesktop.org/doc/dbus-python/api/dbus.mainloop.glib-module.html
        # Initialize threads in dbus-glib, if this has not already been done.
        dbus.mainloop.glib.threads_init()

        # http://stackoverflow.com/questions/22390064/use-dbus-to-just-send-a-message-in-python
        app = ProviderApp(args.verbose, sys.argv)
        app.exec_()

    except IOError:
        print("gevernote-provider already running")
    except Exception as e:
        print(e)
예제 #4
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    parser = argparse.ArgumentParser()
    parser.add_argument("attach", type=str, nargs="?", help="attach file to new note")
    parser.add_argument("--open", type=int, help="open note")
    parser.add_argument("--create", action="store_true", help="create new note")
    parser.add_argument("--all-notes", action="store_true", help="show all notes window")
    parser.add_argument("--settings", action="store_true", help="settings and management")
    parser.add_argument("--replace", action="store_true", help="replace already runned")
    parser.add_argument("--version", "-v", action="store_true", help="show version")
    args = parser.parse_args(sys.argv[1:])
    if args.version:
        print_version()
    if args.replace:
        try:
            pad = get_pad()
            pad.kill()
        except dbus.exceptions.DBusException:
            pass
    fp = open("/tmp/everpad-%s.lock" % getpass.getuser(), "w")
    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
        app = PadApp(sys.argv)
        app.setApplicationName("everpad")
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        session_bus = dbus.SessionBus()
        app.provider = get_provider(session_bus)
        app.provider.connect_to_signal(
            "sync_state_changed", app.on_sync_state_changed, dbus_interface="com.everpad.provider"
        )
        app.provider.connect_to_signal("data_changed", app.on_data_changed, dbus_interface="com.everpad.provider")
        app.launcher = get_launcher("application://everpad.desktop", session_bus, "/")
        bus = dbus.service.BusName("com.everpad.App", session_bus)
        service = EverpadService(session_bus, "/EverpadService")
        if args.open:
            app.indicator.open(args.open)
        if args.create:
            app.indicator.create()
        if args.settings:
            app.indicator.show_management()
        if args.attach:
            app.indicator.create(args.attach)
        if args.all_notes:
            app.indicator.show_all_notes()
        app.exec_()
    except IOError:
        pad = get_pad()
        if args.open:
            pad.open(args.open)
        if args.create:
            pad.create()
        if args.settings:
            pad.settings()
        if args.attach:
            pad.create_wit_attach(args.attach)
        if args.all_notes:
            pad.all_notes()
        sys.exit(0)
예제 #5
0
파일: daemon.py 프로젝트: MikeyG/gevernote
def main():
    # ctrl-c terminates the process gracefully
    # http://docs.python.org/dev/library/signal.html
    # http://pymotw.com/2/signal/
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # create everpad directories - _create_dirs local
    _create_dirs(['~/.everpad/', '~/.everpad/data/', '~/.everpad/logs/'])

    # parse args using funky python built-in stuff
    # {none}, verbose, or version
    # ref: http://docs.python.org/2/howto/argparse.html
    parser = argparse.ArgumentParser()
    parser.add_argument('--verbose', action='store_true', help='verbose output')
    parser.add_argument('--version', '-v', action='store_true', help='show version')
    parser.add_argument('--debug', '-d', action='store_true', help='debug output')
    args = parser.parse_args(sys.argv[1:])

    # print version (tools.py) and exit. print_version executes sys.exit(0)
    # after printing
    if args.version:
        print_version()

    # lockfile using usr name getpass.getuser()
    # start main loop or error out
    fp = open('/tmp/gvernote-provider-%s.lock' % getpass.getuser(), 'w')

    try:

        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)

        # ref: http://dbus.freedesktop.org/doc/dbus-python/api/
        # set_as_default is given and is true, set the new main 
        # loop as the default for all new Connection or Bus instances
        # allows this script to receive DBus calls
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

        # SlavikZ - Fix occasional everpad-provider segfaults 050814
        # http://dbus.freedesktop.org/doc/dbus-python/api/dbus.mainloop.glib-module.html
        # Initialize threads in dbus-glib, if this has not already been done.
        dbus.mainloop.glib.threads_init()

        # http://stackoverflow.com/questions/22390064/use-dbus-to-just-send-a-message-in-python
        app = ProviderApp(args.verbose, sys.argv)
        app.exec_()

    except IOError:
        print("gevernote-provider already running")
    except Exception as e:
        print(e)
예제 #6
0
파일: daemon.py 프로젝트: Exel232/everpad
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    fp = open('/tmp/everpad-provider-%s.lock' % getpass.getuser(), 'w')
    fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
    try:
        os.mkdir(os.path.expanduser('~/.everpad/'))
        os.mkdir(os.path.expanduser('~/.everpad/data/'))
    except OSError:
        pass
    parser = argparse.ArgumentParser()
    parser.add_argument('--verbose', action='store_true', help='verbose output')
    parser.add_argument('--version', '-v', action='store_true', help='show version')
    args = parser.parse_args(sys.argv[1:])
    if args.version:
        print_version()
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    app = ProviderApp(args.verbose, sys.argv)
    app.exec_()