-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_menu.py
46 lines (44 loc) · 1.5 KB
/
main_menu.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
from tools import sdcard
from tools.menu import Menu, MenuItem
from tools.prompt import ask_yes_no
from flash.standard import Standard
from tools.command_line import CommandLine
from tools.utils import get_save_path
from os import path
import os
INSTALL = 'install'
YOCTO = 'yocto'
m = Menu()
m.query = 'Please choose a task'
m.items.append(MenuItem('Install a distro to Micro SD', INSTALL))
m.items.append(MenuItem('Setup the image build environment', YOCTO))
m.items.append(MenuItem('Exit', ''))
option = m.show()
if option == INSTALL:
if not os.geteuid()==0:
exit("You must be root to run this action, please use sudo and try again.")
import distros
while True:
distro = distros.select()
if CommandLine.peek_next():
break
print distro.get_description()
print 'There is an option to download this distro' if distro.can_download() else 'You must have already downloaded an image in order to install this distro.'
print '\n',
if ask_yes_no('Would you like to install ' + distro.get_name() + '?', True):
break
distro.install(sdcard.select_card())
elif option == YOCTO:
from tools import yocto
SETUP = 'setup'
DEPENDS = 'dependencies'
y = Menu()
y.query = 'Please choose a task'
y.items.append(MenuItem('setup Yocto', SETUP))
y.items.append(MenuItem('', DEPENDS))
y.items.append(MenuItem('Exit', ''))
option = y.show()
if option == SETUP:
yocto.setup(path.join(get_save_path(), 'yocto'))
elif option == DEPENDS:
yocto.get_dependencies(CommandLine.get_next())