I'm writing a script to log disk usage on all our hosts to a central DB server. This works fine on one host, but on a different host I'm getting an error:
Doing a little more investigation, I was able to replicate the problem on the first host by running
I was unaware that Python includes the subprocess.run module, but apparently the version installed with Pip is faulty? Can someone explain what happened here?
Output:# python36 Python 3.6.8 (default, Apr 25 2019, 21:02:35) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> df = subprocess.run(['df','-m'], universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/site-packages/run/__init__.py", line 145, in __new__ process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell) File "/usr/local/lib/python3.6/site-packages/run/__init__.py", line 121, in create_process shlex.split(command), File "/usr/lib64/python3.6/shlex.py", line 305, in split return list(lex) File "/usr/lib64/python3.6/shlex.py", line 295, in __next__ token = self.get_token() File "/usr/lib64/python3.6/shlex.py", line 105, in get_token raw = self.read_token() File "/usr/lib64/python3.6/shlex.py", line 136, in read_token nextchar = self.instream.read(1) AttributeError: 'list' object has no attribute 'read' >>>Both hosts are running CentOS 7 and Python 3.6.8Doing a little more investigation, I was able to replicate the problem on the first host by running
pip3 install subprocess.run. I then ran pip3 uninstall subprocess.run on both hosts and was able to get things working again. I was unaware that Python includes the subprocess.run module, but apparently the version installed with Pip is faulty? Can someone explain what happened here?
