def getSourceCode(url, proxy, returnRedirctUrl = False, maxRetries=1, waitRetryTime=1):
	if (proxy is not None):
		if (NO_SOCKS):
			raise FatalError('socks library required to use proxy (e.g. SocksiPy)')
		proxySettings = proxy.split(':')
		socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, proxySettings[0], int(proxySettings[1]), True)
		socket.socket = socks.socksocket
				
	global urlReqHeaders
	
	ret = None
	request = urllib2.Request(url, headers=urlReqHeaders) 
	
	while (ret == None): 
		try:
			f = urllib2.urlopen(request)
			encoding = f.headers.get('Content-Encoding')
					
			if encoding == None:
				ret = f.read()
			else:
				if encoding.upper() == 'GZIP': 
					compressedstream = io.BytesIO(f.read()) 
					gzipper = gzip.GzipFile(fileobj=compressedstream)
					ret = gzipper.read()
				else:
					raise FatalError('Unknown HTTP Encoding returned')
		except urllib2.URLError:
			if (maxRetries == 0):
				break
			else:
				# random dist. for further protection against anti-leech
				# idea from wget
				time.sleep(random.uniform(0.5*waitRetryTime, 1.5*waitRetryTime))
				maxRetries -= 1

	if returnRedirctUrl:
		return ret, f.geturl()
	else:
		return ret
If we're not running under a POSIX system, just simulate the daemon
dataset/ETHPy150Open jiaweihli/manga_downloader/src/util.py/getSourceCode--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/utils/daemonize.py/become_daemon