예제 #1
0
파일: handler.py 프로젝트: net9/ftp9
 def log_cmd(self, cmd, arg, respcode, respstr):
     """derived method"""
     if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
         arg = relpath(arg)
         if respcode < 400:
             self.log(u'{0} {1}: {2}'.format(cmd, arg, respcode),
                     _log_modify)
         else:
             self.log(u'{0} {1}: {2} {3}'.format(cmd, arg, respcode,
                 respstr.decode(config.FILESYSTEM_ENCODING)), _log_modify)
예제 #2
0
파일: handler.py 프로젝트: net9/ftp9
 def log_transfer(self, cmd, filename, receive, completed, elapsed, bytes):
     """derived method"""
     if elapsed > 0:
         filename = relpath(filename)
         size = human_readable_filesize(bytes)
         speed = human_readable_filesize(bytes / elapsed) + '/s'
         msg = u'{0} {1}: size={2} time={3:.1f}sec speed={4}'.format(
                 cmd, filename, size, elapsed, speed)
         if not completed:
             msg += ' [uncompleted]'
         if receive:
             self.log(msg, _log_modify)
         else:
             self.log(msg, _log_access)
예제 #3
0
파일: group.py 프로젝트: net9/ftp9
        def walk(node, rootdir):
            path2grp[rootdir] = node

            create_list = set([i.name for i in node.children])
            if node is self._root:
                create_list.add(config.ROOT_PUB_NAME)
            else:
                create_list.add(config.PUBLIC_NAME)
                create_list.add(config.PRIVATE_NAME)

            remove_list = set()
            if os.path.isdir(rootdir):
                for i in os.listdir(rootdir):
                    if os.path.isdir(pjoin(rootdir, i)):
                        remove_list.add(fs_enc(i))

            intersect = create_list & remove_list
            create_list -= intersect
            remove_list -= intersect

            for i in create_list:
                os.makedirs(pjoin(rootdir, i))

            for i in remove_list:
                p0 = pjoin(rootdir, i)
                if config.FTP_DISCARDEDGRP_SAVEDIR:
                    tgt_dir = pjoin(
                            config.FTP_DISCARDEDGRP_SAVEDIR,
                            self._timestamp,
                            relpath(rootdir))
                    if not os.path.isdir(tgt_dir):
                        os.makedirs(tgt_dir)
                    shutil.move(p0, tgt_dir)
                else:
                    shutil.rmtree(p0)

            for i in node.children:
                walk(i, pjoin(rootdir, i.name))