Skip to content

Commit 0bb47c6

Browse files
Cleanup busy dialogs
1 parent 662d9b4 commit 0bb47c6

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

lib/inputstreamhelper.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,18 @@ def _http_request(self, download=False, message=None):
173173
"""Makes HTTP request and displays a progress dialog on download."""
174174
self._log('Request URL: {0}'.format(self._url))
175175
filename = self._url.split('/')[-1]
176-
busy_dialog = xbmcgui.DialogBusy()
177176
dialog = xbmcgui.Dialog()
178177

179178
try:
180-
busy_dialog.create()
181179
req = requests.get(self._url, stream=download, verify=False)
182180
self._log('Response code: {0}'.format(req.status_code))
183181
if not download:
184182
self._log('Response: {0}'.format(req.content))
185183
req.raise_for_status()
186184
except requests.exceptions.HTTPError:
187-
busy_dialog.close()
188185
dialog.ok(self._language(30004), self._language(30013).format(filename))
189186
return False
190187

191-
busy_dialog.close()
192188
if download:
193189
if not message: # display "downloading [filename]"
194190
message = self._language(30015).format(filename)
@@ -322,13 +318,17 @@ def _install_widevine_cdm_x86(self):
322318

323319
downloaded = self._http_request(download=True)
324320
if downloaded:
321+
busy_dialog = xbmcgui.DialogBusy()
322+
busy_dialog.create()
325323
self._unzip_cdm()
326324
self._install_cdm()
327325
self._cleanup()
328326
if self._has_widevine_cdm():
329327
dialog.ok(self._language(30001), self._language(30003))
328+
busy_dialog.close()
330329
return True
331330
else:
331+
busy_dialog.close()
332332
dialog.ok(self._language(30004), self._language(30005))
333333

334334
return False
@@ -358,40 +358,39 @@ def _install_widevine_cdm_arm(self):
358358
downloaded = self._http_request(download=True, message=self._language(30022))
359359
if downloaded:
360360
dialog.ok(self._language(30023), self._language(30024))
361+
busy_dialog = xbmcgui.DialogBusy()
362+
busy_dialog.create()
361363
if not self._unzip_bin() or not self._losetup() or not self._mnt_loop_dev():
362364
self._cleanup()
365+
busy_dialog.close()
363366
return False
364367
else:
365368
self._extract_cdm_from_img()
366369
self._install_cdm()
367370
self._cleanup()
368371
if self._has_widevine_cdm():
369372
dialog.ok(self._language(30001), self._language(30003))
373+
busy_dialog.close()
370374
return True
371375
else:
376+
busy_dialog.close()
372377
dialog.ok(self._language(30004), self._language(30005))
373378

374379
return False
375380

376381
def _extract_cdm_from_img(self):
377-
busy_dialog = xbmcgui.DialogBusy()
378-
busy_dialog.create()
379382
"""Extract the Widevine CDM binary from the mounted Chrome OS image."""
380383
for root, dirs, files in os.walk(self._mnt_path()):
381384
for filename in files:
382385
if 'widevinecdm' in filename and filename.endswith(config.CDM_EXTENSIONS):
383386
shutil.copyfile(os.path.join(root, filename), os.path.join(self._cdm_path(), filename))
384-
busy_dialog.close()
385387
return True
386388

387-
busy_dialog.close()
388389
self._log('Failed to find Widevine CDM binary in Chrome OS image.')
389390
return False
390391

391392
def _install_cdm(self):
392393
"""Loop through local cdm folder and symlink/copy binaries to inputstream cdm_path."""
393-
busy_dialog = xbmcgui.DialogBusy()
394-
busy_dialog.create()
395394
for cdm_file in os.listdir(self._cdm_path()):
396395
if cdm_file.endswith(config.CDM_EXTENSIONS):
397396
cdm_path_addon = os.path.join(self._cdm_path(), cdm_file)
@@ -401,32 +400,23 @@ def _install_cdm(self):
401400
else:
402401
os.symlink(cdm_path_addon, cdm_path_inputstream)
403402

404-
busy_dialog.close()
405403
return True
406404

407405
def _unzip_bin(self):
408-
busy_dialog = xbmcgui.DialogBusy()
409406
zip_obj = zipfile.ZipFile(self._download_path)
410-
busy_dialog.create()
411407
for filename in zip_obj.namelist():
412408
if filename.endswith('.bin'):
413409
zip_obj.extract(filename, self._temp_path())
414-
busy_dialog.close()
415410
self._bin_path = os.path.join(self._temp_path(), filename)
416411
return True
417412

418413
def _unzip_cdm(self):
419-
busy_dialog = xbmcgui.DialogBusy()
420-
busy_dialog.create()
421414
zip_obj = zipfile.ZipFile(self._download_path)
422415
zip_obj.extractall(self._cdm_path())
423-
busy_dialog.close()
424416
return True
425417

426418
def _cleanup(self):
427419
"""Clean up after Widevine DRM installation."""
428-
busy_dialog = xbmcgui.DialogBusy()
429-
busy_dialog.create()
430420
if self._mounted:
431421
cmd = ['umount', self._mnt_path()]
432422
subprocess.check_call(cmd)
@@ -437,7 +427,6 @@ def _cleanup(self):
437427
self._loop_dev = False
438428

439429
shutil.rmtree(self._temp_path())
440-
busy_dialog.close()
441430
return True
442431

443432
def _supports_hls(self):

0 commit comments

Comments
 (0)