pjl.py 文件源码

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

项目:PRET 作者: RUB-NDS 项目源码 文件源码
def dirlist(self, path, sep=True, hidden=False, dirsonly=False, r=True):
    # get remote path if not in recursive mode
    if r: path = self.rpath(path)
    # receive list of files on remote device
    str_recv = self.cmd('@PJL FSDIRLIST NAME="' + path + '" ENTRY=1 COUNT=65535')
    list = {}
    for item in str_recv.splitlines():
      # get directories
      dirname = re.findall("^(.*)\s+TYPE\s*=\s*DIR$", item)
      if dirname and (dirname[0] not in ("", ".", "..") or hidden):
        sep = c.SEP if sep and dirname[0][-1:] != c.SEP else ''
        list[dirname[0] + sep] = None
      # get files
      filename = re.findall("^(.*)\s+TYPE\s*=\s*FILE", item)
      filesize = re.findall("FILE\s+SIZE\s*=\s*(\d*)", item)
      if filename and filesize and not dirsonly:
        list[filename[0]] = filesize[0]
    return list

  # ------------------------[ ls <path> ]-------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号