def main(args): print 'NOTE: this process requires simultaneous access to' print 'Solo and to the Internet. if you have not yet done so,' print 'run `solo wifi` to connect to Solo and to a local' print 'wifi connection simultaneously.' print '' print 'NOTE: also run `solo install-smart` first.' print '' # prompt for consent print 'WARNING: this can break your Solo and require a factory reset!' print 'your Solo will turn off after and you will need to power cycle it.' y = raw_input('proceed to resize filesystem? [y/N] ') if not (y.lower() == 'y' or y.lower() == 'yes'): sys.exit(1) print '' print 'connecting to solo...' solo = soloutils.connect_solo(await=True) print 'waiting for Internet connectivity...' soloutils.await_net() print '' code = soloutils.command_stream(solo, SCRIPT) print '' dt = datetime.today() + timedelta(minutes=4) print('please wait up to four minutes longer for the resize to complete (at {}).'.format(dt.strftime('%-I:%M'))) print('(you can manually restart solo if it fails to come online again.)') solo.close() sys.exit(code)
def main(args): print 'NOTE: this process requires simultaneous access to' print 'Solo and to the Internet. if you have not yet done so,' print 'run `solo wifi` to connect to Solo and to a local' print 'wifi connection simultaneously.' print '' print 'NOTE: also run `solo install-smart` first.' print '' # prompt for consent print 'WARNING: this can break your Solo and require a factory reset!' print 'your Solo will turn off after and you will need to power cycle it.' y = raw_input('proceed to resize filesystem? [y/N] ') if not (y.lower() == 'y' or y.lower() == 'yes'): sys.exit(1) print '' print 'connecting to solo...' solo = soloutils.connect_solo(await=True) print 'waiting for Internet connectivity...' soloutils.await_net() print '' code = soloutils.command_stream(solo, SCRIPT) print '' dt = datetime.today() + timedelta(minutes=4) print( 'please wait up to four minutes longer for the resize to complete (at {}).' .format(dt.strftime('%-I:%M'))) print('(you can manually restart solo if it fails to come online again.)') solo.close() sys.exit(code)
def list(): errprinter('checking Internet connectivity...') soloutils.await_net() controller = releases([1, 10]) drone = releases([2, 9]) for update in controller: print('controller', update.version) for update in drone: print('drone', update.version) sys.exit(0)
def main(args): print 'NOTE: this process requires simultaneous access to' print 'Solo and to the Internet. if you have not yet done so,' print 'run `solo wifi` to connect to Solo and to a local' print 'wifi connection simultaneously.' print '' print 'connecting to solo...' solo = soloutils.connect_solo(await=True) print 'waiting for Internet connectivity...' soloutils.await_net() print '' code = soloutils.command_stream(solo, SCRIPT) solo.close() sys.exit(code)
def main(args): if args['--list']: list() return if args['pixhawk']: if args['<filename>']: firmware_file = args['<filename>'] flash_px4(firmware_file) return if args['both']: group = 'Solo and the Controller' if args['drone']: group = 'Solo' if args['controller']: group = 'the Controller' version = None if args['<version>']: version = re.sub(r'^v', '', args['<version>']) if not re.match(r'^\d+', version): errprinter('error: verion number specified looks invalid.') sys.exit(1) # Specific exceptions to the update flow. if args['current'] and not args['--clean']: # solo flash XXX current errprinter( 'you are already flashed at your current version. stopping.') sys.exit(0) if args['factory'] and not args['--clean']: # solo flash XXX factory errprinter( 'error: cannot reset to factory firmware without specifying --clean.' ) sys.exit(1) # prompt for consent errprinter('you are about to flash {}.'.format(group)) if args['--clean']: errprinter( 'by specifying --clean, you will REMOVE ALL LOCAL CHANGES to Solo.' ) else: errprinter( 'this PRESERVES ALL LOCAL CHANGES to Solo, but any conflicts') errprinter('with newer updates is not guaranteed to work.') y = raw_input('proceed to perform update? [y/N] ') if not (y.lower() == 'y' or y.lower() == 'yes'): sys.exit(1) # Specific exceptions to the update flow. if args['current'] and args['--clean']: # solo flash XXX current --clean return clean_settings(args) if args['factory'] and args['--clean']: # solo flash XXX factory --clean return factory_reset(args) errprinter('') errprinter('checking Internet connectivity...') soloutils.await_net() if args['drone'] or args['both']: drone_file, drone_md5 = download_firmware('drone', version) if args['controller'] or args['both']: controller_file, controller_md5 = download_firmware( 'controller', version) errprinter('') errprinter('please power on ' + group + ' and connect your computer') errprinter('to Solo\'s wifi network.') errprinter('') if args['drone'] or args['both']: code = flash('drone', drone_file, drone_md5, args) if args['both']: errprinter('') if args['controller'] or args['both']: code = flash('controller', controller_file, controller_md5, args) if code != 0: sys.exit(code) sys.exit(code)
def main(args): if args['--list']: list() return if args['pixhawk']: if args['<filename>']: firmware_file = args['<filename>'] flash_px4(firmware_file) return if args['both']: group = 'Solo and the Controller' if args['drone']: group = 'Solo' if args['controller']: group = 'the Controller' version = None if args['<version>']: version = re.sub(r'^v', '', args['<version>']) if not re.match(r'^\d+', version): errprinter('error: verion number specified looks invalid.') sys.exit(1) # Specific exceptions to the update flow. if args['current'] and not args['--clean']: # solo flash XXX current errprinter('you are already flashed at your current version. stopping.') sys.exit(0) if args['factory'] and not args['--clean']: # solo flash XXX factory errprinter('error: cannot reset to factory firmware without specifying --clean.') sys.exit(1) # prompt for consent errprinter('you are about to flash {}.'.format(group)) if args['--clean']: errprinter('by specifying --clean, you will REMOVE ALL LOCAL CHANGES to Solo.') else: errprinter('this PRESERVES ALL LOCAL CHANGES to Solo, but any conflicts') errprinter('with newer updates is not guaranteed to work.') y = raw_input('proceed to perform update? [y/N] ') if not (y.lower() == 'y' or y.lower() == 'yes'): sys.exit(1) # Specific exceptions to the update flow. if args['current'] and args['--clean']: # solo flash XXX current --clean return clean_settings(args) if args['factory'] and args['--clean']: # solo flash XXX factory --clean return factory_reset(args) errprinter('') errprinter('checking Internet connectivity...') soloutils.await_net() if args['drone'] or args['both']: drone_file, drone_md5 = download_firmware('drone', version) if args['controller'] or args['both']: controller_file, controller_md5 = download_firmware('controller', version) errprinter('') errprinter('please power on ' + group + ' and connect your computer') errprinter('to Solo\'s wifi network.') errprinter('') if args['drone'] or args['both']: code = flash('drone', drone_file, drone_md5, args) if args['both']: errprinter('') if args['controller'] or args['both']: code = flash('controller', controller_file, controller_md5, args) if code != 0: sys.exit(code) sys.exit(code)
def main(args): if args['both']: group = 'Solo and the Controller' if args['solo']: group = 'Solo' if args['controller']: group = 'the Controller' version = None if args['<version>']: version = re.sub(r'^v', '', args['<version>']) if not re.match(r'^\d+', version): errprinter('error: verion number specified looks invalid.') sys.exit(1) if not args['--list']: # prompt for consent errprinter('you are about to update {}.'.format(group)) errprinter( 'this preserves all your local changes to Solo, but compatibility') errprinter('with newer updates is not guaranteed.') y = raw_input('proceed to perform update? [y/N] ') if not (y.lower() == 'y' or y.lower() == 'yes'): sys.exit(1) if not args['latest'] and not version and not args['--list']: errprinter( 'TODO: only solo update to "latest" or "<version>" works yet.') sys.exit(1) if args['both']: errprinter( 'TODO: only "solo" or "controller" update yet works, not "both".') sys.exit(1) errprinter('checking Internet connectivity...') soloutils.await_net() if args['controller']: product = [1, 10] else: product = [2, 9] updates = releases(product) if version: updates = filter( lambda x: version in re.sub('.tar.gz', '', x.url.split('/')[-1]), updates) if len(updates) == 0: errprinter( 'error: no version matching {} were found.'.format(version)) sys.exit(1) if args['--list']: for update in updates: print(update.version) sys.exit(0) # download file file_loc, md5_loc = fetch(updates[-1]) errprinter( 'please power-up the Controller and connect your PC to the Solo wifi network.' ) # Connect to controller... if args['controller']: errprinter('connecting to Controller...') client = soloutils.connect_controller(await=True) else: errprinter('connecting to Solo...') client = soloutils.connect_solo(await=True) # Prepare the update. # older versions don't have sololink_config and ssh returns 127, so do it manually code = soloutils.command_stream( client, 'sololink_config --update-prepare sololink') if code != 0: soloutils.command_stream( client, 'rm -rf /log/updates && mkdir -p /log/updates') # Upload the files. errprinter('uploading updates...') scp = SCPClient(client.get_transport()) scp.put(file_loc, posixpath.join('/log/updates/', posixpath.basename(file_loc))) scp.put(md5_loc, posixpath.join('/log/updates/', posixpath.basename(md5_loc))) scp.close() if args['controller']: errprinter("starting update on the Controller...") else: errprinter("starting update on Solo...") code = soloutils.command_stream(client, 'sololink_config --update-apply sololink') if code != 0: code = soloutils.command_stream( client, 'touch /log/updates/UPDATE && shutdown -r now') if args['controller']: errprinter('the Controller will update once it reboots.') else: errprinter('Solo will update once it reboots.') else: errprinter('update succeeded!') dt = datetime.today() + timedelta(minutes=4) errprinter( 'please wait up to four minutes longer for the installation to complete (at {}).' .format(dt.strftime('%-I:%M'))) # Complete! client.close() sys.exit(code)
elif args['logs']: soloutils.logs.main(args) elif args['install-pip']: soloutils.install_pip.main(args) elif args['install-smart']: soloutils.install_smart.main(args) elif args['install-runit']: soloutils.install_runit.main(args) elif args['resize']: soloutils.resize.main(args) elif args['video']: soloutils.video.main(args) elif args['script']: if sys.argv[2] == 'pack': print 'checking Internet connectivity...' soloutils.await_net() soloutils.pack.main(args) elif sys.argv[2] == 'push': soloutils.script.push_main(args) elif sys.argv[2] == 'run': if len(sys.argv) < 4: print 'Usage: solo script run <file.py>' sys.exit(1) soloutils.script.run_main(args) else: print('Usage: solo script (pack|push|run)') sys.exit(1) else: print 'no argument found.'
def main(args): if args["both"]: group = "Solo and the Controller" if args["solo"]: group = "Solo" if args["controller"]: group = "the Controller" version = None if args["<version>"]: version = re.sub(r"^v", "", args["<version>"]) if not re.match(r"^\d+", version): errprinter("error: verion number specified looks invalid.") sys.exit(1) if not args["--list"]: # prompt for consent errprinter("you are about to update {}.".format(group)) errprinter("this preserves all your local changes to Solo, but compatibility") errprinter("with newer updates is not guaranteed.") y = raw_input("proceed to perform update? [y/N] ") if not (y.lower() == "y" or y.lower() == "yes"): sys.exit(1) if not args["latest"] and not version and not args["--list"]: errprinter('TODO: only solo update to "latest" or "<version>" works yet.') sys.exit(1) if args["both"]: errprinter('TODO: only "solo" or "controller" update yet works, not "both".') sys.exit(1) errprinter("checking Internet connectivity...") soloutils.await_net() if args["controller"]: product = [1, 10] else: product = [2, 9] updates = releases(product) if version: updates = filter(lambda x: version in re.sub(".tar.gz", "", x.url.split("/")[-1]), updates) if len(updates) == 0: errprinter("error: no version matching {} were found.".format(version)) sys.exit(1) if args["--list"]: for update in updates: print(update.version) sys.exit(0) # download file file_loc, md5_loc = fetch(updates[-1]) errprinter("please power-up the Controller and connect your PC to the Solo wifi network.") # Connect to controller... if args["controller"]: errprinter("connecting to Controller...") client = soloutils.connect_controller(await=True) else: errprinter("connecting to Solo...") client = soloutils.connect_solo(await=True) # Prepare the update. # older versions don't have sololink_config and ssh returns 127, so do it manually code = soloutils.command_stream(client, "sololink_config --update-prepare sololink") if code != 0: soloutils.command_stream(client, "rm -rf /log/updates && mkdir -p /log/updates") # Upload the files. errprinter("uploading updates...") scp = SCPClient(client.get_transport()) scp.put(file_loc, posixpath.join("/log/updates/", posixpath.basename(file_loc))) scp.put(md5_loc, posixpath.join("/log/updates/", posixpath.basename(md5_loc))) scp.close() if args["controller"]: errprinter("starting update on the Controller...") else: errprinter("starting update on Solo...") code = soloutils.command_stream(client, "sololink_config --update-apply sololink") if code != 0: code = soloutils.command_stream(client, "touch /log/updates/UPDATE && shutdown -r now") if args["controller"]: errprinter("the Controller will update once it reboots.") else: errprinter("Solo will update once it reboots.") else: errprinter("update succeeded!") dt = datetime.today() + timedelta(minutes=4) errprinter( "please wait up to four minutes longer for the installation to complete (at {}).".format(dt.strftime("%-I:%M")) ) # Complete! client.close() sys.exit(code)