Ejemplo n.º 1
0
    def __init__(self, note_store, changed_function):
        self.note_store = note_store
        self.changed_function = changed_function
        self.changed = changed_function()

        config = Config()
        operations_dir = config.get('caching', 'cache_directory')
        self.operations_file_name = operations_dir + '/local_note_store'
        with open(self.operations_file_name, 'r+') as operations_file:
            try:
                operations = cPickle.load(operations_file)
                self.operations = self._unmarshal_operations(operations)
            except EOFError:
                self.operations = {}
Ejemplo n.º 2
0
class EvernoteApi(object):
    def __init__(self):
        self.config = Config()
        self._developer_token = self.config.get('login_details', 'developer_token')

        note_store = self._get_note_store()
        #TODO: tidy up this caching
        self.changed_cache = cache.get_cache('changed')
        def changed_function():
            logging.info('Calling getSyncState')
            sync_state = note_store.getSyncState(self._developer_token)
            return sync_state.updateCount

        def cached_changed_function():
            return self.changed_cache.get(key='changed', createfunc=changed_function)
        
        self.cached_changed_function = cached_changed_function
        self.note_store = LocalNoteStore(note_store, cached_changed_function)

        self.changes_store = ChangesStore()


    def _get_store_protocol(self, store_url):
        user_store_client = THttpClient(store_url)
        return TBinaryProtocol(user_store_client)
Ejemplo n.º 3
0
    def __init__(self):
        self.config = Config()
        self._developer_token = self.config.get('login_details', 'developer_token')

        note_store = self._get_note_store()
        #TODO: tidy up this caching
        self.changed_cache = cache.get_cache('changed')
        def changed_function():
            logging.info('Calling getSyncState')
            sync_state = note_store.getSyncState(self._developer_token)
            return sync_state.updateCount

        def cached_changed_function():
            return self.changed_cache.get(key='changed', createfunc=changed_function)
        
        self.cached_changed_function = cached_changed_function
        self.note_store = LocalNoteStore(note_store, cached_changed_function)

        self.changes_store = ChangesStore()
Ejemplo n.º 4
0
    def refresh(self):
        self.api.refresh_cache()

if __name__ == '__main__':
    arguments = docopt(__doc__)

    titles = []
    if select.select([sys.stdin],[],[],0.0)[0]:
        titles = [title[:-1] for title in sys.stdin.readlines()]
    if arguments['<title>']:
        titles.append(arguments['<title>'])

    logging.basicConfig(filename='/tmp/evernotelog', level=logging.DEBUG)
    logging.info('Running %s', string.join(sys.argv))
    config = Config()
    default_notebook = config.get('defaults', 'default_notebook')

    cli = EvernoteCli(default_notebook)

    if arguments['ls']:
        cli.print_notes(arguments['<notebook>'])
    elif arguments['notebooks']:
        cli.print_notebooks()
    elif arguments['refresh']:
        cli.refresh()
    elif arguments['print']:
        for title in titles:
            print 'Printing note {0}'.format(title)
            cli.print_note(title, arguments['--notebook'])
    elif len(titles) > 0: