Unbreak snap screen, and simplify it

This commit is contained in:
Dimitri John Ledkov 2019-05-14 16:03:55 +02:00
parent 25071d9cf0
commit 96be2a8f5d
1 changed files with 7 additions and 16 deletions

View File

@ -413,13 +413,6 @@ class SnapListView(BaseView):
self._w = screen
def get_seed_yaml(self):
log.debug("%r", self.controller.base_model.installpath.sources)
sources = list(self.controller.base_model.installpath.sources.values())
if len(sources) != 1 or not sources[0].startswith('cp://'):
log.warning("cannot parse install sources %r", sources)
else:
source = sources[0][5:]
log.debug("install source %r", source)
if self.controller.opts.dry_run:
return '''snaps:
-
@ -431,16 +424,14 @@ class SnapListView(BaseView):
channel: stable/ubuntu-18.04
file: lxd_59.snap
'''
else:
seed_location = os.path.join(
source, 'var/lib/snapd/seed/seed.yaml')
try:
fp = open(seed_location, encoding='utf-8', errors='replace')
except FileNotFoundError:
log.exception("could not find source at %r", seed_location)
with fp:
seed_location = '/media/filesystem/var/lib/snapd/seed/seed.yaml'
content = ""
try:
with open(seed_location, encoding='utf-8', errors='replace') as fp:
content = fp.read()
return content
except FileNotFoundError:
log.exception("could not find source at %r", seed_location)
return content
def get_preinstalled_snaps(self):
try: