{"action":"created","comment":{"url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/comments/190099304","pull_request_review_id":122405929,"id":190099304,"diff_hunk":"@@ -40,10 +49,109 @@ class InstallState:\n     ERROR = -1\n \n \n+class WaitForCurtinEventsTask(BackgroundTask):\n+\n+    def __init__(self, controller):\n+        self.controller = controller\n+        self.waited = 0.0\n+\n+    def start(self):\n+        pass\n+\n+    def _bg_run(self):\n+        while self.controller._event_indent and self.waited < 5.0:\n+            time.sleep(0.1)\n+            self.waited += 0.1\n+        log.debug(\"waited %s seconds for events to drain\", self.waited)\n+\n+    def end(self, observer, fut):\n+        # Will raise if command failed:\n+        fut.result()\n+        self.controller._install_event_start(\"installing snaps\")\n+        observer.task_succeeded()\n+\n+\n+class DownloadSnapTask(BackgroundTask):\n+\n+    def __init__(self, controller, download_dir, snap_name, channel):\n+        self.controller = controller\n+        self.download_dir = os.path.join(download_dir, snap_name)\n+        self.snap_name = snap_name\n+        self.channel = channel\n+\n+    def start(self):\n+        self.controller._install_event_start(_(\"downloading {}\").format(self.snap_name))\n+        os.mkdir(self.download_dir)\n+        self.proc = utils.start_command(\n+            ['snap', 'download', '--channel='+self.channel, self.snap_name],\n+            cwd=self.download_dir)\n+\n+    def _bg_run(self):\n+        self.proc.communicate()\n+        if self.proc.returncode != 0:\n+            raise subprocess.CalledProcessError(\n+                cp.returncode, cp.args, output=cp.stdout, stderr=cp.stderr)\n+\n+    def end(self, observer, fut):\n+        self.controller._install_event_finish()\n+        fut.result()\n+        observer.task_succeeded()\n+\n+\n+class UpdateSnapSeed(BackgroundTask):\n+\n+    def __init__(self, controller, root):\n+        self.controller = controller\n+        self._seed_yaml = os.path.join(root, \"var/lib/snapd/seed/seed.yaml\")\n+        self._tmp_dir = os.path.join(root, \"var/lib/snapd/seed/tmp\")\n+        self._snap_dir = os.path.join(root, \"var/lib/snapd/seed/snaps\")\n+        self._assertions_dir = os.path.join(root, \"var/lib/snapd/seed/assertions\")\n+\n+    def start(self):\n+        self.controller._install_event_start(_(\"updating snap seed\"))\n+\n+    def _bg_run(self):\n+        # This doesn't really need to be in the background, but as we\n+        # have the infrastructure already in place, we may as well.\n+        with open(self._seed_yaml) as fp:\n+            seed = yaml.safe_load(fp)\n+\n+        for snap_name in os.listdir(self._tmp_dir):\n+            [snap_path] = glob.glob(os.path.join(self._tmp_dir, snap_name, \"*.snap\"))\n+            [assertion_path] = glob.glob(os.path.join(self._tmp_dir, snap_name, \"*.assert\"))\n+\n+            snap_file = os.path.basename(snap_path)\n+            assertion_file = os.path.basename(assertion_path)\n+            os.rename(snap_path, os.path.join(self._snap_dir, snap_file))\n+            os.rename(assertion_path, os.path.join(self._assertions_dir, assertion_file))\n+\n+            os.rmdir(os.path.join(self._tmp_dir, snap_name))\n+            selection = self.controller.base_model.snaplist.to_install[snap_name]\n+            seedinfo = {\n+                'name': snap_name,\n+                'file': snap_file,\n+                'channel': selection.channel,\n+                }\n+            if selection.is_classic:\n+                seedinfo['classic'] = True\n+            seed['snaps'].append(seedinfo)\n+\n+        os.rmdir(self._tmp_dir)","path":"subiquity/controllers/installprogress.py","position":117,"original_position":117,"commit_id":"f3b9ec87d935da4c1e954a149a69843b3e08bda3","original_commit_id":"f3b9ec87d935da4c1e954a149a69843b3e08bda3","user":{"login":"mwhudson","id":672022,"avatar_url":"https://avatars3.githubusercontent.com/u/672022?v=4","gravatar_id":"","url":"https://api.github.com/users/mwhudson","html_url":"https://github.com/mwhudson","followers_url":"https://api.github.com/users/mwhudson/followers","following_url":"https://api.github.com/users/mwhudson/following{/other_user}","gists_url":"https://api.github.com/users/mwhudson/gists{/gist_id}","starred_url":"https://api.github.com/users/mwhudson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwhudson/subscriptions","organizations_url":"https://api.github.com/users/mwhudson/orgs","repos_url":"https://api.github.com/users/mwhudson/repos","events_url":"https://api.github.com/users/mwhudson/events{/privacy}","received_events_url":"https://api.github.com/users/mwhudson/received_events","type":"User","site_admin":false},"body":"Yes but see above about code making assumptions. I've added a comment.","created_at":"2018-05-23T01:18:53Z","updated_at":"2018-05-23T01:18:53Z","html_url":"https://github.com/CanonicalLtd/subiquity/pull/339#discussion_r190099304","pull_request_url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/comments/190099304"},"html":{"href":"https://github.com/CanonicalLtd/subiquity/pull/339#discussion_r190099304"},"pull_request":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339"}},"in_reply_to_id":189920743},"pull_request":{"url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339","id":189634383,"html_url":"https://github.com/CanonicalLtd/subiquity/pull/339","diff_url":"https://github.com/CanonicalLtd/subiquity/pull/339.diff","patch_url":"https://github.com/CanonicalLtd/subiquity/pull/339.patch","issue_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/339","number":339,"state":"open","locked":false,"title":"offer featured snaps for installation ","user":{"login":"mwhudson","id":672022,"avatar_url":"https://avatars3.githubusercontent.com/u/672022?v=4","gravatar_id":"","url":"https://api.github.com/users/mwhudson","html_url":"https://github.com/mwhudson","followers_url":"https://api.github.com/users/mwhudson/followers","following_url":"https://api.github.com/users/mwhudson/following{/other_user}","gists_url":"https://api.github.com/users/mwhudson/gists{/gist_id}","starred_url":"https://api.github.com/users/mwhudson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwhudson/subscriptions","organizations_url":"https://api.github.com/users/mwhudson/orgs","repos_url":"https://api.github.com/users/mwhudson/repos","events_url":"https://api.github.com/users/mwhudson/events{/privacy}","received_events_url":"https://api.github.com/users/mwhudson/received_events","type":"User","site_admin":false},"body":"https://asciinema.org/a/R5FujJOA0p07RJOkawGRAQzA7","created_at":"2018-05-22T11:43:43Z","updated_at":"2018-05-23T01:18:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06c2717005be231bd41d7b3e0feaa91c63677473","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339/commits","review_comments_url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339/comments","review_comment_url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/339/comments","statuses_url":"https://api.github.com/repos/CanonicalLtd/subiquity/statuses/f3b9ec87d935da4c1e954a149a69843b3e08bda3","head":{"label":"CanonicalLtd:mwhudson/snap-screen","ref":"mwhudson/snap-screen","sha":"f3b9ec87d935da4c1e954a149a69843b3e08bda3","user":{"login":"CanonicalLtd","id":7490288,"avatar_url":"https://avatars0.githubusercontent.com/u/7490288?v=4","gravatar_id":"","url":"https://api.github.com/users/CanonicalLtd","html_url":"https://github.com/CanonicalLtd","followers_url":"https://api.github.com/users/CanonicalLtd/followers","following_url":"https://api.github.com/users/CanonicalLtd/following{/other_user}","gists_url":"https://api.github.com/users/CanonicalLtd/gists{/gist_id}","starred_url":"https://api.github.com/users/CanonicalLtd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanonicalLtd/subscriptions","organizations_url":"https://api.github.com/users/CanonicalLtd/orgs","repos_url":"https://api.github.com/users/CanonicalLtd/repos","events_url":"https://api.github.com/users/CanonicalLtd/events{/privacy}","received_events_url":"https://api.github.com/users/CanonicalLtd/received_events","type":"Organization","site_admin":false},"repo":{"id":37095216,"name":"subiquity","full_name":"CanonicalLtd/subiquity","owner":{"login":"CanonicalLtd","id":7490288,"avatar_url":"https://avatars0.githubusercontent.com/u/7490288?v=4","gravatar_id":"","url":"https://api.github.com/users/CanonicalLtd","html_url":"https://github.com/CanonicalLtd","followers_url":"https://api.github.com/users/CanonicalLtd/followers","following_url":"https://api.github.com/users/CanonicalLtd/following{/other_user}","gists_url":"https://api.github.com/users/CanonicalLtd/gists{/gist_id}","starred_url":"https://api.github.com/users/CanonicalLtd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanonicalLtd/subscriptions","organizations_url":"https://api.github.com/users/CanonicalLtd/orgs","repos_url":"https://api.github.com/users/CanonicalLtd/repos","events_url":"https://api.github.com/users/CanonicalLtd/events{/privacy}","received_events_url":"https://api.github.com/users/CanonicalLtd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CanonicalLtd/subiquity","description":"Ubuntu Server Installer","fork":false,"url":"https://api.github.com/repos/CanonicalLtd/subiquity","forks_url":"https://api.github.com/repos/CanonicalLtd/subiquity/forks","keys_url":"https://api.github.com/repos/CanonicalLtd/subiquity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanonicalLtd/subiquity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanonicalLtd/subiquity/teams","hooks_url":"https://api.github.com/repos/CanonicalLtd/subiquity/hooks","issue_events_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/events{/number}","events_url":"https://api.github.com/repos/CanonicalLtd/subiquity/events","assignees_url":"https://api.github.com/repos/CanonicalLtd/subiquity/assignees{/user}","branches_url":"https://api.github.com/repos/CanonicalLtd/subiquity/branches{/branch}","tags_url":"https://api.github.com/repos/CanonicalLtd/subiquity/tags","blobs_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanonicalLtd/subiquity/statuses/{sha}","languages_url":"https://api.github.com/repos/CanonicalLtd/subiquity/languages","stargazers_url":"https://api.github.com/repos/CanonicalLtd/subiquity/stargazers","contributors_url":"https://api.github.com/repos/CanonicalLtd/subiquity/contributors","subscribers_url":"https://api.github.com/repos/CanonicalLtd/subiquity/subscribers","subscription_url":"https://api.github.com/repos/CanonicalLtd/subiquity/subscription","commits_url":"https://api.github.com/repos/CanonicalLtd/subiquity/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanonicalLtd/subiquity/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/comments{/number}","contents_url":"https://api.github.com/repos/CanonicalLtd/subiquity/contents/{+path}","compare_url":"https://api.github.com/repos/CanonicalLtd/subiquity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanonicalLtd/subiquity/merges","archive_url":"https://api.github.com/repos/CanonicalLtd/subiquity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanonicalLtd/subiquity/downloads","issues_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues{/number}","pulls_url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls{/number}","milestones_url":"https://api.github.com/repos/CanonicalLtd/subiquity/milestones{/number}","notifications_url":"https://api.github.com/repos/CanonicalLtd/subiquity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanonicalLtd/subiquity/labels{/name}","releases_url":"https://api.github.com/repos/CanonicalLtd/subiquity/releases{/id}","deployments_url":"https://api.github.com/repos/CanonicalLtd/subiquity/deployments","created_at":"2015-06-08T21:57:45Z","updated_at":"2018-05-22T11:09:05Z","pushed_at":"2018-05-23T01:16:43Z","git_url":"git://github.com/CanonicalLtd/subiquity.git","ssh_url":"git@github.com:CanonicalLtd/subiquity.git","clone_url":"https://github.com/CanonicalLtd/subiquity.git","svn_url":"https://github.com/CanonicalLtd/subiquity","homepage":null,"size":3778,"stargazers_count":71,"watchers_count":71,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":14,"open_issues":11,"watchers":71,"default_branch":"master"}},"base":{"label":"CanonicalLtd:master","ref":"master","sha":"626488e988d46043ec67d20f862b9ac207adfba3","user":{"login":"CanonicalLtd","id":7490288,"avatar_url":"https://avatars0.githubusercontent.com/u/7490288?v=4","gravatar_id":"","url":"https://api.github.com/users/CanonicalLtd","html_url":"https://github.com/CanonicalLtd","followers_url":"https://api.github.com/users/CanonicalLtd/followers","following_url":"https://api.github.com/users/CanonicalLtd/following{/other_user}","gists_url":"https://api.github.com/users/CanonicalLtd/gists{/gist_id}","starred_url":"https://api.github.com/users/CanonicalLtd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanonicalLtd/subscriptions","organizations_url":"https://api.github.com/users/CanonicalLtd/orgs","repos_url":"https://api.github.com/users/CanonicalLtd/repos","events_url":"https://api.github.com/users/CanonicalLtd/events{/privacy}","received_events_url":"https://api.github.com/users/CanonicalLtd/received_events","type":"Organization","site_admin":false},"repo":{"id":37095216,"name":"subiquity","full_name":"CanonicalLtd/subiquity","owner":{"login":"CanonicalLtd","id":7490288,"avatar_url":"https://avatars0.githubusercontent.com/u/7490288?v=4","gravatar_id":"","url":"https://api.github.com/users/CanonicalLtd","html_url":"https://github.com/CanonicalLtd","followers_url":"https://api.github.com/users/CanonicalLtd/followers","following_url":"https://api.github.com/users/CanonicalLtd/following{/other_user}","gists_url":"https://api.github.com/users/CanonicalLtd/gists{/gist_id}","starred_url":"https://api.github.com/users/CanonicalLtd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanonicalLtd/subscriptions","organizations_url":"https://api.github.com/users/CanonicalLtd/orgs","repos_url":"https://api.github.com/users/CanonicalLtd/repos","events_url":"https://api.github.com/users/CanonicalLtd/events{/privacy}","received_events_url":"https://api.github.com/users/CanonicalLtd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CanonicalLtd/subiquity","description":"Ubuntu Server Installer","fork":false,"url":"https://api.github.com/repos/CanonicalLtd/subiquity","forks_url":"https://api.github.com/repos/CanonicalLtd/subiquity/forks","keys_url":"https://api.github.com/repos/CanonicalLtd/subiquity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanonicalLtd/subiquity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanonicalLtd/subiquity/teams","hooks_url":"https://api.github.com/repos/CanonicalLtd/subiquity/hooks","issue_events_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/events{/number}","events_url":"https://api.github.com/repos/CanonicalLtd/subiquity/events","assignees_url":"https://api.github.com/repos/CanonicalLtd/subiquity/assignees{/user}","branches_url":"https://api.github.com/repos/CanonicalLtd/subiquity/branches{/branch}","tags_url":"https://api.github.com/repos/CanonicalLtd/subiquity/tags","blobs_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanonicalLtd/subiquity/statuses/{sha}","languages_url":"https://api.github.com/repos/CanonicalLtd/subiquity/languages","stargazers_url":"https://api.github.com/repos/CanonicalLtd/subiquity/stargazers","contributors_url":"https://api.github.com/repos/CanonicalLtd/subiquity/contributors","subscribers_url":"https://api.github.com/repos/CanonicalLtd/subiquity/subscribers","subscription_url":"https://api.github.com/repos/CanonicalLtd/subiquity/subscription","commits_url":"https://api.github.com/repos/CanonicalLtd/subiquity/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanonicalLtd/subiquity/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanonicalLtd/subiquity/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/comments{/number}","contents_url":"https://api.github.com/repos/CanonicalLtd/subiquity/contents/{+path}","compare_url":"https://api.github.com/repos/CanonicalLtd/subiquity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanonicalLtd/subiquity/merges","archive_url":"https://api.github.com/repos/CanonicalLtd/subiquity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanonicalLtd/subiquity/downloads","issues_url":"https://api.github.com/repos/CanonicalLtd/subiquity/issues{/number}","pulls_url":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls{/number}","milestones_url":"https://api.github.com/repos/CanonicalLtd/subiquity/milestones{/number}","notifications_url":"https://api.github.com/repos/CanonicalLtd/subiquity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanonicalLtd/subiquity/labels{/name}","releases_url":"https://api.github.com/repos/CanonicalLtd/subiquity/releases{/id}","deployments_url":"https://api.github.com/repos/CanonicalLtd/subiquity/deployments","created_at":"2015-06-08T21:57:45Z","updated_at":"2018-05-22T11:09:05Z","pushed_at":"2018-05-23T01:16:43Z","git_url":"git://github.com/CanonicalLtd/subiquity.git","ssh_url":"git@github.com:CanonicalLtd/subiquity.git","clone_url":"https://github.com/CanonicalLtd/subiquity.git","svn_url":"https://github.com/CanonicalLtd/subiquity","homepage":null,"size":3778,"stargazers_count":71,"watchers_count":71,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":14,"open_issues":11,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339"},"html":{"href":"https://github.com/CanonicalLtd/subiquity/pull/339"},"issue":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/339"},"comments":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/issues/339/comments"},"review_comments":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339/comments"},"review_comment":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/pulls/339/commits"},"statuses":{"href":"https://api.github.com/repos/CanonicalLtd/subiquity/statuses/f3b9ec87d935da4c1e954a149a69843b3e08bda3"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"mwhudson"}}