import urllib.request, re
from urllib.error import URLError, HTTPError

def get_update_info(url):
	val = ''
	try:
		res = urllib.request.urlopen(url, None, 10)
		if res is None:
			val = 'Timeout'
		else:
			enc = 'utf-8'
			ct = res.getheader('Content-Type')
			if re.search('^text', ct) is not None:
				m = re.search('charset=([\w\-]+)', ct, re.I)
				if m is not None: enc = m.group(1)

			val = res.read().decode(enc)
	except HTTPError as e:
		val = 'HTTPError:' + str(e.code)
	except URLError as e:
		val = 'URLError:' + str(e.reason)
	except:
		val = 'UnknownError'

	return val
