← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #262180]: How i can import json module in my scripts

 

Question #262180 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/262180

    Status: Answered => Open

Chp is still having a problem:
I am sorry that I could not answer you right away.

What problems do you have with urllib2 in version 1.1.0? -->
In my tests I need to constantly send requests to the server to install or get some data. Here is my code:
def delete(self, User):
	API.log('Admin user delete:')
	params = {
		'authenticity_token'	:self.authenticity_token,
		'_method'				:'delete',
	}
	data = urllib.urlencode(params)
	url = self.url+'/users/'+User.dict['dw_id']+'/game_data'
	self.go_url(url, data)
	API.log('Admin user delete DONE!')

@trust_all_certificates
def go_url(self, url, data = None, headers = {}):
	request = urllib2.Request(url, data, headers)
	try:
		response = self.opener.open(request)
	except IOError, e:
		if hasattr(e, 'reason'):
			self.game.error('We failed to reach a server. Reason: '+str(e.reason))
		elif hasattr(e, 'code'):
			self.game.error('The server couldn\'t fulfill the request. Error code: '+str(e.code))
	return response

On jython2.5.2 it works well, but sometimes in jython 2.7 (not always),
an error: ERROR: We failed to reach a server. Reason: [Errno 32] Illegal
state exception

The problem I could not fix.
Now try to download the jar file, if that otpishus

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.