{"action":"created","comment":{"url":"https://api.github.com/repos/cockpit-project/hubbot/pulls/comments/32928699","id":32928699,"diff_hunk":"@@ -349,20 +361,42 @@ def expire_work_dirs(github_visible_commits):\n     # make sure we don't look at too many commits\n     github_visible_commits = list(set(github_visible_commits))\n     def is_redundant_directory(dirname):\n-        if dirname in [\"data\", \"status-images\"] or not os.path.isdir(os.path.join(work,dirname)):\n-            return False\n         for c in github_visible_commits:\n             if c in dirname:\n                 return False\n         return True\n-    dirs = sorted (map (lambda e: (os.stat(e).st_mtime,e),\n-                        map (lambda e: os.path.join(work,e),\n-                             filter (is_redundant_directory, os.listdir(work)))),\n-                   lambda x,y: cmp(x[0],y[0]))\n+    dirs = filter (is_redundant_directory, list_work_dirs())\n     if len(dirs) > keep_work_dirs:\n         for d in dirs[0:len(dirs)-keep_work_dirs]:\n-            trace(\"Expiring %s\" % d[1])\n-            shutil.rmtree(d[1])\n+            trace(\"Expiring %s\" % d)\n+            shutil.rmtree(d)\n+\n+def expire_images():\n+    keep = { }\n+\n+    def keep_image(flavor, os_, tag):\n+        keep[\"%s-%s-*-%s-checksum\" % (flavor, os_, tag)] = True\n+        keep[\"%s-%s-*-%s.*\" % (flavor, os_, tag)] = True\n+\n+    for d in list_work_dirs():\n+        t = os.path.join(d, \"test\")\n+        if os.path.exists(t):\n+            for c in filter(lambda e: e.endswith(\".conf\"), os.listdir(t)):\n+                flavor = c[:-5]\n+                conf = ast.literal_eval(open(os.path.join(t, c)).read())\n+                if 'tags' in conf:\n+                    tags = conf['tags']\n+                    for os_ in tags:\n+                        keep_image (flavor, os_, tags[os_])\n+\n+    images_dir = \"%s/cockpit-data/images\" % os.environ['HOME']\n+    expired_dir = \"%s/cockpit-data/images.expired\" % os.environ['HOME']","path":"hubbot","position":67,"original_position":67,"commit_id":"d943518b060e0479aa2e90ec0ccf9703f45003f1","original_commit_id":"d943518b060e0479aa2e90ec0ccf9703f45003f1","user":{"login":"dperpeet","id":8711649,"avatar_url":"https://avatars.githubusercontent.com/u/8711649?v=3","gravatar_id":"","url":"https://api.github.com/users/dperpeet","html_url":"https://github.com/dperpeet","followers_url":"https://api.github.com/users/dperpeet/followers","following_url":"https://api.github.com/users/dperpeet/following{/other_user}","gists_url":"https://api.github.com/users/dperpeet/gists{/gist_id}","starred_url":"https://api.github.com/users/dperpeet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dperpeet/subscriptions","organizations_url":"https://api.github.com/users/dperpeet/orgs","repos_url":"https://api.github.com/users/dperpeet/repos","events_url":"https://api.github.com/users/dperpeet/events{/privacy}","received_events_url":"https://api.github.com/users/dperpeet/received_events","type":"User","site_admin":false},"body":"I think it would be nice to have these in the config, with defaults at the top of the file","created_at":"2015-06-22T12:30:54Z","updated_at":"2015-06-22T12:30:54Z","html_url":"https://github.com/cockpit-project/hubbot/pull/9#discussion_r32928699","pull_request_url":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/cockpit-project/hubbot/pulls/comments/32928699"},"html":{"href":"https://github.com/cockpit-project/hubbot/pull/9#discussion_r32928699"},"pull_request":{"href":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9","id":38224788,"html_url":"https://github.com/cockpit-project/hubbot/pull/9","diff_url":"https://github.com/cockpit-project/hubbot/pull/9.diff","patch_url":"https://github.com/cockpit-project/hubbot/pull/9.patch","issue_url":"https://api.github.com/repos/cockpit-project/hubbot/issues/9","number":9,"state":"open","locked":false,"title":"Expire images","user":{"login":"mvollmer","id":3228183,"avatar_url":"https://avatars.githubusercontent.com/u/3228183?v=3","gravatar_id":"","url":"https://api.github.com/users/mvollmer","html_url":"https://github.com/mvollmer","followers_url":"https://api.github.com/users/mvollmer/followers","following_url":"https://api.github.com/users/mvollmer/following{/other_user}","gists_url":"https://api.github.com/users/mvollmer/gists{/gist_id}","starred_url":"https://api.github.com/users/mvollmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvollmer/subscriptions","organizations_url":"https://api.github.com/users/mvollmer/orgs","repos_url":"https://api.github.com/users/mvollmer/repos","events_url":"https://api.github.com/users/mvollmer/events{/privacy}","received_events_url":"https://api.github.com/users/mvollmer/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-22T12:06:01Z","updated_at":"2015-06-22T12:30:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2ac66cd7c4fd822668c015b2fad8941d7056785","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9/commits","review_comments_url":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9/comments","review_comment_url":"https://api.github.com/repos/cockpit-project/hubbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockpit-project/hubbot/issues/9/comments","statuses_url":"https://api.github.com/repos/cockpit-project/hubbot/statuses/d943518b060e0479aa2e90ec0ccf9703f45003f1","head":{"label":"mvollmer:expire-images","ref":"expire-images","sha":"d943518b060e0479aa2e90ec0ccf9703f45003f1","user":{"login":"mvollmer","id":3228183,"avatar_url":"https://avatars.githubusercontent.com/u/3228183?v=3","gravatar_id":"","url":"https://api.github.com/users/mvollmer","html_url":"https://github.com/mvollmer","followers_url":"https://api.github.com/users/mvollmer/followers","following_url":"https://api.github.com/users/mvollmer/following{/other_user}","gists_url":"https://api.github.com/users/mvollmer/gists{/gist_id}","starred_url":"https://api.github.com/users/mvollmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvollmer/subscriptions","organizations_url":"https://api.github.com/users/mvollmer/orgs","repos_url":"https://api.github.com/users/mvollmer/repos","events_url":"https://api.github.com/users/mvollmer/events{/privacy}","received_events_url":"https://api.github.com/users/mvollmer/received_events","type":"User","site_admin":false},"repo":{"id":36289285,"name":"hubbot","full_name":"mvollmer/hubbot","owner":{"login":"mvollmer","id":3228183,"avatar_url":"https://avatars.githubusercontent.com/u/3228183?v=3","gravatar_id":"","url":"https://api.github.com/users/mvollmer","html_url":"https://github.com/mvollmer","followers_url":"https://api.github.com/users/mvollmer/followers","following_url":"https://api.github.com/users/mvollmer/following{/other_user}","gists_url":"https://api.github.com/users/mvollmer/gists{/gist_id}","starred_url":"https://api.github.com/users/mvollmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvollmer/subscriptions","organizations_url":"https://api.github.com/users/mvollmer/orgs","repos_url":"https://api.github.com/users/mvollmer/repos","events_url":"https://api.github.com/users/mvollmer/events{/privacy}","received_events_url":"https://api.github.com/users/mvollmer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mvollmer/hubbot","description":"","fork":true,"url":"https://api.github.com/repos/mvollmer/hubbot","forks_url":"https://api.github.com/repos/mvollmer/hubbot/forks","keys_url":"https://api.github.com/repos/mvollmer/hubbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mvollmer/hubbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mvollmer/hubbot/teams","hooks_url":"https://api.github.com/repos/mvollmer/hubbot/hooks","issue_events_url":"https://api.github.com/repos/mvollmer/hubbot/issues/events{/number}","events_url":"https://api.github.com/repos/mvollmer/hubbot/events","assignees_url":"https://api.github.com/repos/mvollmer/hubbot/assignees{/user}","branches_url":"https://api.github.com/repos/mvollmer/hubbot/branches{/branch}","tags_url":"https://api.github.com/repos/mvollmer/hubbot/tags","blobs_url":"https://api.github.com/repos/mvollmer/hubbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mvollmer/hubbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mvollmer/hubbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/mvollmer/hubbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mvollmer/hubbot/statuses/{sha}","languages_url":"https://api.github.com/repos/mvollmer/hubbot/languages","stargazers_url":"https://api.github.com/repos/mvollmer/hubbot/stargazers","contributors_url":"https://api.github.com/repos/mvollmer/hubbot/contributors","subscribers_url":"https://api.github.com/repos/mvollmer/hubbot/subscribers","subscription_url":"https://api.github.com/repos/mvollmer/hubbot/subscription","commits_url":"https://api.github.com/repos/mvollmer/hubbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/mvollmer/hubbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/mvollmer/hubbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/mvollmer/hubbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/mvollmer/hubbot/contents/{+path}","compare_url":"https://api.github.com/repos/mvollmer/hubbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mvollmer/hubbot/merges","archive_url":"https://api.github.com/repos/mvollmer/hubbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mvollmer/hubbot/downloads","issues_url":"https://api.github.com/repos/mvollmer/hubbot/issues{/number}","pulls_url":"https://api.github.com/repos/mvollmer/hubbot/pulls{/number}","milestones_url":"https://api.github.com/repos/mvollmer/hubbot/milestones{/number}","notifications_url":"https://api.github.com/repos/mvollmer/hubbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mvollmer/hubbot/labels{/name}","releases_url":"https://api.github.com/repos/mvollmer/hubbot/releases{/id}","created_at":"2015-05-26T10:38:58Z","updated_at":"2015-05-26T10:38:59Z","pushed_at":"2015-06-22T12:05:35Z","git_url":"git://github.com/mvollmer/hubbot.git","ssh_url":"git@github.com:mvollmer/hubbot.git","clone_url":"https://github.com/mvollmer/hubbot.git","svn_url":"https://github.com/mvollmer/hubbot","homepage":"http://files.cockpit-project.org/hubbot/","size":155,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockpit-project:master","ref":"master","sha":"43da52c8e0170a6e1a065466d26361a8d028679e","user":{"login":"cockpit-project","id":5765104,"avatar_url":"https://avatars.githubusercontent.com/u/5765104?v=3","gravatar_id":"","url":"https://api.github.com/users/cockpit-project","html_url":"https://github.com/cockpit-project","followers_url":"https://api.github.com/users/cockpit-project/followers","following_url":"https://api.github.com/users/cockpit-project/following{/other_user}","gists_url":"https://api.github.com/users/cockpit-project/gists{/gist_id}","starred_url":"https://api.github.com/users/cockpit-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockpit-project/subscriptions","organizations_url":"https://api.github.com/users/cockpit-project/orgs","repos_url":"https://api.github.com/users/cockpit-project/repos","events_url":"https://api.github.com/users/cockpit-project/events{/privacy}","received_events_url":"https://api.github.com/users/cockpit-project/received_events","type":"Organization","site_admin":false},"repo":{"id":36288567,"name":"hubbot","full_name":"cockpit-project/hubbot","owner":{"login":"cockpit-project","id":5765104,"avatar_url":"https://avatars.githubusercontent.com/u/5765104?v=3","gravatar_id":"","url":"https://api.github.com/users/cockpit-project","html_url":"https://github.com/cockpit-project","followers_url":"https://api.github.com/users/cockpit-project/followers","following_url":"https://api.github.com/users/cockpit-project/following{/other_user}","gists_url":"https://api.github.com/users/cockpit-project/gists{/gist_id}","starred_url":"https://api.github.com/users/cockpit-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockpit-project/subscriptions","organizations_url":"https://api.github.com/users/cockpit-project/orgs","repos_url":"https://api.github.com/users/cockpit-project/repos","events_url":"https://api.github.com/users/cockpit-project/events{/privacy}","received_events_url":"https://api.github.com/users/cockpit-project/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockpit-project/hubbot","description":"","fork":false,"url":"https://api.github.com/repos/cockpit-project/hubbot","forks_url":"https://api.github.com/repos/cockpit-project/hubbot/forks","keys_url":"https://api.github.com/repos/cockpit-project/hubbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockpit-project/hubbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockpit-project/hubbot/teams","hooks_url":"https://api.github.com/repos/cockpit-project/hubbot/hooks","issue_events_url":"https://api.github.com/repos/cockpit-project/hubbot/issues/events{/number}","events_url":"https://api.github.com/repos/cockpit-project/hubbot/events","assignees_url":"https://api.github.com/repos/cockpit-project/hubbot/assignees{/user}","branches_url":"https://api.github.com/repos/cockpit-project/hubbot/branches{/branch}","tags_url":"https://api.github.com/repos/cockpit-project/hubbot/tags","blobs_url":"https://api.github.com/repos/cockpit-project/hubbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockpit-project/hubbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockpit-project/hubbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockpit-project/hubbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockpit-project/hubbot/statuses/{sha}","languages_url":"https://api.github.com/repos/cockpit-project/hubbot/languages","stargazers_url":"https://api.github.com/repos/cockpit-project/hubbot/stargazers","contributors_url":"https://api.github.com/repos/cockpit-project/hubbot/contributors","subscribers_url":"https://api.github.com/repos/cockpit-project/hubbot/subscribers","subscription_url":"https://api.github.com/repos/cockpit-project/hubbot/subscription","commits_url":"https://api.github.com/repos/cockpit-project/hubbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockpit-project/hubbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockpit-project/hubbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockpit-project/hubbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockpit-project/hubbot/contents/{+path}","compare_url":"https://api.github.com/repos/cockpit-project/hubbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockpit-project/hubbot/merges","archive_url":"https://api.github.com/repos/cockpit-project/hubbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockpit-project/hubbot/downloads","issues_url":"https://api.github.com/repos/cockpit-project/hubbot/issues{/number}","pulls_url":"https://api.github.com/repos/cockpit-project/hubbot/pulls{/number}","milestones_url":"https://api.github.com/repos/cockpit-project/hubbot/milestones{/number}","notifications_url":"https://api.github.com/repos/cockpit-project/hubbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockpit-project/hubbot/labels{/name}","releases_url":"https://api.github.com/repos/cockpit-project/hubbot/releases{/id}","created_at":"2015-05-26T10:23:17Z","updated_at":"2015-05-26T10:24:47Z","pushed_at":"2015-06-22T12:06:01Z","git_url":"git://github.com/cockpit-project/hubbot.git","ssh_url":"git@github.com:cockpit-project/hubbot.git","clone_url":"https://github.com/cockpit-project/hubbot.git","svn_url":"https://github.com/cockpit-project/hubbot","homepage":"http://files.cockpit-project.org/hubbot/","size":237,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9"},"html":{"href":"https://github.com/cockpit-project/hubbot/pull/9"},"issue":{"href":"https://api.github.com/repos/cockpit-project/hubbot/issues/9"},"comments":{"href":"https://api.github.com/repos/cockpit-project/hubbot/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/cockpit-project/hubbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockpit-project/hubbot/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/cockpit-project/hubbot/statuses/d943518b060e0479aa2e90ec0ccf9703f45003f1"}}}}