Beispiel #1
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)
Beispiel #2
0
def auth_processor(handler): 
    try:
        parser = argparse.ArgumentParser()
        parser.add_argument('--token', type=str, help='oauth token')
        parser.add_argument('--secret', type=str, help='oauth secret')
        args = parser.parse_args(argv)
        verifier = web.input()['oauth_verifier']
        token = oauth.Token(args.token, args.secret)
        token.set_verifier(verifier)
        consumer = oauth.Consumer(CONSUMER_KEY, CONSUMER_SECRET)
        client = oauth.Client(consumer, token)
        resp, content = client.request('https://%s/oauth' % HOST, 'POST')
        access_token = dict(urlparse.parse_qsl(content))
        get_provider().authenticate(access_token['oauth_token'])
    except KeyError:
        pass
    return handler() 
Beispiel #3
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)
CATEGORIES = [c1, c2]

m0 = {'id': 'created',
      'type': 's',
      'field': Unity.SchemaFieldType.OPTIONAL}
m1 = {'id': 'last_changed',
      'type': 's',
      'field': Unity.SchemaFieldType.OPTIONAL}
m2 = {'id': 'tags',
      'type': 's',
      'field': Unity.SchemaFieldType.OPTIONAL}
EXTRA_METADATA = [m0, m1, m2]

#dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
everpad_provider = get_provider()


# Classes below this point establish communication
# with Unity, you probably shouldn't modify them.
class MySearch (Unity.ScopeSearchBase):
    def __init__(self, search_context):
        super(MySearch, self).__init__()
        self.set_search_context(search_context)
        #TODO read indexes from CATEGORIES array
        self.all_notes = 0
        self.pin_notes = 1

    def extract_content(self, note_content):
        """
        Extract sample note content for preview
Beispiel #5
0
import dbus.mainloop.glib
import sys
import os
import gettext
import json


path = os.path.join(os.path.dirname(__file__), '../../../i18n')
if not os.path.isdir(path):
    path =  resource_filename('share/locale/')
gettext.bindtextdomain('everpad', path)
gettext.textdomain('everpad')
_ = gettext.gettext

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
provider = get_provider()


class EverpadLens(SingleScopeLens):

    class Meta:
        name = 'everpad'
        description = _('Everpad Lens')
        search_hint = _('Search Everpad')
        icon = 'everpad-lens'
        search_on_blank = True
        bus_name = 'net.launchpad.Unity.Lens.EverpadLens'
        bus_path = '/net/launchpad/unity/lens/everpad'

    def __init__(self):
        SingleScopeLens.__init__(self)
Beispiel #6
0
import dbus
import dbus.mainloop.glib
import sys
import os
import gettext
import json

path = os.path.join(os.path.dirname(__file__), '../../../i18n')
if not os.path.isdir(path):
    path = resource_filename('share/locale/')
gettext.bindtextdomain('everpad', path)
gettext.textdomain('everpad')
_ = gettext.gettext

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
provider = get_provider()


class EverpadLens(SingleScopeLens):
    class Meta:
        name = 'everpad'
        description = _('Everpad Lens')
        search_hint = _('Search Everpad')
        icon = 'everpad-lens'
        search_on_blank = True
        bus_name = 'net.launchpad.Unity.Lens.EverpadLens'
        bus_path = '/net/launchpad/unity/lens/everpad'

    def __init__(self):
        SingleScopeLens.__init__(self)
        provider.connect_to_signal(