Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-10-02 11:31:42 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-10-02 11:31:42 (GMT)
commitef69b25a9ba9c34abe0493026162790bbb5ea424 (patch)
treeb875d603ff42a1d1d77007cb86a9cc564150616e
parent4fdceee90d15ad7786e7403fddc4639222773cc7 (diff)
Fix minor issues in package resolving code
-rw-r--r--TODO1
-rwxr-xr-xmisc/aslo-sync13
-rwxr-xr-xsugar-network-service4
-rw-r--r--sugar_network/node/obs.py2
-rw-r--r--sugar_network/resources/context.py9
-rwxr-xr-xtests/units/obs.py8
6 files changed, 27 insertions, 10 deletions
diff --git a/TODO b/TODO
index e11ffd7..72eef8e 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,4 @@
+- from service API, return 304 HTTP status w/o pinging remote SN server
- check if moon icon is uptodate
- reuse the same data dir for all SN resources for the same context
- GC BLOBs cache
diff --git a/misc/aslo-sync b/misc/aslo-sync
index 0166061..c69374b 100755
--- a/misc/aslo-sync
+++ b/misc/aslo-sync
@@ -42,6 +42,7 @@ ACTIVITIES_PATH = '/upload/activities'
EXCLUDE_BUNDLE_IDS = ['net.gcompris']
SUGAR_GUID = 'sugar'
SN_GUID = 'sugar-network'
+PACKAGES_GUID = 'packages'
CATEGIORIES_TO_TAGS = {
'Search & Discovery': 'discovery',
@@ -119,6 +120,18 @@ class Application(application.Application):
ctime=time.time(), mtime=time.time(),
)
+ if not self.volume['context'].exists(PACKAGES_GUID):
+ self.volume['context'].create(
+ guid=PACKAGES_GUID,
+ implement=PACKAGES_GUID,
+ type='project',
+ title='Packages',
+ summary='Collection of GNU/Linux packages metadata',
+ description='Collection of GNU/Linux packages metadata',
+ ctime=time.time(), mtime=time.time())
+ self.volume['context'].set_blob(PACKAGES_GUID, 'icon',
+ url='/static/images/package.png')
+
if self.args:
for addon_id in self.args:
self.sync_activities(addon_id)
diff --git a/sugar-network-service b/sugar-network-service
index 37cb2f2..f0267a6 100755
--- a/sugar-network-service
+++ b/sugar-network-service
@@ -301,7 +301,8 @@ class Application(application.Application):
break
def _sync(self, volume):
- docs, __ = volume['context'].find(limit=ad.MAX_LIMIT, keep_impl=[1, 2])
+ contexts = volume['context']
+ docs, __ = contexts.find(limit=ad.MAX_LIMIT, keep_impl=[1, 2])
for context in docs:
if not activities.ensure_checkins(context.guid):
contexts.update(context.guid, keep_impl=0)
@@ -320,6 +321,7 @@ local.tmpdir.value = sugar.profile_path('tmp')
Option.seek('main', [application.debug])
Option.seek('webui', webui)
Option.seek('local', local)
+Option.seek('local', [sugar.keyfile])
Option.seek('node', [node.port, node.sync_dirs])
Option.seek('stats', stats)
Option.seek('active-document', ad)
diff --git a/sugar_network/node/obs.py b/sugar_network/node/obs.py
index 8100096..e1bb39e 100644
--- a/sugar_network/node/obs.py
+++ b/sugar_network/node/obs.py
@@ -107,8 +107,6 @@ def presolve(repo, arch, names):
})
for pkg in reply.findall('binary'):
result.append({
- # TODO more distros after supporting them PK backend
- 'distributor_id': 'Fedora',
'name': pkg.get('name'),
'url': pkg.get('url'),
})
diff --git a/sugar_network/resources/context.py b/sugar_network/resources/context.py
index 3c3827d..d5f5340 100644
--- a/sugar_network/resources/context.py
+++ b/sugar_network/resources/context.py
@@ -172,9 +172,12 @@ class Context(Resource):
try:
to_resolve = alias.get('binary', []) + \
alias.get('devel', [])
- for arch in repo['arches']:
- obs.resolve(repo['name'], arch, to_resolve)
- alias['status'] = 'success'
+ if to_resolve:
+ for arch in repo['arches']:
+ obs.resolve(repo['name'], arch, to_resolve)
+ alias['status'] = 'success'
+ else:
+ alias['status'] = 'no packages to resolve'
except Exception, error:
util.exception('Failed to resolve %r', alias)
alias = {'status': str(error)}
diff --git a/tests/units/obs.py b/tests/units/obs.py
index b621384..e82e6d9 100755
--- a/tests/units/obs.py
+++ b/tests/units/obs.py
@@ -131,10 +131,10 @@ class ObsTest(tests.Test):
]))
self.assertEqual([
- {'distributor_id': 'Fedora', 'url': 'http://pkg1-1.prm', 'name': 'pkg1-1'},
- {'distributor_id': 'Fedora', 'url': 'http://pkg1-2.prm', 'name': 'pkg1-2'},
- {'distributor_id': 'Fedora', 'url': 'http://pkg2-1.prm', 'name': 'pkg2-1'},
- {'distributor_id': 'Fedora', 'url': 'http://pkg2-2.prm', 'name': 'pkg2-2'},
+ {'url': 'http://pkg1-1.prm', 'name': 'pkg1-1'},
+ {'url': 'http://pkg1-2.prm', 'name': 'pkg1-2'},
+ {'url': 'http://pkg2-1.prm', 'name': 'pkg2-1'},
+ {'url': 'http://pkg2-2.prm', 'name': 'pkg2-2'},
],
obs.presolve('repo', 'arch', ['pkg1', 'pkg2']))