def beta_134_to_beta_200(self): if not is_installed('kano-character-cli'): logger.info("kano-character-cli not installed," " attempt to install kano-profile") install('kano-profile') run_cmd_log( 'kano-character-cli -c "judoka" "Hair_Black" "Skin_Orange" -s')
def beta_110_to_beta_111(self): install('kano-sound-files kano-init-flow') # Create first boot file so we don't annoy existent users username = get_user_unsudoed() first_boot = '/home/%s/.kano-settings/first_boot' % username try: open(first_boot, 'w').close() except: pass
def beta_110_to_beta_111(self, dummy_progress): install('kano-sound-files kano-init-flow') # Create first boot file so we don't annoy existent users username = get_user_unsudoed() first_boot = '/home/%s/.kano-settings/first_boot' % username try: open(first_boot, 'w').close() except: pass
def beta_134_to_beta_200(self, dummy_progress): if not is_installed('kano-character-cli'): logger.info( "kano-character-cli not installed," " attempt to install kano-profile" ) install('kano-profile') run_cmd_log( 'kano-character-cli -c "judoka" "Hair_Black" "Skin_Orange" -s' )
def beta_210_to_beta_220(self): install('telnet python-serial') try: from kano_profile.apps import save_app_state_variable_all_users save_app_state_variable_all_users("init-flow-completed", "level", 1) except ImportError: logger.error( "Could not award Computer Commander badge, import error")
def beta_210_to_beta_220(self, dummy_progress): install('telnet python-serial') try: from kano_profile.apps import save_app_state_variable_all_users save_app_state_variable_all_users("init-flow-completed", "level", 1) except ImportError: logger.error( "Could not award Computer Commander badge, import error" )
def beta_3_13_0_to_beta_3_14_0(self, dummy_progress): try: import apt.cache c = apt.cache.Cache() if c['rpi-chromium-mods-kano'].installed >= '20170809': install('scratch2') else: logger.error( "beta_3_13_0_to_beta_3_14_0: " "wrong version of rpi-chromium-mods-kano installed: {}" .format(c['rpi-chromium-mods-kano'].installed.version) ) except Exception as e: logger.error("beta_3_13_0_to_beta_3_14_0: Failed to install scratch2", exception=e)
def beta_3_13_0_to_beta_3_14_0(self): try: import apt.cache c = apt.cache.Cache() if c['rpi-chromium-mods-kano'].installed >= '20170809': install('scratch2') else: logger.error( "beta_3_13_0_to_beta_3_14_0: wrong version of rpi-chromium-mods-kano installed: {}" .format(c['rpi-chromium-mods-kano'].installed.version)) except Exception as e: logger.error( "beta_3_13_0_to_beta_3_14_0: Failed to install scratch2", exception=e)
def beta_120_to_beta_121(self, dummy_progress): install('espeak')
def beta_220_to_beta_230(self): # A few helper fns to keep the scenario tidy def ensure_system_group_exists(group): if (os.system('getent group {}'.format(group)) != 0): rc = os.system('groupadd -f -r {}'.format(group)) if rc != 0: logger.error("could not create group") def add_users_to_group(group): try: linux_users = get_users() if not linux_users: logger.error('beta_220_to_beta_230: linux_users is empty!') for user in linux_users: os.system('sudo usermod -a -G {} {}'.format(group, user)) except Exception as e: logger.error("Couldn't add users to {} group - [{}]".format( group, e)) def add_i2c_module_to_auto_loaded(): try: found_i2c_dev = False with open('/etc/modules', 'r') as f: for line in f: if line.strip() == 'i2c_dev': found_i2c_dev = True if not found_i2c_dev: with open('/etc/modules', 'a') as f: f.write('\ni2c_dev\n') except Exception as e: logger.error( "Couldn't add i2c_dev to /etc/modules - [{}]".format(e)) def remove_powerup_lnk_file(): try: linux_users = get_users() if not linux_users: logger.error('beta_220_to_beta_230: linux_users is empty!') lnk_dir_template = os.path.join(os.sep, 'home', '{user}', '.kdesktop', 'Powerup.lnk') for user in linux_users: lnk_dir = lnk_dir_template.format(user=user) if os.path.exists(lnk_dir): os.remove(lnk_dir) except Exception as e: logger.error("Couldn't remove Powerup.lnk - [{}]".format(e)) def enable_spi_device(): from kano_settings.boot_config import set_config_value set_config_value("dtparam=spi", "on") try: from kano_settings.boot_config import end_config_transaction end_config_transaction() except ImportError: logger.error( "end_config_transaciton not present - update to kano-settings failed?" ) # Scenario work starts here install('rsync') run_cmd_log('kano-apps install --no-gui powerup') remove_powerup_lnk_file() ensure_system_group_exists('gpio') ensure_system_group_exists('spi') add_users_to_group('i2c') add_users_to_group('gpio') add_users_to_group('spi') add_i2c_module_to_auto_loaded() # enable spi device enable_spi_device()
def beta_3_9_2_to_beta_3_10_0(self): # The new Overture onboarding needs to be enabled - disabling old tty-based kano-init run_cmd_log('kano-init finalise --force') # Install the kano-os metapackage for top level OS packages. install('kano-os')
def beta_125_to_beta_131(self): install('kano-draw')
def beta_120_to_beta_121(self): install('espeak')
def beta_103_to_beta_110(self): rclocal_executable() remove_user_files(['.kdeskrc']) install('kano-widgets')
def beta_3_9_2_to_beta_3_10_0(self, dummy_progress): # The new Overture onboarding needs to be enabled - disabling old tty-based kano-init run_cmd_log('kano-init finalise --force') # Install the kano-os metapackage for top level OS packages. install('kano-os')
def beta_220_to_beta_230(self, dummy_progress): # A few helper fns to keep the scenario tidy def ensure_system_group_exists(group): if(os.system('getent group {}'.format(group)) != 0): rc = os.system('groupadd -f -r {}'.format(group)) if rc != 0: logger.error("could not create group") def add_users_to_group(group): try: linux_users = get_users() if not linux_users: logger.error('beta_220_to_beta_230: linux_users is empty!') for user in linux_users: os.system('sudo usermod -a -G {} {}'.format(group, user)) except Exception as e: logger.error( "Couldn't add users to {} group - [{}]".format(group, e) ) def add_i2c_module_to_auto_loaded(): try: found_i2c_dev = False with open('/etc/modules', 'r') as f: for line in f: if line.strip() == 'i2c_dev': found_i2c_dev = True if not found_i2c_dev: with open('/etc/modules', 'a') as f: f.write('\ni2c_dev\n') except Exception as e: logger.error( "Couldn't add i2c_dev to /etc/modules - [{}]".format(e) ) def remove_powerup_lnk_file(): try: linux_users = get_users() if not linux_users: logger.error('beta_220_to_beta_230: linux_users is empty!') lnk_dir_template = os.path.join( os.sep, 'home', '{user}', '.kdesktop', 'Powerup.lnk' ) for user in linux_users: lnk_dir = lnk_dir_template.format(user=user) if os.path.exists(lnk_dir): os.remove(lnk_dir) except Exception as e: logger.error("Couldn't remove Powerup.lnk - [{}]".format(e)) def enable_spi_device(): from kano_settings.boot_config import set_config_value set_config_value("dtparam=spi", "on") try: from kano_settings.boot_config import end_config_transaction end_config_transaction() except ImportError: logger.error("end_config_transaciton not present - update to kano-settings failed?") # Scenario work starts here install('rsync') run_cmd_log('kano-apps install --no-gui powerup') remove_powerup_lnk_file() ensure_system_group_exists('gpio') ensure_system_group_exists('spi') add_users_to_group('i2c') add_users_to_group('gpio') add_users_to_group('spi') add_i2c_module_to_auto_loaded() # enable spi device enable_spi_device()
def beta_125_to_beta_131(self, dummy_progress): install('kano-draw')
def beta_103_to_beta_110(self, dummy_progress): rclocal_executable() remove_user_files(['.kdeskrc']) install('kano-widgets')