Beispiel #1
0
 def view_pdf(self):
     if not Shell.isinPATH('pdftoppm'):
         self.view_mime()
     else:
         if self.path not in self.tempfile_cache:
             fname = tempfile.mkstemp()[1]
             Shell.touch(fname)
             self.tempfile_cache[self.path] = fname
         fname = self.tempfile_cache[self.path]
         Shell.run(f'pdftoppm -png -f 1 -singlefile "{self.path}" {fname}')
         self.path = self.tempfile_cache[self.path] + '.png'
         self.view_image()
Beispiel #2
0
    def ls(self, dirname, cheap_remote_ls=False):
        if not cheap_remote_ls and len(dirname) > len(self.root_dir):
            local_files = set([
                name for name in Shell.run(f'ls -p "{dirname}"').split('\n')
                if len(name) > 0
            ])

            remote_files = set([
                name for name in Shell.run(
                    f'rclone {self._flags} lsf "{self.rpath(dirname)}"').split(
                        '\n') if len(name) > 0
            ])
            for name in remote_files.difference(local_files):
                if name[-1] == '/':
                    Shell.mkdir(os.path.join(dirname, name))
                else:
                    Shell.touch(os.path.join(dirname, name))

            for name in local_files.difference(remote_files):
                # TODO use Vim.AsyncRun instead
                Shell.run_async(f'rclone {self._flags} copyto --tpslimit=10 \
                                "{os.path.join(dirname, name)}" \
                                "{os.path.join(self.rpath(dirname), name)}"')
        return super(Rclone, self).ls(dirname)
Beispiel #3
0
 def touch(self, name):
     Shell.touch(name)