Identify named pipes and sockets
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 297
- Fork
- 179
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pre-commit/identify
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
pre-commit/identify#103 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
pre-commit/identify#61 · 2 commenti ·
Tutte le issue di pre-commit/identify
Issue simili
-
link-check link-check:sphinx-theme
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
OpenHands/extensions#626 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
CSCfi/sd-search-api#39 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100