How to 'convert' variable of type instance

2019-04-17 05:28发布

问题:

I'm using https://code.google.com/p/python-ntlm/ for authenticating and then using a system call to get the response from YSlow. I am not quite sure on how to 'convert' the needed info to a variable that will provide me the response I desire. I tried other solutions...but here I am...

user = 'domain\userName'
password = "password"
url = "http://someUrlHere.com"
# User must be granted access in order for script to work...

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, password)

# create the NTLM authentication handler
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)

# create and install the opener
opener = urllib2.build_opener(auth_NTLM)
urllib2.install_opener(opener)

# retrieve the result
response = urllib2.urlopen(url)

call(["phantomjs", "yslow.js", "--info", "basic", "--format", "plain", response])

I've tried passing other variables from this same script, but none seemed to give me the response I'm looking for. The glorious error message when I run this is

Traceback (most recent call last):
File "c:\Python27\lib\site-packages\nose-1.3.0-py2.7.egg\nose\case.py", line 1
97, in runTest
self.test(*self.arg)
File "c:\Users\XXX\Desktop\commandLineTools\phantomjs-1.9.2-win
dows\NTLM_AUTH.py", line 35, in getTheResponse
call(["phantomjs", "yslow.js", "--info", "basic", "--format", "plain", respo
nse])
File "c:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "c:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "c:\Python27\lib\subprocess.py", line 912, in _execute_child
args = list2cmdline(args)
File "c:\Python27\lib\subprocess.py", line 616, in list2cmdline
needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: argument of type 'instance' is not iterable