-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulk_flasher.py
executable file
·56 lines (48 loc) · 1.94 KB
/
bulk_flasher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import sys
import subprocess
import argparse
from utilities.arg_parse import Parser
from controller.console_controller import ConsoleApp
from utilities.console_dialog import ConsoleDialog
from utilities.adb_helper import AdbHelper
from utilities.path_parser import PathParser
def ArgParse(input):
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--full_flash', help='flash full image of device')
parser.add_argument('-g', '--gaia', help='shallow flash gaia into device')
parser.add_argument('-G', '--gecko', help='shallow flash gaia into device')
options = parser.parse_args(input)
return options
def main():
if not AdbHelper.has_adb():
print("No adb installed; terminated")
sys.exit(1)
options = ArgParse(sys.argv[1:])
try:
archive = {}
prog = ConsoleApp()
if option.full_flash:
archives[PathParser._IMAGES] = option.full_flash
else:
if option.gecko:
archives[PathParser._GECKO] = option.gecko
if option.gaia:
archives[PathParser._GAIA] = option.gaia
if not archive:
print("Nothing to flash; terminated")
return sys.exit(1)
ret_obj = prog.dialog.yes_no('Bulk Flasher Prompt', 'Warning: this program will flash all devices! Please make sure devices are the same. continue? (y/N)', ConsoleDialog._NO_CMD_INDEX)
devices = AdbHelper.adb_devices().keys()
for serial in devices:
prog.do_flash(self.flash_params, archives, serial, keep_profile=self.target_keep_profile)
except KeyboardInterrupt:
print ''
print '### Quit'
sys.exit(0)
if __name__ == '__main__':
main()