Merge lp:~abentley/charmworld/stop-ingesting-icon into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Curtis Hovey
Approved revision: 247
Merged at revision: 245
Proposed branch: lp:~abentley/charmworld/stop-ingesting-icon
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 170 lines (+39/-22)
6 files modified
charmworld/jobs/ingest.py (+0/-12)
charmworld/jobs/lp.py (+15/-6)
charmworld/jobs/tests/test_bzr.py (+1/-1)
charmworld/jobs/tests/test_lp.py (+16/-1)
migrations/versions/006_no_op.py (+5/-0)
migrations/versions/tests/test_migrations.py (+2/-2)
To merge this branch: bzr merge lp:~abentley/charmworld/stop-ingesting-icon
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+167613@code.launchpad.net

Commit message

Stop adding icon during ingest.

Description of the change

The 006 migration deleted icons from the charm data, but ingest restored them.

This branch updates ingest to stop storing icon data and renames the 006 migration to 007 so that it will run again.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/jobs/ingest.py'
2--- charmworld/jobs/ingest.py 2013-05-29 20:43:01 +0000
3+++ charmworld/jobs/ingest.py 2013-06-05 18:36:28 +0000
4@@ -1,7 +1,6 @@
5 # Copyright 2013 Canonical Ltd. This software is licensed under the
6 # GNU Affero General Public License version 3 (see the file LICENSE).
7
8-from base64 import b64encode
9 import calendar
10 import contextlib
11 from datetime import (
12@@ -121,17 +120,6 @@
13 (quote_key(cfile.filename), dict(cfile)) for cfile in
14 self.store_branch_files(charm_data)
15 ])
16- if ICON_FILENAME in os.listdir(charm_data['branch_dir']):
17- file_path = os.path.join(charm_data['branch_dir'], ICON_FILENAME)
18- with open(file_path, 'rb') as icon_file:
19- charm_data['icon'] = b64encode(icon_file.read())
20- else:
21- # It might happen that an existing icon is removed from the
22- # charm. We should assume that this is a deliberate decision
23- # by the charm's maintainer, be it for an aesthetic, legal
24- # or any other reason.
25- if 'icon' in charm_data:
26- del charm_data['icon']
27 return charm_data
28
29 def checkout_charm(self, charm_data, branch_dir):
30
31=== modified file 'charmworld/jobs/lp.py'
32--- charmworld/jobs/lp.py 2013-05-24 09:42:29 +0000
33+++ charmworld/jobs/lp.py 2013-06-05 18:36:28 +0000
34@@ -20,7 +20,12 @@
35 from utils import parse_branch
36
37
38-def available_charms(charm_data=None, limit=None):
39+default = object()
40+
41+
42+def available_charms(charm_data=None, limit=None, import_filter=default):
43+ if import_filter is default:
44+ import_filter = CHARM_IMPORT_FILTER
45 log = logging.getLogger("charm.launchpad")
46 if not charm_data:
47 charm_data = get_branch_tips()
48@@ -36,8 +41,8 @@
49 log.warning("Unable to parse repo %s", repo)
50 continue
51
52- if CHARM_IMPORT_FILTER and not data['branch_spec'].startswith(
53- CHARM_IMPORT_FILTER):
54+ if import_filter and not data['branch_spec'].startswith(
55+ import_filter):
56 continue
57
58 if data["bname"] not in ("trunk", "trunk-1"):
59@@ -59,9 +64,9 @@
60 break
61
62
63-def queue_charms(out_queue, limit=None):
64+def queue_charms(out_queue, limit=None, import_filter=default):
65 log = logging.getLogger("charm.launchpad")
66- for charm in available_charms(limit=limit):
67+ for charm in available_charms(limit=limit, import_filter=import_filter):
68 added = out_queue.put(charm)
69 if added and 0:
70 log.info("Queued %s", charm)
71@@ -74,6 +79,10 @@
72 "--limit",
73 help="Maximum number of charms to queue.",
74 type=int)
75+ parser.add_argument(
76+ "--prefix",
77+ help="Only charms matching this prefix are queued.",
78+ type=str, default=default)
79 args = parser.parse_args()
80 log = logging.getLogger("charm.launchpad")
81 settings = get_ini()
82@@ -89,7 +98,7 @@
83 with lock('ingest-queue', int(settings['script_lease_time']) * 60,
84 db, log):
85 queue = get_queue(CHARM_QUEUE)
86- queue_charms(queue, charm_import_limit)
87+ queue_charms(queue, charm_import_limit, args.prefix)
88 except LockHeld, error:
89 log.warn(str(error))
90
91
92=== modified file 'charmworld/jobs/tests/test_bzr.py'
93--- charmworld/jobs/tests/test_bzr.py 2013-04-24 20:30:58 +0000
94+++ charmworld/jobs/tests/test_bzr.py 2013-06-05 18:36:28 +0000
95@@ -102,7 +102,7 @@
96 job.setup(db=self.db)
97 job.add_files(charm_data)
98 self.assertIn('files', charm_data)
99- self.assertIn('icon', charm_data)
100+ self.assertNotIn('icon', charm_data)
101
102
103 @contextmanager
104
105=== modified file 'charmworld/jobs/tests/test_lp.py'
106--- charmworld/jobs/tests/test_lp.py 2013-05-23 10:57:51 +0000
107+++ charmworld/jobs/tests/test_lp.py 2013-06-05 18:36:28 +0000
108@@ -17,7 +17,7 @@
109 from charmworld.jobs.utils import get_queue
110
111
112-def available_charms_mock(charm_data=None, limit=None):
113+def available_charms_mock(charm_data=None, limit=None, import_filter=None):
114 yield {'branch_dir': 'foo', 'branch_spec': 'bar'}
115
116
117@@ -89,6 +89,21 @@
118 charms = [charm for charm in available_charms(charm_data)]
119 self.assertEqual([], charms)
120
121+ def test_available_charms_explicit_filter(self):
122+ # If the branch doesn't start with the defined filter (i.e.
123+ # ~charmers/charms/precise) it is not returned
124+ charm_data = [[u'~not-charmers/charms/precise/someproject/trunk',
125+ u'ja@appflower.com-20120329093714-s2m9e28dwotmijqc',
126+ []],
127+ [u'~charmers/charms/precise/someproject/trunk',
128+ u'ja@appflower.com-20120329093714-s2m9e28dwotmijqc',
129+ []],
130+ ]
131+ charms = available_charms(
132+ charm_data, import_filter='~charmers/charms/precise')
133+ self.assertEqual(['~charmers/charms/precise/someproject/trunk'],
134+ [charm['branch_spec'] for charm in charms])
135+
136 def test_available_charms_not_trunk(self):
137 # If the branch is not trunk or trunk-1, the charm is not returned by
138 # available charms.
139
140=== added file 'migrations/versions/006_no_op.py'
141--- migrations/versions/006_no_op.py 1970-01-01 00:00:00 +0000
142+++ migrations/versions/006_no_op.py 2013-06-05 18:36:28 +0000
143@@ -0,0 +1,5 @@
144+# Copyright 2013 Canonical Ltd. This software is licensed under the
145+# GNU Affero General Public License version 3 (see the file LICENSE).
146+
147+def upgrade(db, index_client):
148+ """006 lacked a corresponding ingest update, so now disabled."""
149
150=== renamed file 'migrations/versions/006_delete_icon_field.py' => 'migrations/versions/007_delete_icon_field.py'
151=== modified file 'migrations/versions/tests/test_migrations.py'
152--- migrations/versions/tests/test_migrations.py 2013-06-04 18:22:19 +0000
153+++ migrations/versions/tests/test_migrations.py 2013-06-05 18:36:28 +0000
154@@ -66,14 +66,14 @@
155 self.assertNotIn('charm-errors', self.db.collection_names())
156
157
158-class TestMigration006(MongoTestBase):
159+class TestMigration007(MongoTestBase):
160
161 def test_migration(self):
162 self.use_index_client()
163 source = CharmSource.from_request(self)
164 source.save({'_id': 'a', 'icon': 'asdf', 'asdf': 'asdf'})
165 source.save({'_id': 'b', 'icon': 'asdf', 'asdf': 'asdf'})
166- run_migration(self.db, self.index_client, '006_delete_icon_field.py')
167+ run_migration(self.db, self.index_client, '007_delete_icon_field.py')
168 for charm in source._get_all('a'):
169 self.assertNotIn('icon', charm)
170 for charm in source._get_all('b'):

Subscribers

People subscribed via source and target branches