how to do with file line on windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
i need to deal with line of file on windows,but failed. it seems the coding problem
Setup
i use the python api and the file.line module:
local.cmd(tgt=s,fun='file.line',arg=[filepath],kwarg={'content':contents,'mode':'ensure','before':""})
get error report
The minion function caused an exception: Traceback (most recent call last):\n File "c:\salt\bin\lib\site-packages\salt\minion.py", line 1660, in thread_return\n return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)\n File "c:\salt\bin\lib\site-packages\salt\executors\direct_call.py", line 12, in execute\n return func(*args, **kwargs)\n File "c:\salt\bin\lib\site-packages\salt\modules\file.py", line 2050, in line\n path_content = salt.utils.data.decode_list(fp.read().splitlines(True))\nUnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 586: illegal multibyte sequence\n
Versions Report
Salt Version:
Salt: 2019.2.0
Dependency Versions:
cffi: 1.12.3
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.10.1
libgit2: 0.28.2
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.1
mysql-python: Not Installed
pycparser: 2.19
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.28.2
Python: 3.6.8 (default, Apr 25 2019, 21:02:35)
python-gnupg: Not Installed
PyYAML: 5.1.2
PyZMQ: 18.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist: centos 7.6.1810 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-957.27.2.el7.x86_64
system: Linux
version: CentOS Linux 7.6.1810 Core
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading salt/modules/file.py around line 2050 and reproducing the reported Python API call to file.line with the supplied contents. Check the discrepancy between the Windows description and the CentOS traceback; done means the file.line operation handles the reported encoding case without the UnicodeDecodeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100