Beispiel #1
0
 def _download(self, webdavConnection, remote_filename,
               local_filename, time_delta):
     if not local_filename:
         local_filename = remote_filename
     self.logger.debug('Download %s to %s' %
                       (remote_filename, local_filename))
     rdirname, rfilename = (os.path.dirname(remote_filename),
                            os.path.basename(remote_filename))
     print rdirname, rfilename
     webdavConnection.path = webdavPathJoin(self._get_notes_path(),
                                            rdirname, rfilename)
     print webdavConnection.path
     if not os.path.exists(os.path.join(self._localDataFolder,
                                        os.path.dirname(local_filename))):
         os.makedirs(os.path.join(self._localDataFolder,
                                  os.path.dirname(local_filename)))
     lpath = os.path.join(self._localDataFolder,
                          os.path.dirname(local_filename),
                          getValidFilename(
                          os.path.basename(local_filename)))
     webdavConnection.downloadFile(lpath)
     mtime = local2utc(time.mktime(webdavConnection
                                   .readStandardProperties()
                                   .getLastModified())) - time_delta
     os.utime(lpath, (-1, mtime))
Beispiel #2
0
 def _download(self, webdavConnection, remote_filename,
                     local_filename, time_delta):
     if not local_filename:
         local_filename = remote_filename
     self.logger.debug('Download %s to %s' %
                       (remote_filename, local_filename))
     webdavConnection.path = self._get_notes_path() + remote_filename
     lpath = os.path.join(
             self._localDataFolder, getValidFilename(local_filename))
     webdavConnection.downloadFile(lpath)
     mtime = time.mktime(webdavConnection.readStandardProperties()
                         .getLastModified()) - time_delta
     os.utime(lpath, (-1, mtime))
Beispiel #3
0
    def _import(self):
        self.noteList = {}
        for infile in glob.glob(os.path.join(os.path.expanduser("~/.conboy"), "*.note")):
            try:
                parser = xml.sax.make_parser()
                handler = textHandler()
                parser.setContentHandler(handler)
                parser.parse(infile)
            except Exception:
                import traceback

                print traceback.format_exc()

            try:
                note = Note()
                uuid = handler._content.split("\n", 1)[0].strip(" \t\r\n")
                uuid = getValidFilename(uuid)
                path = os.path.join(note.NOTESPATH, uuid)
                if os.path.exists(path + ".txt"):
                    index = 2
                    while os.path.exists(os.path.join(note.NOTESPATH, "%s %s.txt" % (path, unicode(index)))):
                        index = index + 1
                    uuid = "%s %s" % (os.path.basename(path), unicode(index))

                note.uuid = uuid + ".txt"
                note.write(handler._content)
                try:
                    from rfc3339.rfc3339 import strtotimestamp

                    mtime = strtotimestamp(handler._last_change)
                    lpath = os.path.join(Note.NOTESPATH, note.uuid)
                    os.utime(lpath, (-1, mtime))
                except Exception:
                    import traceback

                    print traceback.format_exc()

            except Exception:
                import traceback

                print traceback.format_exc()

        self._set_running(False)
        self.on_finished.emit()
Beispiel #4
0
    def _import(self):
        self.noteList = {}
        for infile in glob.glob( \
            os.path.join(os.path.expanduser('~/.conboy'), '*.note')):
            try:
                parser = xml.sax.make_parser()
                handler = textHandler()
                parser.setContentHandler(handler)
                parser.parse(infile)
            except Exception, err:
                import traceback
                print traceback.format_exc()

            try:
                note = Note()
                uuid = handler._content.split('\n', 1)[0].strip(' \t\r\n')
                uuid = getValidFilename(uuid)
                path = os.path.join(note.NOTESPATH, uuid)
                if os.path.exists(path + '.txt'):
                    index = 2
                    while (os.path.exists(os.path.join( \
                            note.NOTESPATH,'%s %s.txt' \
                            % (path, \
                            unicode(index))))):
                        index = index + 1
                    uuid = ('%s %s' \
                            % (os.path.basename(path), \
                            unicode(index)))

                note.uuid = uuid + '.txt'
                note.write(handler._content)
                try:
                    from rfc3339.rfc3339 import strtotimestamp
                    mtime = strtotimestamp(handler._last_change)
                    lpath = os.path.join(Note.NOTESPATH, note.uuid)
                    os.utime(lpath, (-1, mtime))
                except Exception, err:
                    import traceback
                    print traceback.format_exc()

            except Exception, err:
                import traceback
                print traceback.format_exc()