Exemple #1
0
def select_card(only_valid=False):
    m = Menu()
    m.query = "Please Select your Micro SD card"
    m.items = []
    cards = detect_cards()
    if CommandLine.peek_next():
        device = CommandLine.get_next()
        return filter(lambda card: card.device == device, cards)[0]
    for card in cards:
        if not only_valid or card.is_created():
            m.items.append(MenuItem(card.device, card))
    return m.show()
Exemple #2
0
 def install(self, sdcard):
   params = self.files_needed()
   files = dict.fromkeys(params.values())
   nextCommand = CommandLine.peek_next()
   download = nextCommand and nextCommand == '-d'
   if not download:
     while CommandLine.peek_next():
       key, file = CommandLine.get_next().split('=')
       files[params[key]] = file
   if None in files.values():
     if download or (self.can_download() and prompt.ask_yes_no('Do you need to download the OS files?', True)):
       files = self.download(files)
     else:
       for key, file in files.iteritems():
        files[key] = self.get_file(key)
   self.do_install(files, sdcard)
Exemple #3
0
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))