Identify named pipes and sockets
还没有人认领这个 Issue。
评估
调研方向
Start with identify/identify.py, especially tags_from_path, file_is_text, and parse_shebang_from_file, using the named-pipe and socket reproductions in the issue. Review Python's stat module as suggested. Done means identify-cli no longer hangs on named pipes or raises an error for socket files, with behavior for these file types established.
由索引模型根据 Issue 内容生成。
描述
The current version (v1.4.0) can not identify named pipes and socket files.
I do not know if identify should work on this type of files, but I can show the reproduction, and can add a suggestion for fixing it.
Reproduction for named-pipes (in the last command it hangs):
$ mkfifo /tmp/my-custom-named-pipe
$ file /tmp/my-custom-named-pipe
/tmp/my-custom-named-pipe: fifo (named pipe)
$ identify-cli /tmp/my-custom-named-pipe
bt:
^CTraceback (most recent call last):
File "/usr/local/bin/identify-cli", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/identify/cli.py", line 23, in main
tags = sorted(func(args.path))
File "/usr/local/lib/python3.6/dist-packages/identify/identify.py", line 66, in tags_from_path
if file_is_text(path):
File "/usr/local/lib/python3.6/dist-packages/identify/identify.py", line 128, in file_is_text
with open(path, 'rb') as f:
KeyboardInterrupt
Reproduction for socket files:
$ python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/tmp/my-custom-socket')"
$ file /tmp/my-custom-socket
/tmp/my-custom-socket: socket
$ identify-cli /tmp/my-custom-socket
bt:
Traceback (most recent call last):
File "/usr/local/bin/identify-cli", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/identify/cli.py", line 23, in main
tags = sorted(func(args.path))
File "/usr/local/lib/python3.6/dist-packages/identify/identify.py", line 59, in tags_from_path
shebang = parse_shebang_from_file(path)
File "/usr/local/lib/python3.6/dist-packages/identify/identify.py", line 172, in parse_shebang_from_file
with open(path, 'rb') as f:
OSError: [Errno 6] No such device or address: '/tmp/my-custom-socket'
My suggestion to fix these issues is to use stat module of python. With the help of this modul identify could check all other file types as well.
URL: https://docs.python.org/3/library/stat.html
If possible I can propose a PR with pleasure.
- 主要语言
- Python
- 星标
- 297
- 派生
- 179
- 平均合并
- 10 天 3 小时
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pre-commit/identify 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 48/100
pre-commit/identify#103 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
pre-commit/identify#61 · 2 条评论 ·
查看 pre-commit/identify 的全部 Issue
相似的 Issue
-
bug frontend
难度 2/5 1-3 小时 新手友好度 85/100
PedestrianDynamics/pyFDS-Evac#552 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
resend/resend-skills#144 ·
维护者通常 1 天内回复
-
good first issue
难度 1/5 1 小时以内 新手友好度 68/100
-
Bug
难度 2/5 1-3 小时 新手友好度 72/100
GNS3/gns3-server#2935 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
TauricResearch/TradingAgents#1476 ·
维护者通常 2 天内回复