def __init__(self, opts): self._exc = None self.debug_flags = () if opts.dry_run: # Recognized flags are: # - install-fail: makes curtin install fail by replaying curtin # events from a failed installation, see # subiquity/controllers/installprogress.py # - bpfail-full, bpfail-restricted: makes block probing fail, see # subiquitycore/prober.py # - copy-logs-fail: makes post-install copying of logs fail, see # subiquity/controllers/installprogress.py self.debug_flags = os.environ.get('SUBIQUITY_DEBUG', '').split(',') self.opts = opts opts.project = self.project self.root = '/' if opts.dry_run: self.root = '.subiquity' self.state_dir = os.path.join(self.root, 'run', self.project) os.makedirs(self.state_path('states'), exist_ok=True) self.scale_factor = float( os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "1")) self.updated = os.path.exists(self.state_path('updating')) self.hub = MessageHub() self.aio_loop = asyncio.get_event_loop() self.aio_loop.set_exception_handler(self._exception_handler) self.controllers = ControllerSet(self.controllers_mod, self.controllers, init_args=(self, )) self.context = Context.new(self)
def make_controller(bootloader=None): app = MiniApplication() app.base_model = bm = Thing() app.context = Context.new(app) bm.filesystem = make_model(bootloader) controller = FilesystemController(app) return controller
def __init__(self, opts): self.debug_flags = () if opts.dry_run: # Recognized flags are: # - install-fail: makes curtin install fail by replaying curtin # events from a failed installation, see # subiquity/controllers/installprogress.py # - bpfail-full, bpfail-restricted: makes block probing fail, see # subiquitycore/prober.py # - copy-logs-fail: makes post-install copying of logs fail, see # subiquity/controllers/installprogress.py self.debug_flags = os.environ.get('SUBIQUITY_DEBUG', '').split(',') prober = Prober(opts.machine_config, self.debug_flags) self.ui = self.make_ui() self.opts = opts opts.project = self.project self.root = '/' if opts.dry_run: self.root = '.subiquity' self.state_dir = os.path.join(self.root, 'run', self.project) os.makedirs(self.state_path('states'), exist_ok=True) self.answers = {} if opts.answers is not None: self.answers = yaml.safe_load(opts.answers.read()) log.debug("Loaded answers %s", self.answers) if not opts.dry_run: open('/run/casper-no-prompt', 'w').close() # Set rich_mode to the opposite of what we want, so we can # call toggle_rich to get the right things set up. self.rich_mode = opts.run_on_serial self.color_palette = make_palette(self.COLORS, self.STYLES) self.is_linux_tty = is_linux_tty() if self.is_linux_tty: self.input_filter = KeyCodesFilter() else: self.input_filter = DummyKeycodesFilter() self.scale_factor = float( os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "1")) self.updated = os.path.exists(self.state_path('updating')) self.signal = Signal() self.prober = prober self.new_event_loop() self.urwid_loop = None self.controllers = ControllerSet(self, self.controllers) self.context = Context.new(self)
def make_app(model=None): app = MockedApplication() app.ui = mock.Mock() if model is not None: app.base_model = model else: app.base_model = mock.Mock() app.context = Context.new(app) app.exit = mock.Mock() app.respond = mock.Mock() app.next_screen = mock.Mock() app.prev_screen = mock.Mock() return app
def __init__(self): self.context = Context.new(TestApp())