def get_device_owner(): """ Get device owner, if any """ con = SnapdConnection('', '/run/snapd.socket') for user in con.get('v2/users').json()['result']: if 'username' not in user: continue username = user['username'] homedir = '/home/' + username if os.path.isdir(homedir): return { 'username': username, 'realname': get_realname(username), 'homedir': homedir, } return None
def __init__(self, opts, block_log_dir): super().__init__(opts) self.block_log_dir = block_log_dir self.cloud_init_ok = None self._state = ApplicationState.STARTING_UP self.state_event = asyncio.Event() self.interactive = None self.confirming_tty = '' self.fatal_error = None self.running_error_commands = False self.echo_syslog_id = 'subiquity_echo.{}'.format(os.getpid()) self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid()) self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid()) self.error_reporter = ErrorReporter( self.context.child("ErrorReporter"), self.opts.dry_run, self.root) self.prober = Prober(opts.machine_config, self.debug_flags) self.kernel_cmdline = shlex.split(opts.kernel_cmdline) if opts.snaps_from_examples: connection = FakeSnapdConnection( os.path.join( os.path.dirname(os.path.dirname( os.path.dirname(__file__))), "examples", "snaps"), self.scale_factor) else: connection = SnapdConnection(self.root, self.snapd_socket_path) self.snapd = AsyncSnapd(connection) self.note_data_for_apport("SnapUpdated", str(self.updated)) self.event_listeners = [] self.autoinstall_config = None self.signal.connect_signals([ ('network-proxy-set', lambda: schedule_task(self._proxy_set())), ('network-change', self._network_change), ])
def __init__(self, opts, block_log_dir): if is_linux_tty(): self.input_filter = KeyCodesFilter() else: self.input_filter = DummyKeycodesFilter() self.help_menu = HelpMenu(self) super().__init__(opts) self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid()) self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid()) self.server_updated = None self.restarting_server = False self.prober = Prober(opts.machine_config, self.debug_flags) journald_listen(self.aio_loop, ["subiquity"], self.subiquity_event, seek=True) self.event_listeners = [] self.install_lock_file = Lockfile(self.state_path("installing")) self.global_overlays = [] self.block_log_dir = block_log_dir self.kernel_cmdline = shlex.split(opts.kernel_cmdline) if opts.snaps_from_examples: connection = FakeSnapdConnection( os.path.join(os.path.dirname(os.path.dirname(__file__)), "examples", "snaps"), self.scale_factor) else: connection = SnapdConnection(self.root, self.snapd_socket_path) self.snapd = AsyncSnapd(connection) self.signal.connect_signals([ ('network-proxy-set', lambda: schedule_task(self._proxy_set())), ('network-change', self._network_change), ]) self.conn = aiohttp.UnixConnector(self.opts.socket) self.client = make_client_for_conn(API, self.conn, self.resp_hook) self.autoinstall_config = {} self.error_reporter = ErrorReporter( self.context.child("ErrorReporter"), self.opts.dry_run, self.root, self.client) self.note_data_for_apport("SnapUpdated", str(self.updated)) self.note_data_for_apport("UsingAnswers", str(bool(self.answers)))
def get_managed(): """ Check if device is managed """ con = SnapdConnection('', '/run/snapd.socket') return con.get('v2/system-info').json()['result']['managed']