Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar_network
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2014-01-30 14:08:03 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2014-01-30 14:08:03 (GMT)
commit2ca3e5f20ec1ad1c122a098abb174dc737df7c32 (patch)
treee02a87ce28f1be8698cd78e6f8becbda963ec633 /sugar_network
parentfc17a971c24b8b1084a47f33ea642bf5c287aef3 (diff)
Rename Implementation resource to Release
Diffstat (limited to 'sugar_network')
-rw-r--r--sugar_network/client/cache.py8
-rw-r--r--sugar_network/client/releases.py (renamed from sugar_network/client/implementations.py)14
-rw-r--r--sugar_network/client/routes.py12
-rw-r--r--sugar_network/client/solver.py14
-rw-r--r--sugar_network/model/__init__.py2
-rw-r--r--sugar_network/model/release.py (renamed from sugar_network/model/implementation.py)2
-rw-r--r--sugar_network/model/report.py10
-rw-r--r--sugar_network/model/routes.py6
-rw-r--r--sugar_network/node/master.py8
-rw-r--r--sugar_network/node/routes.py21
-rw-r--r--sugar_network/node/stats_node.py8
-rw-r--r--sugar_network/node/volume.py2
12 files changed, 52 insertions, 55 deletions
diff --git a/sugar_network/client/cache.py b/sugar_network/client/cache.py
index 07daa16..e13ccb6 100644
--- a/sugar_network/client/cache.py
+++ b/sugar_network/client/cache.py
@@ -77,7 +77,7 @@ class Cache(object):
self._pool.__getitem__(guid)
return
_logger.debug('Checkin %r %d bytes long', guid, size)
- mtime = os.stat(self._volume['implementation'].path(guid)).st_mtime
+ mtime = os.stat(self._volume['release'].path(guid)).st_mtime
self._pool[guid] = (size, mtime)
self._du += size
@@ -109,10 +109,10 @@ class Cache(object):
if self._pool is not None:
return
- _logger.debug('Open implementations pool')
+ _logger.debug('Open releases pool')
pool = []
- impls = self._volume['implementation']
+ impls = self._volume['release']
for res in impls.find(not_layer=['local'])[0]:
meta = res.meta('data')
if not meta or 'blob_size' not in meta:
@@ -176,7 +176,7 @@ class Cache(object):
_logger.debug('Recycle stale %r to save %s bytes', guid, size)
else:
_logger.debug('Recycle %r to save %s bytes', guid, size)
- self._volume['implementation'].delete(guid)
+ self._volume['release'].delete(guid)
self._du -= size
if guid in self._pool:
del self._pool[guid]
diff --git a/sugar_network/client/implementations.py b/sugar_network/client/releases.py
index ca9e89c..98b14b2 100644
--- a/sugar_network/client/implementations.py
+++ b/sugar_network/client/releases.py
@@ -38,7 +38,7 @@ from sugar_network.toolkit import http, coroutine, enforce
_MIMETYPE_DEFAULTS_KEY = '/desktop/sugar/journal/defaults'
_MIMETYPE_INVALID_CHARS = re.compile('[^a-zA-Z0-9-_/.]')
-_logger = logging.getLogger('implementations')
+_logger = logging.getLogger('releases')
class Routes(object):
@@ -58,7 +58,7 @@ class Routes(object):
clone_path = self._volume['context'].path(request.guid, '.clone')
enforce(exists(clone_path), http.NotFound)
clone_impl = basename(os.readlink(clone_path))
- return self._volume['implementation'].path(clone_impl, 'data')
+ return self._volume['release'].path(clone_impl, 'data')
@route('GET', ['context', None], cmd='launch', arguments={'args': list},
mime_type='text/event-stream')
@@ -114,8 +114,7 @@ class Routes(object):
yield {'event': 'ready'}
else:
cloned_impl = basename(os.readlink(cloned_path))
- meta = self._volume['implementation'].get(
- cloned_impl).meta('data')
+ meta = self._volume['release'].get(cloned_impl).meta('data')
size = meta.get('unpack_size') or meta['blob_size']
self._cache.checkin(cloned_impl, size)
os.unlink(cloned_path)
@@ -213,7 +212,7 @@ class Routes(object):
def _checkin_impl(self, context, request, cache_call):
if 'clone' in context['layer']:
cache_call = self._cache.checkout
- impls = self._volume['implementation']
+ impls = self._volume['release']
if 'activity' in context['type']:
to_install = []
@@ -239,8 +238,7 @@ class Routes(object):
return cache_call(guid, size)
if blob is None:
- blob = self._call(method='GET',
- path=['implementation', guid, 'data'])
+ blob = self._call(method='GET', path=['release', guid, 'data'])
blob_dir = dirname(sel['path'])
if not exists(blob_dir):
@@ -318,7 +316,7 @@ class Routes(object):
if 'clone' not in context['layer']:
return self._map_exceptions(self.fallback, request, response)
guid = basename(os.readlink(context.path('.clone')))
- impl = self._volume['implementation'].get(guid)
+ impl = self._volume['release'].get(guid)
response.meta = impl.properties([
'guid', 'ctime', 'layer', 'author', 'tags',
'context', 'version', 'stability', 'license', 'notes', 'data',
diff --git a/sugar_network/client/routes.py b/sugar_network/client/routes.py
index e43eea5..c6ea6d2 100644
--- a/sugar_network/client/routes.py
+++ b/sugar_network/client/routes.py
@@ -21,7 +21,7 @@ from zipfile import ZipFile, ZIP_DEFLATED
from os.path import join, basename
from sugar_network import db, client, node, toolkit, model
-from sugar_network.client import journal, implementations
+from sugar_network.client import journal, releases
from sugar_network.node.slave import SlaveRoutes
from sugar_network.toolkit import netlink, mountpoints
from sugar_network.toolkit.router import ACL, Request, Response, Router
@@ -40,11 +40,11 @@ _LOCAL_LAYERS = frozenset(['local', 'clone', 'favorite'])
_logger = logging.getLogger('client.routes')
-class ClientRoutes(model.FrontRoutes, implementations.Routes, journal.Routes):
+class ClientRoutes(model.FrontRoutes, releases.Routes, journal.Routes):
def __init__(self, home_volume, api_url=None, no_subscription=False):
model.FrontRoutes.__init__(self)
- implementations.Routes.__init__(self, home_volume)
+ releases.Routes.__init__(self, home_volume)
journal.Routes.__init__(self)
self._local = _LocalRoutes(home_volume)
@@ -201,7 +201,7 @@ class ClientRoutes(model.FrontRoutes, implementations.Routes, journal.Routes):
request.update(kwargs)
if self._inline.is_set():
if client.layers.value and \
- request.resource in ('context', 'implementation'):
+ request.resource in ('context', 'release'):
request.add('layer', *client.layers.value)
request.principal = self._auth.login
try:
@@ -262,7 +262,7 @@ class ClientRoutes(model.FrontRoutes, implementations.Routes, journal.Routes):
def pull_events():
for event in self._node.subscribe():
- if event.get('resource') == 'implementation':
+ if event.get('resource') == 'release':
mtime = event.get('mtime')
if mtime:
self.invalidate_solutions(mtime)
@@ -273,7 +273,7 @@ class ClientRoutes(model.FrontRoutes, implementations.Routes, journal.Routes):
self._node = client.Connection(url, auth=self._auth)
status = self._node.get(cmd='status')
self._auth.allow_basic_auth = (status.get('level') == 'master')
- impl_info = status['resources'].get('implementation')
+ impl_info = status['resources'].get('release')
if impl_info:
self.invalidate_solutions(impl_info['mtime'])
if self._inline.is_set():
diff --git a/sugar_network/client/solver.py b/sugar_network/client/solver.py
index 0b24579..67350b6 100644
--- a/sugar_network/client/solver.py
+++ b/sugar_network/client/solver.py
@@ -149,7 +149,7 @@ def solve(call, context, stability):
if reason_exception is not None:
reason = reason_exception.message
else:
- reason = 'Cannot find implementations for %s' % ', '.join(missed)
+ reason = 'Cannot find releases for %s' % ', '.join(missed)
raise http.NotFound(reason)
solution = []
@@ -209,10 +209,10 @@ def _load_feed(context):
feed.to_resolve = feed_content.get('packages')
if not feed.to_resolve:
_logger.trace('[%s] No compatible packages', context)
- for impl in feed_content['implementations']:
+ for impl in feed_content['releases']:
feed.implement(impl)
if not feed.to_resolve and not feed.implementations:
- _logger.trace('[%s] No implementations', context)
+ _logger.trace('[%s] No releases', context)
return feed
@@ -242,7 +242,7 @@ class _Feed(model.ZeroInstallFeed):
def resolve(self, packages):
top_package = packages[0]
- impl = _Implementation(self, self.context, None)
+ impl = _Release(self, self.context, None)
impl.version = parse_version(top_package['version'])
impl.released = 0
impl.arch = '*-%s' % (top_package['arch'] or '*')
@@ -262,7 +262,7 @@ class _Feed(model.ZeroInstallFeed):
impl_id = release['guid']
spec = release['data']['spec']['*-*']
- impl = _Implementation(self, impl_id, None)
+ impl = _Release(self, impl_id, None)
impl.version = parse_version(release['version'])
impl.released = 0
impl.arch = '*-*'
@@ -288,7 +288,7 @@ class _Feed(model.ZeroInstallFeed):
def implement_sugar(self, sugar_version):
impl_id = 'sugar-%s' % sugar_version
- impl = _Implementation(self, impl_id, None)
+ impl = _Release(self, impl_id, None)
impl.version = parse_version(sugar_version)
impl.released = 0
impl.arch = '*-*'
@@ -302,7 +302,7 @@ class _Feed(model.ZeroInstallFeed):
}
-class _Implementation(model.ZeroInstallImplementation):
+class _Release(model.ZeroInstallImplementation):
to_install = None
sn_impl = None
diff --git a/sugar_network/model/__init__.py b/sugar_network/model/__init__.py
index c846bc7..117649b 100644
--- a/sugar_network/model/__init__.py
+++ b/sugar_network/model/__init__.py
@@ -35,7 +35,7 @@ RESOURCES = (
'sugar_network.model.artifact',
'sugar_network.model.comment',
'sugar_network.model.context',
- 'sugar_network.model.implementation',
+ 'sugar_network.model.release',
'sugar_network.model.notification',
'sugar_network.model.feedback',
'sugar_network.model.report',
diff --git a/sugar_network/model/implementation.py b/sugar_network/model/release.py
index 53473e3..46eeaae 100644
--- a/sugar_network/model/implementation.py
+++ b/sugar_network/model/release.py
@@ -21,7 +21,7 @@ from sugar_network.toolkit.licenses import GOOD_LICENSES
from sugar_network.toolkit.spec import parse_version
-class Implementation(db.Resource):
+class Release(db.Resource):
@db.indexed_property(prefix='C',
acl=ACL.CREATE | ACL.READ)
diff --git a/sugar_network/model/report.py b/sugar_network/model/report.py
index 8b2ca05..84db43a 100644
--- a/sugar_network/model/report.py
+++ b/sugar_network/model/report.py
@@ -24,13 +24,13 @@ class Report(db.Resource):
return value
@db.indexed_property(prefix='V', default='', acl=ACL.CREATE | ACL.READ)
- def implementation(self, value):
+ def release(self, value):
return value
- @implementation.setter
- def implementation(self, value):
- if value and 'version' not in self.props and 'implementation' in value:
- version = self.volume['implementation'].get(value)
+ @release.setter
+ def release(self, value):
+ if value and 'version' not in self.props and 'release' in value:
+ version = self.volume['release'].get(value)
self['version'] = version['version']
return value
diff --git a/sugar_network/model/routes.py b/sugar_network/model/routes.py
index c5c4929..c8f8da6 100644
--- a/sugar_network/model/routes.py
+++ b/sugar_network/model/routes.py
@@ -31,10 +31,10 @@ class VolumeRoutes(db.Routes):
mime_type='application/json')
def feed(self, request, distro):
context = self.volume['context'].get(request.guid)
- implementations = self.volume['implementation']
+ releases = self.volume['release']
versions = []
- impls, __ = implementations.find(context=context.guid,
+ impls, __ = releases.find(context=context.guid,
not_layer='deleted', **request)
for impl in impls:
version = impl.properties([
@@ -51,7 +51,7 @@ class VolumeRoutes(db.Routes):
del data[key]
versions.append(version)
- result = {'implementations': versions}
+ result = {'releases': versions}
if distro:
aliases = context['aliases'].get(distro)
if aliases and 'binary' in aliases:
diff --git a/sugar_network/node/master.py b/sugar_network/node/master.py
index 9903fd8..19a8cf1 100644
--- a/sugar_network/node/master.py
+++ b/sugar_network/node/master.py
@@ -146,14 +146,14 @@ class MasterRoutes(NodeRoutes):
def after_post(self, doc):
if doc.metadata.name == 'context':
- shift_implementations = doc.modified('dependencies')
+ shift_releases = doc.modified('dependencies')
if doc.modified('aliases'):
# TODO Already launched job should be killed
coroutine.spawn(self._resolve_aliases, doc)
- shift_implementations = True
- if shift_implementations and not doc.is_new:
+ shift_releases = True
+ if shift_releases and not doc.is_new:
# Shift checkpoint to invalidate solutions
- self.volume['implementation'].checkpoint()
+ self.volume['release'].checkpoint()
NodeRoutes.after_post(self, doc)
def _push(self, stream):
diff --git a/sugar_network/node/routes.py b/sugar_network/node/routes.py
index ebb46a8..5f066a9 100644
--- a/sugar_network/node/routes.py
+++ b/sugar_network/node/routes.py
@@ -149,10 +149,10 @@ class NodeRoutes(model.VolumeRoutes, model.FrontRoutes):
response.content_type = 'application/json'
return result
- @route('POST', ['implementation'], cmd='submit',
+ @route('POST', ['release'], cmd='submit',
arguments={'initial': False},
mime_type='application/json', acl=ACL.AUTH)
- def submit_implementation(self, request, document):
+ def submit_release(self, request, document):
with toolkit.NamedTemporaryFile() as blob:
shutil.copyfileobj(request.content_stream, blob)
blob.flush()
@@ -373,7 +373,7 @@ class NodeRoutes(model.VolumeRoutes, model.FrontRoutes):
if 'stability' not in request:
request['stability'] = 'stable'
- impls, __ = self.volume['implementation'].find(
+ impls, __ = self.volume['release'].find(
context=request.guid, order_by='-version', not_layer='deleted',
**request)
impl = None
@@ -384,13 +384,13 @@ class NodeRoutes(model.VolumeRoutes, model.FrontRoutes):
continue
break
else:
- raise http.NotFound('No implementations found')
+ raise http.NotFound('No releases found')
return impl
def _get_clone(self, request, response):
impl = self._solve(request)
result = request.call(method=request.method,
- path=['implementation', impl['guid'], 'data'],
+ path=['release', impl['guid'], 'data'],
response=response)
response.meta = impl.properties([
'guid', 'ctime', 'layer', 'author', 'tags',
@@ -437,12 +437,12 @@ def generate_node_stats(volume, path):
for resource, props in [
('user', []),
('context', []),
- ('implementation', ['context']),
+ ('release', ['context']),
('artifact', ['context', 'type']),
('feedback', ['context']),
('solution', ['context', 'feedback']),
('review', ['context', 'artifact', 'rating']),
- ('report', ['context', 'implementation']),
+ ('report', ['context', 'release']),
('comment', ['context', 'review', 'feedback', 'solution']),
]:
objs, __ = volume[resource].find(
@@ -454,7 +454,7 @@ def generate_node_stats(volume, path):
for resource, props in [
('user', ['layer']),
('context', ['layer']),
- ('implementation', ['layer']),
+ ('release', ['layer']),
('artifact', ['layer']),
('feedback', ['layer', 'solution']),
('solution', ['layer']),
@@ -498,7 +498,7 @@ def load_bundle(volume, request, bundle_path):
contexts = volume['context']
context = impl.get('context')
context_meta = None
- impls = volume['implementation']
+ impls = volume['release']
try:
bundle = Bundle(bundle_path, mime_type='application/zip')
@@ -574,8 +574,7 @@ def load_bundle(volume, request, bundle_path):
context=context, version=impl['version'], not_layer='deleted')
if 'url' not in data:
data['blob'] = bundle_path
- impl['guid'] = \
- request.call(method='POST', path=['implementation'], content=impl)
+ impl['guid'] = request.call(method='POST', path=['release'], content=impl)
for i in existing:
layer = i['layer'] + ['deleted']
impls.update(i.guid, {'layer': layer})
diff --git a/sugar_network/node/stats_node.py b/sugar_network/node/stats_node.py
index 8a91994..cc77424 100644
--- a/sugar_network/node/stats_node.py
+++ b/sugar_network/node/stats_node.py
@@ -250,9 +250,9 @@ class _ContextStats(_ResourceStats):
self['downloaded'] = 0
-class _ImplementationStats(_Stats):
+class _ReleaseStats(_Stats):
- RESOURCE = 'implementation'
+ RESOURCE = 'release'
OWNERS = ['context']
def log(self, request):
@@ -268,7 +268,7 @@ class _ImplementationStats(_Stats):
class _ReportStats(_Stats):
RESOURCE = 'report'
- OWNERS = ['context', 'implementation']
+ OWNERS = ['context', 'release']
def log(self, request):
if request.method == 'POST':
@@ -338,7 +338,7 @@ class _CommentStats(_ResourceStats):
_STATS = {_UserStats.RESOURCE: _UserStats,
_ContextStats.RESOURCE: _ContextStats,
- _ImplementationStats.RESOURCE: _ImplementationStats,
+ _ReleaseStats.RESOURCE: _ReleaseStats,
_ReportStats.RESOURCE: _ReportStats,
_ReviewStats.RESOURCE: _ReviewStats,
_FeedbackStats.RESOURCE: _FeedbackStats,
diff --git a/sugar_network/node/volume.py b/sugar_network/node/volume.py
index 00ff983..0c254f7 100644
--- a/sugar_network/node/volume.py
+++ b/sugar_network/node/volume.py
@@ -21,7 +21,7 @@ from sugar_network.toolkit import http, coroutine, enforce
# Apply node level layer for these documents
-_LIMITED_RESOURCES = ('context', 'implementation')
+_LIMITED_RESOURCES = ('context', 'release')
_logger = logging.getLogger('node.volume')