MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / check_updates

Function check_updates

bleachbit/Update.py:100–149  ·  view source on GitHub ↗

Check for updates via the Internet

(check_beta, check_winapp2, append_text, cb_success)

Source from the content-addressed store, hash-verified

98
99
100def check_updates(check_beta, check_winapp2, append_text, cb_success):
101 """Check for updates via the Internet"""
102 url = bleachbit.update_check_url
103 if 'windowsapp' in sys.executable.lower():
104 url += '?windowsapp=1'
105 try:
106 response = fetch_url(url,
107 headers=get_update_request_headers())
108 except requests.RequestException as e:
109 logger.error(
110 _('Error when opening a network connection to check for updates. Please verify the network is working and that a firewall is not blocking this application. Error message: {}').format(e))
111 logger.debug('URL %s has IP address %s', url, get_ip_for_url(url))
112 if hasattr(e, 'response') and e.response is not None:
113 logger.debug(e.response.headers)
114 return ()
115 try:
116 dom = xml.dom.minidom.parseString(response.text)
117 except:
118 logger.exception(
119 'The update information does not parse: %s', response.text)
120 return ()
121
122 def parse_updates(element):
123 if element:
124 ver = element[0].getAttribute('ver')
125 url = element[0].firstChild.data
126 assert isinstance(ver, str)
127 assert isinstance(url, str)
128 assert url.startswith('http')
129 return ver, url
130 return ()
131
132 stable = parse_updates(dom.getElementsByTagName("stable"))
133 beta = parse_updates(dom.getElementsByTagName("beta"))
134
135 wa_element = dom.getElementsByTagName('winapp2')
136 if check_winapp2 and wa_element:
137 wa_sha512 = wa_element[0].getAttribute('sha512')
138 wa_url = wa_element[0].getAttribute('url')
139 update_winapp2(wa_url, wa_sha512, append_text, cb_success)
140
141 dom.unlink()
142
143 if stable and beta and check_beta:
144 return (stable, beta)
145 if stable:
146 return (stable,)
147 if beta and check_beta:
148 return (beta,)
149 return ()

Calls 6

fetch_urlFunction · 0.90
get_ip_for_urlFunction · 0.90
parse_updatesFunction · 0.85
update_winapp2Function · 0.85
getAttributeMethod · 0.45