forked from askeing/B2G-flash-tool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flash_local.py
executable file
·81 lines (66 loc) · 2.56 KB
/
flash_local.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/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
from sys import platform as _platform
from Tkinter import Tk
from tkFileDialog import askopenfilename
from tkMessageBox import askquestion
from tkMessageBox import askyesno
def main():
window = Tk()
window.option_add('*Dialog.msg.wrapLength', '10i')
window.withdraw()
ret = askyesno('Flash Local', 'It will shallow flash gaia/gecko from local file system.', icon='info')
if ret:
pass
else:
quit()
is_flash_gaia = False
GAIA_FILEOPENOPTIONS = {'title': 'Select the Gaia package (gaia.zip)', 'defaultextension': '.zip', 'filetypes': [('Zip file', '*.zip'), ('All files', '*.*')]}
gaia_filename = askopenfilename(**GAIA_FILEOPENOPTIONS)
if gaia_filename:
is_flash_gaia = True
is_flash_gecko = False
GECKO_FILEOPENOPTIONS = {'title': 'Select the Gecko package (b2g-xxx.android-arm.tar.gz)', 'defaultextension': '.tar.gz', 'filetypes': [('Gzip file', '*.tar.gz'), ('All files', '*.*')]}
gecko_filename = askopenfilename(**GECKO_FILEOPENOPTIONS)
if gecko_filename:
is_flash_gecko = True
if not is_flash_gaia and not is_flash_gecko:
quit()
comfirm_message = 'Are You Sure?\n'
if is_flash_gaia:
comfirm_message = comfirm_message + '\nGaia:\n%s\n' % gaia_filename
if is_flash_gecko:
comfirm_message = comfirm_message + '\nGecko:\n%s\n' % gecko_filename
ret = askyesno('Comfirm', comfirm_message, icon='warning')
if ret:
do_flash(is_flash_gaia, gaia_filename, is_flash_gecko, gecko_filename)
comfirm_message = "Flash next device. " + comfirm_message
while True:
ret = askyesno('Comfirm', comfirm_message, icon='warning')
if ret:
do_flash(is_flash_gaia, gaia_filename, is_flash_gecko, gecko_filename)
else:
quit()
else:
quit()
def quit():
print "Bye"
exit(0)
def do_flash(is_flash_gaia, gaia_filename, is_flash_gecko, gecko_filename, keep_profile=False):
cmd = './shallow_flash.sh -y'
sp = ''
if _platform == 'darwin':
sp = ' '
if is_flash_gaia:
cmd = cmd + ' -g' + sp + gaia_filename
if is_flash_gecko:
cmd = cmd + ' -G' + sp + gecko_filename
if keep_profile:
cmd = cmd + ' --keep_profile'
print('run command: ' + cmd)
os.system(cmd)
if __name__ == '__main__':
main()