traverse.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:FTPwalker 作者: Bohdan-Khomtchouk 项目源码 文件源码
def main_run(self, args):
        """
        .. py:attribute:: main_run()
        Run threads by passing a leading directory to `traverse_branch` function.

           :param args: a tuple contain root and another tuple contains base and
           leadings. The root is the path of parent directory (assigned to a process)
           base is a tuple contain the path of sub-directory and file names that are
           associated with.
           :type args: iterable
           :rtype: None

        """
        if self.resume:
            root, leadings = args
            base = ['/']
        else:
            root, (base, leadings) = args
        print ('---' * 5, datetime.now(), '{}'.format(root), '---' * 5)
        try:
            # base, leadings = self.find_leading(root)
            # print("base and leadings for {} --> {}, {}".format(root, base, leadings))
            if not self.resume:
                leadings = [(ospath.join('/', root, i.strip('/')), root) for i in leadings]
            if leadings:
                pool = ThreadPool()
                pool.map(self.traverse_branch, leadings)
                pool.close()
                pool.join()
            else:
                self.all_path.put(base[0])
        except (ftplib.error_temp, ftplib.error_perm, socket.gaierror) as exp:
            print(exp)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号