66
67
class install(Thread):
67
68
def __init__(self, source, target, persist, device=None,
68
allow_system_internal=False):
69
allow_system_internal=False,
69
71
Thread.__init__(self)
70
72
self.source = source
71
73
self.target = target
72
74
self.persist = persist
73
75
self.device = device
74
76
self.allow_system_internal = allow_system_internal
77
self.fastboot_mode = fastboot_mode
75
78
self._stopevent = Event()
76
79
self.progress_thread = None
77
80
logging.debug('install thread source: %s' % source)
137
140
if ext not in ['.iso', '.img']:
138
141
self._failure(_('The extension "%s" is not supported.') %
143
if self.fastboot_mode:
144
self.bootimg = os.path.splitext(self.source)[0] + '.bootimg'
145
if not os.path.isfile(self.bootimg):
146
self._failure(_('Missing matching "%s" for source image %s.') %
147
(self.bootimg, self.source))
148
self.fastboot_install()
141
150
if sys.platform == 'win32':
142
151
self.cdimage_install()
394
403
except dbus.DBusException:
395
404
self._failure(failure_msg)
406
def _fastboot_command(self, cmd):
407
fastboot_cmd = ['fastboot', '-s', self.target]
408
fastboot_cmd.extend(cmd)
411
def fastboot_install(self):
412
self.progress(0, 3*60+9, True)
413
self.progress_message(_('Erasing boot partition...'))
414
self._fastboot_command(['erase', 'boot'])
415
self.progress(5, 3*60+7, True)
416
self.progress_message(_('Erasing user partition...'))
417
self._fastboot_command(['erase', 'userdata'])
418
self.progress(10, 3*60+5, True)
419
self.progress_message(_('Flashing boot partition...'))
420
self._fastboot_command(['flash', 'boot', self.bootimg])
421
self.progress(15, 3*60+3, True)
422
self.progress_message(_('Flashing user partition...'))
423
self.progress_pulse()
424
self._fastboot_command(['flash', 'userdata', self.source])
425
self.progress_pulse_stop()
426
self.progress(95, 1, True)
427
self.progress_message(_('Rebooting device...'))
428
self._fastboot_command(['reboot'])
429
self.progress(100, 0, True)
397
431
def cdimage_install(self):