Пример #1
0
def partition_defaultboot(partition):
    try:
        settings_path = partition_mount(
            config.DATA['system']['settings_partition'], 'rw')
        conf_path = os.path.join(settings_path, 'noobs.conf')

        noobs_conf = ConfigParser()
        noobs_conf.read(conf_path)

        section = 'General'

        if not noobs_conf.has_section(section):
            noobs_conf.add_section(section)

        if partition == config.DATA['system']['recovery_partition']:
            noobs_conf.remove_option(section, 'default_partition_to_boot')
            noobs_conf.remove_option(section, 'sticky_boot')
        else:
            noobs_conf.set(section, 'default_partition_to_boot',
                           str(partition_number(partition)))
            noobs_conf.set(section, 'sticky_boot',
                           str(partition_number(partition)))

        output = StringIO()
        noobs_conf.write(output)
        write_file(conf_path, output.getvalue())
    except:
        raise
    finally:
        partition_umount(config.DATA['system']['settings_partition'])
Пример #2
0
Файл: auth.py Проект: zwunix/st2
    def run(self, args, **kwargs):

        if not args.password:
            args.password = getpass.getpass()
        instance = self.resource(ttl=args.ttl) if args.ttl else self.resource()

        cli = BaseCLIApp()

        # Determine path to config file
        try:
            config_file = cli._get_config_file_path(args)
        except ValueError:
            # config file not found in args or in env, defaulting
            config_file = config_parser.ST2_CONFIG_PATH

        # Retrieve token
        manager = self.manager.create(instance,
                                      auth=(args.username, args.password),
                                      **kwargs)
        cli._cache_auth_token(token_obj=manager)

        # Update existing configuration with new credentials
        config = ConfigParser()
        config.read(config_file)

        # Modify config (and optionally populate with password)
        if not config.has_section('credentials'):
            config.add_section('credentials')

        config.set('credentials', 'username', args.username)
        if args.write_password:
            config.set('credentials', 'password', args.password)
        else:
            # Remove any existing password from config
            config.remove_option('credentials', 'password')

        config_existed = os.path.exists(config_file)
        with open(config_file, 'w') as cfg_file_out:
            config.write(cfg_file_out)
        # If we created the config file, correct the permissions
        if not config_existed:
            os.chmod(config_file, 0o660)

        return manager
Пример #3
0
    def run(self, args, **kwargs):

        if not args.password:
            args.password = getpass.getpass()
        instance = self.resource(ttl=args.ttl) if args.ttl else self.resource()

        cli = BaseCLIApp()

        # Determine path to config file
        try:
            config_file = cli._get_config_file_path(args)
        except ValueError:
            # config file not found in args or in env, defaulting
            config_file = config_parser.ST2_CONFIG_PATH

        # Retrieve token
        manager = self.manager.create(instance, auth=(args.username, args.password), **kwargs)
        cli._cache_auth_token(token_obj=manager)

        # Update existing configuration with new credentials
        config = ConfigParser()
        config.read(config_file)

        # Modify config (and optionally populate with password)
        if not config.has_section('credentials'):
            config.add_section('credentials')

        config.set('credentials', 'username', args.username)
        if args.write_password:
            config.set('credentials', 'password', args.password)
        else:
            # Remove any existing password from config
            config.remove_option('credentials', 'password')

        with open(config_file, 'w') as cfg_file_out:
            config.write(cfg_file_out)

        return manager
Пример #4
0
inifile=args[0]

# Set up the configuration for the sub-dags

prior_cp=ConfigParser()
prior_cp.optionxform = str
prior_cp.readfp(open(inifile))

main_cp=ConfigParser()
main_cp.optionxform = str
main_cp.readfp(open(inifile))

# Remove gps start and end time options
for option in ['gps-start-time','gps-end-time']:
  if main_cp.has_option('input',option):
    main_cp.remove_option('input',option)

rundir=os.path.abspath(opts.run_path)

if opts.daglog_path is not None:
  prior_cp.set('paths','daglogdir',os.path.join(os.path.abspath(opts.daglog_path),'prior'))
  main_cp.set('paths','daglogdir',os.path.join(os.path.abspath(opts.daglog_path),'main'))
  daglogdir=os.path.abspath(opts.daglog_path)
else:
  prior_cp.set('paths','daglogdir',os.path.join(os.path.abspath(opts.run_path),'prior'))
  main_cp.set('paths','daglogdir',os.path.join(os.path.abspath(opts.run_path),'main'))
  daglogdir=os.path.abspath(opts.run_path)

webdir=main_cp.get('ppanalysis','webdir')
priordir=os.path.join(rundir,'prior')
maindir=os.path.join(rundir,'main')