Пример #1
0
    def do_run(self, options, args):

        if not args:
            args = ['.']

        for fs, path, is_dir in self.get_resources(args, single=True):
            if not is_dir:
                self.error(u"'%s' is not a dir\n" % path)
                return 1
            fs.cache_hint(True)
            if options.gui:
                from fs.browsewin import browse
                if path:
                    fs = fs.opendir(path)
                browse(fs, hide_dotfiles=not options.all)
            else:
                if options.depth < 0:
                    max_levels = None
                else:
                    max_levels = options.depth
                print_fs(fs,
                         path or '',
                         file_out=self.output_file,
                         max_levels=max_levels,
                         terminal_colors=self.terminal_colors,
                         hide_dotfiles=not options.all,
                         dirs_first=options.dirsfirst)
Пример #2
0
 def do_run(self, options, args):        
     
     if not args:
         args = ['.']
 
     for fs, path, is_dir in self.get_resources(args, single=True):                            
         if not is_dir:
             self.error(u"'%s' is not a dir\n" % path)
             return 1
         fs.cache_hint(True)
         if options.gui:
             from fs.browsewin import browse
             if path:
                 fs = fs.opendir(path)
             browse(fs, hide_dotfiles=not options.all)
         else:
             if options.depth < 0:
                 max_levels = None
             else:
                 max_levels = options.depth
             print_fs(fs, path or '',
                      file_out=self.output_file,
                      max_levels=max_levels,
                      terminal_colors=self.terminal_colors,
                      hide_dotfiles=not options.all,
                      dirs_first=options.dirsfirst)        
Пример #3
0
 def browse(self, hide_dotfiles=False):
     """Displays the FS tree in a graphical window (requires wxPython)
     
     :param hide_dotfiles: If True, files and folders that begin with a dot will be hidden
     
     """
     from fs.browsewin import browse
     browse(self, hide_dotfiles)
Пример #4
0
    def do_run(self, options, args):

        if not args:
            args = ['.']

        for fs, path, is_dir in self.get_resources(args, single=True):
            if not is_dir:
                self.error("'%s' is not a dir\n" % path)
                return 1
            fs.cache_hint(True)
            if options.gui:
                from fs.browsewin import browse
                if path:
                    fs = fs.opendir(path)
                browse(fs, hide_dotfiles=not options.all)
            else:
                if options.depth < 0:
                    max_levels = None
                else:
                    max_levels = options.depth
                self.output(self.wrap_dirname(args[0] + '\n'))
                dircount, filecount = print_fs(
                    fs,
                    path or '',
                    file_out=self.output_file,
                    max_levels=max_levels,
                    terminal_colors=self.terminal_colors,
                    hide_dotfiles=not options.all,
                    dirs_first=options.dirsfirst,
                    files_wildcard=options.pattern,
                    dirs_only=options.dirsonly)
                self.output('\n')

                def pluralize(one, many, count):
                    if count == 1:
                        return '%i %s' % (count, one)
                    else:
                        return '%i %s' % (count, many)

                self.output("%s, %s\n" %
                            (pluralize('directory', 'directories', dircount),
                             pluralize('file', 'files', filecount)))
Пример #5
0
    def do_run(self, options, args):

        if not args:
            args = ['.']

        for fs, path, is_dir in self.get_resources(args, single=True):
            if not is_dir:
                self.error(u"'%s' is not a dir\n" % path)
                return 1
            fs.cache_hint(True)
            if options.gui:
                from fs.browsewin import browse
                if path:
                    fs = fs.opendir(path)
                browse(fs, hide_dotfiles=not options.all)
            else:
                if options.depth < 0:
                    max_levels = None
                else:
                    max_levels = options.depth
                self.output(self.wrap_dirname(args[0] + '\n'))
                dircount, filecount = print_fs(fs, path or '',
                                               file_out=self.output_file,
                                               max_levels=max_levels,
                                               terminal_colors=self.terminal_colors,
                                               hide_dotfiles=not options.all,
                                               dirs_first=options.dirsfirst,
                                               files_wildcard=options.pattern,
                                               dirs_only=options.dirsonly)
                self.output('\n')
                def pluralize(one, many, count):
                    if count == 1:
                        return '%i %s' % (count, one)
                    else:
                        return '%i %s' % (count, many)

                self.output("%s, %s\n" % (pluralize('directory', 'directories', dircount),
                                  pluralize('file', 'files', filecount)))
Пример #6
0
    def browse(self):
        """Displays the FS tree in a graphical window (requires wxWidgets)"""
        from fs.browsewin import browse

        browse(self)
Пример #7
0
                src,
                dst,
                overwrite=False,
                ignore_errors=False,
                chunk_size=16384):
        self.clear_dircache(dirname(dst))
        super(FTPFS, self).copydir(src, dst, overwrite, ignore_errors,
                                   chunk_size)


if __name__ == "__main__":

    ftp_fs = FTPFS('ftp.ncsa.uiuc.edu')
    ftp_fs.cache_hint(True)
    from fs.browsewin import browse
    browse(ftp_fs)

    #ftp_fs = FTPFS('127.0.0.1', 'user', '12345', dircache=True)
    #f = ftp_fs.open('testout.txt', 'w')
    #f.write("Testing writing to an ftp file!")
    #f.write("\nHai!")
    #f.close()

    #ftp_fs.createfile(u"\N{GREEK CAPITAL LETTER KAPPA}", 'unicode!')

    #kappa = u"\N{GREEK CAPITAL LETTER KAPPA}"
    #ftp_fs.makedir(kappa)

    #print repr(ftp_fs.listdir())

    #print repr(ftp_fs.listdir())
Пример #8
0
 def browse(self):
     """Displays the FS tree in a graphical window (requires wxPython)"""
     from fs.browsewin import browse
     browse(self)
Пример #9
0
        self.clear_dircache(dirname(src), dirname(dst))
        super(FTPFS, self).movedir(src, dst, overwrite, ignore_errors, chunk_size)

    @ftperrors
    def copydir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=16384):
        self.clear_dircache(dirname(dst))
        super(FTPFS, self).copydir(src, dst, overwrite, ignore_errors, chunk_size)


if __name__ == "__main__":

    ftp_fs = FTPFS("ftp.ncsa.uiuc.edu")
    ftp_fs.cache_hint(True)
    from fs.browsewin import browse

    browse(ftp_fs)

    # ftp_fs = FTPFS('127.0.0.1', 'user', '12345', dircache=True)
    # f = ftp_fs.open('testout.txt', 'w')
    # f.write("Testing writing to an ftp file!")
    # f.write("\nHai!")
    # f.close()

    # ftp_fs.createfile(u"\N{GREEK CAPITAL LETTER KAPPA}", 'unicode!')

    # kappa = u"\N{GREEK CAPITAL LETTER KAPPA}"
    # ftp_fs.makedir(kappa)

    # print repr(ftp_fs.listdir())

    # print repr(ftp_fs.listdir())