nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Process cmdline on Windows does not show quotation marks #118

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
======================================================================
FAIL: test_process_cmdline (_windows.WindowsSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\user\Desktop\svn\psutil\test\_windows.py", line 96, in test_process_cmdline
    self.assertEqual(' '.join(p.cmdline), w.CommandLine)
AssertionError: 'C:\\Python27\\python.exe -c import time; time.sleep(3600);' != 
u'C:\\Python27\\python.exe -c "import time; time.sleep(3600);"'

----------------------------------------------------------------------

Verified that both procexp and process hacker tools do not have this issue.
I took a look at process_info.c and didn't notice anything weird so I have no 
clue on where I might look.

Original issue reported on code.google.com by g.rodola on 17 Oct 2010 at 8:17

GoogleCodeExporter commented 8 years ago
It's because you call CommandLineToArgvW, and its purpose is to parse the 
command line string to remove quotes and backslashes...

Original comment by wj32...@gmail.com on 18 Oct 2010 at 5:17

GoogleCodeExporter commented 8 years ago
Hints on what to use as replacement?

Original comment by g.rodola on 18 Oct 2010 at 5:20

GoogleCodeExporter commented 8 years ago
We're returning an array of process arguments, not a string...  I would think 
this is expected behavior. This is similar to what you get from sys.argv where 
the arguments are already parsed, which is what CommandLineToArgvW is supposed 
to do, and we return the corresponding array of strings as a Python list.

Original comment by jlo...@gmail.com on 18 Oct 2010 at 6:44

GoogleCodeExporter commented 8 years ago
Verified that the same thing happens on Linux and BSD/OSX.
Thinking back I guess it's ok to return strings without quotation marks as 
well, also because that's what you would pass to subprocess.Popen in case you 
want to attempt to restart the process, for example.
I'm going to close this out and modify the test case.

Original comment by g.rodola on 19 Oct 2010 at 3:25