[Python-modules-commits] r29765 - in packages/python-aiodocker/trunk (20 files)
tianon-guest at users.alioth.debian.org
tianon-guest at users.alioth.debian.org
Wed Jul 16 04:11:50 UTC 2014
Date: Wednesday, July 16, 2014 @ 04:11:48
Author: tianon-guest
Revision: 29765
[svn-inject] Applying Debian modifications (0.3-1) to trunk
Added:
packages/python-aiodocker/trunk/PKG-INFO
packages/python-aiodocker/trunk/aiodocker/
packages/python-aiodocker/trunk/aiodocker/__init__.py
packages/python-aiodocker/trunk/aiodocker/channel.py
packages/python-aiodocker/trunk/aiodocker/docker.py
packages/python-aiodocker/trunk/aiodocker/utils.py
packages/python-aiodocker/trunk/debian/
packages/python-aiodocker/trunk/debian/Dockerfile
packages/python-aiodocker/trunk/debian/changelog
packages/python-aiodocker/trunk/debian/compat
packages/python-aiodocker/trunk/debian/control
packages/python-aiodocker/trunk/debian/copyright
packages/python-aiodocker/trunk/debian/patches/
packages/python-aiodocker/trunk/debian/patches/series
packages/python-aiodocker/trunk/debian/rules
packages/python-aiodocker/trunk/debian/source/
packages/python-aiodocker/trunk/debian/source/format
packages/python-aiodocker/trunk/debian/watch
packages/python-aiodocker/trunk/setup.cfg
packages/python-aiodocker/trunk/setup.py
Added: packages/python-aiodocker/trunk/PKG-INFO
===================================================================
--- packages/python-aiodocker/trunk/PKG-INFO (rev 0)
+++ packages/python-aiodocker/trunk/PKG-INFO 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: aiodocker
+Version: 0.3
+Summary: does some stuff with things & stuff
+Home-page: UNKNOWN
+Author: Paul Tagliamonte
+Author-email: paultag at debian.org
+License: Expat
+Description: AsyncIO Docker bindings
+Platform: any
Added: packages/python-aiodocker/trunk/aiodocker/__init__.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/__init__.py (rev 0)
+++ packages/python-aiodocker/trunk/aiodocker/__init__.py 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1 @@
+__version__ = "0.3"
Added: packages/python-aiodocker/trunk/aiodocker/channel.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/channel.py (rev 0)
+++ packages/python-aiodocker/trunk/aiodocker/channel.py 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,29 @@
+import asyncio
+
+
+class ChannelIterator:
+ def __init__(self, channel):
+ self.channel = channel
+ self.queue = asyncio.Queue()
+ self.channel.queues.append(self.queue)
+
+ def __del__(self):
+ self.channel.queues.remove(self.queue)
+
+ @asyncio.coroutine
+ def get(self):
+ x = yield from self.queue.get()
+ return x
+
+
+class Channel:
+ def __init__(self):
+ self.queues = []
+
+ @asyncio.coroutine
+ def put(self, obj):
+ for el in self.queues:
+ yield from el.put(obj)
+
+ def listen(self):
+ return ChannelIterator(self)
Added: packages/python-aiodocker/trunk/aiodocker/docker.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/docker.py (rev 0)
+++ packages/python-aiodocker/trunk/aiodocker/docker.py 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,285 @@
+import os
+import base64
+import urllib
+import aiohttp
+import asyncio
+import hashlib
+import json
+import datetime as dt
+from aiohttp import websocket
+
+from aiodocker.channel import Channel
+from aiodocker.utils import identical
+
+
+class Docker:
+ def __init__(self, url="/run/docker.sock"):
+ self.url = url
+ self.events = DockerEvents(self)
+ self.containers = DockerContainers(self)
+ self.connector = aiohttp.UnixSocketConnector(url)
+
+ def _endpoint(self, path, **kwargs):
+ string = "/".join([self.url, path])
+ string = path
+ if kwargs:
+ string += "?" + urllib.parse.urlencode(kwargs)
+ string = "http://fnord/%s" % (string)
+ return string
+
+ def _query(self, path, method='GET', data=None, headers=None, **kwargs):
+ url = self._endpoint(path, **kwargs)
+ response = yield from aiohttp.request(
+ method, url,
+ connector=self.connector,
+ headers=headers, data=data)
+
+ if (response.status // 100) in [4, 5]:
+ what = yield from response.read()
+ response.close()
+ raise ValueError("Got a failure from the server: '%s'" % (
+ what.decode('utf-8').strip()
+ ))
+
+ if 'json' in response.headers.get("Content-Type", ""):
+ try:
+ data = yield from response.json(encoding='utf-8')
+ except ValueError as e:
+ print("Server said", chunk)
+ raise
+ return data
+
+ try:
+ data = yield from response.content.read() # XXX: Correct?
+ except ValueError as e:
+ print("Server said", chunk)
+ raise
+
+ response.close()
+ return data
+
+
+class DockerContainers:
+ def __init__(self, docker):
+ self.docker = docker
+
+ @asyncio.coroutine
+ def list(self, **kwargs):
+ data = yield from self.docker._query(
+ "containers/json",
+ method='GET',
+ **kwargs
+ )
+ return [DockerContainer(self.docker, **x) for x in data]
+
+ @asyncio.coroutine
+ def create_or_replace(self, name, config):
+ container = None
+
+ try:
+ container = yield from self.get(name)
+ if not identical(config, container._container):
+ running = container._container.get(
+ "State", {}).get("Running", False)
+ if running:
+ yield from container.stop()
+ yield from container.delete()
+ container = None
+ except ValueError:
+ pass
+
+ if container is None:
+ container = yield from self.create(config, name=name)
+
+ return container
+
+ @asyncio.coroutine
+ def create(self, config, name=None):
+ url = "containers/create"
+
+ config = json.dumps(config, sort_keys=True, indent=4).encode('utf-8')
+ kwargs = {}
+ if name:
+ kwargs['name'] = name
+ data = yield from self.docker._query(
+ url,
+ method='POST',
+ headers={"content-type": "application/json",},
+ data=config,
+ **kwargs
+ )
+ return DockerContainer(self.docker, id=data['Id'])
+
+ @asyncio.coroutine
+ def get(self, container, **kwargs):
+ data = yield from self.docker._query(
+ "containers/{}/json".format(container),
+ method='GET',
+ **kwargs
+ )
+ return DockerContainer(self.docker, **data)
+
+
+class DockerContainer:
+ def __init__(self, docker, **kwargs):
+ self.docker = docker
+ self._container = kwargs
+ self._id = self._container.get("id", self._container.get(
+ "ID", self._container.get("Id")))
+ self.logs = DockerLog(docker, self)
+
+ @asyncio.coroutine
+ def log(self, stdout=False, stderr=False, **kwargs):
+ if stdout is False and stderr is False:
+ raise TypeError("Need one of stdout or stderr")
+
+ data = yield from self.docker._query(
+ "containers/{}/logs".format(self._id),
+ method='GET',
+ data={
+ "stdout": stdout,
+ "stderr": stderr,
+ "follow": False,
+ }
+ )
+ return data
+
+ @asyncio.coroutine
+ def show(self, **kwargs):
+ data = yield from self.docker._query(
+ "containers/{}/json".format(self._id),
+ method='GET',
+ **kwargs
+ )
+ return data
+
+ @asyncio.coroutine
+ def stop(self, **kwargs):
+ data = yield from self.docker._query(
+ "containers/{}/stop".format(self._id),
+ method='POST',
+ **kwargs
+ )
+ return data
+
+ @asyncio.coroutine
+ def start(self, config, **kwargs):
+ config = json.dumps(config, sort_keys=True, indent=4).encode('utf-8')
+ data = yield from self.docker._query(
+ "containers/{}/start".format(self._id),
+ method='POST',
+ headers={"content-type": "application/json",},
+ data=config,
+ **kwargs
+ )
+ return data
+
+ @asyncio.coroutine
+ def kill(self, **kwargs):
+ data = yield from self.docker._query(
+ "containers/{}/kill".format(self._id),
+ method='POST',
+ **kwargs
+ )
+ return data
+
+ @asyncio.coroutine
+ def wait(self, **kwargs):
+ data = yield from self.docker._query(
+ "containers/{}/wait".format(self._id),
+ method='POST',
+ **kwargs
+ )
+ return data
+
+ @asyncio.coroutine
+ def delete(self, **kwargs):
+ data = yield from self.docker._query(
+ "containers/{}".format(self._id),
+ method='DELETE',
+ **kwargs
+ )
+ return data
+
+
+class DockerEvents:
+ def __init__(self, docker):
+ self.running = False
+ self.docker = docker
+ self.channel = Channel()
+
+ def listen(self):
+ return self.channel.listen()
+
+ def saferun(self):
+ if self.running:
+ return
+ asyncio.async(self.run())
+
+ @asyncio.coroutine
+ def run(self):
+ self.running = True
+ containers = self.docker.containers
+ response = yield from aiohttp.request(
+ 'GET',
+ self.docker._endpoint('events'),
+ connector=self.docker.connector,
+ )
+
+ while True:
+ chunk = yield from response.content.readany()
+ # XXX: WTF. WTF WTF WTF.
+ # WHY AM I NOT GETTING A RETURN ON .READLINE()?! WHY NO NEWLINE
+ # https://github.com/dotcloud/docker/pull/4276 ADDED THEM
+ if chunk == b'':
+ break
+ data = json.loads(chunk.decode('utf-8'))
+
+ if 'time' in data:
+ data['time'] = dt.datetime.fromtimestamp(data['time'])
+
+ if 'id' in data and data['status'] in [
+ "start", "create",
+ ]:
+ data['container'] = yield from containers.get(data['id'])
+
+ asyncio.async(self.channel.put(data))
+ response.close()
+ self.running = False
+
+
+class DockerLog:
+ def __init__(self, docker, container):
+ self.docker = docker
+ self.channel = Channel()
+ self.container = container
+ self.running = False
+
+ def listen(self):
+ return self.channel.listen()
+
+ def saferun(self):
+ if self.running:
+ return
+ asyncio.async(self.run())
+
+ @asyncio.coroutine
+ def run(self):
+ self.running = True
+ containers = self.docker.containers
+ url = self.docker._endpoint(
+ 'containers/{id}/logs'.format(id=self.container._id),
+ follow=True,
+ stdout=True,
+ stderr=True,
+ )
+ response = yield from aiohttp.request(
+ 'GET', url, connector=self.docker.connector)
+
+ while True:
+ msg = yield from response.content.readline()
+ if msg == b'':
+ break
+ asyncio.async(self.channel.put(msg))
+
+ self.running = False
Added: packages/python-aiodocker/trunk/aiodocker/utils.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/utils.py (rev 0)
+++ packages/python-aiodocker/trunk/aiodocker/utils.py 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,19 @@
+def identical(d1, d2):
+ if type(d1) != type(d2):
+ return False
+
+ if isinstance(d1, dict):
+ keys = set(d1.keys()) | set(d2.keys())
+ for key in keys:
+ if not identical(d1.get(key, {}), d2.get(key, {})):
+ return False
+ return True
+
+ if isinstance(d1, list):
+ if len(d1) != len(d2):
+ return False
+
+ pairs = zip(d1, d2)
+ return all((identical(x, y) for (x, y) in pairs))
+
+ return d1 == d2
Property changes on: packages/python-aiodocker/trunk/debian
___________________________________________________________________
Added: mergeWithUpstream
+ 1
Added: packages/python-aiodocker/trunk/debian/Dockerfile
===================================================================
--- packages/python-aiodocker/trunk/debian/Dockerfile (rev 0)
+++ packages/python-aiodocker/trunk/debian/Dockerfile 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,23 @@
+FROM tianon/debian-devel
+
+# start by adding just "debian/control" so we can get mk-build-deps with maximum caching
+ADD control /usr/src/python-aiodocker/debian/
+WORKDIR /usr/src/python-aiodocker
+
+RUN /tianon/prep-source-package.sh python-aiohttp svn://svn.debian.org/svn/python-modules/packages/python-aiohttp/trunk \
+ && cd /usr/src/python-aiohttp \
+ && dpkg-buildpackage -uc -us \
+ && { dpkg -i ../python*-aiohttp*.deb || apt-get install -f; }
+
+# get all the build deps of _this_ package in a nice repeatable way
+RUN apt-get update && mk-build-deps -irt'apt-get --no-install-recommends -yq' debian/control
+
+# need our debian/ directory to compile _this_ package
+ADD . /usr/src/python-aiodocker/debian
+
+# go download and unpack our upstream source
+RUN uscan --force-download --verbose --download-current-version
+RUN origtargz --unpack
+
+# tianon is _really_ lazy, and likes a preseeded bash history
+RUN echo 'origtargz --unpack && dpkg-buildpackage -us -uc && lintian -EvIL+pedantic' >> "$HOME/.bash_history"
Added: packages/python-aiodocker/trunk/debian/changelog
===================================================================
--- packages/python-aiodocker/trunk/debian/changelog (rev 0)
+++ packages/python-aiodocker/trunk/debian/changelog 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,5 @@
+python-aiodocker (0.3-1) UNRELEASED; urgency=medium
+
+ * Initial release.
+
+ -- Tianon Gravi <admwiggin at gmail.com> Thu, 10 Jul 2014 22:00:13 +0200
Added: packages/python-aiodocker/trunk/debian/compat
===================================================================
--- packages/python-aiodocker/trunk/debian/compat (rev 0)
+++ packages/python-aiodocker/trunk/debian/compat 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1 @@
+9
Added: packages/python-aiodocker/trunk/debian/control
===================================================================
--- packages/python-aiodocker/trunk/debian/control (rev 0)
+++ packages/python-aiodocker/trunk/debian/control 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,24 @@
+Source: python-aiodocker
+Section: python
+Priority: optional
+Maintainer: Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
+Uploaders: Tianon Gravi <admwiggin at gmail.com>,
+ Paul Tagliamonte <paultag at debian.org>
+Build-Depends: debhelper (>= 9),
+ dh-python,
+ python3-aiohttp,
+ python3-all (>= 3.4~),
+ python3-setuptools
+Standards-Version: 3.9.5
+Homepage: https://github.com/paultag/aiodocker/
+Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/python-aiodocker/trunk/
+Vcs-Browser: http://anonscm.debian.org/viewvc/python-modules/packages/python-aiodocker/trunk/
+X-Python3-Version: >= 3.4
+
+Package: python3-aiodocker
+Architecture: all
+Depends: ${misc:Depends}, ${python3:Depends}
+Description: Docker client for asyncio
+ Docker client for asyncio.
+ .
+ This package provides Python 3 module bindings only.
Added: packages/python-aiodocker/trunk/debian/copyright
===================================================================
--- packages/python-aiodocker/trunk/debian/copyright (rev 0)
+++ packages/python-aiodocker/trunk/debian/copyright 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,29 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
+Source: https://github.com/KeepSafe/aiohttp
+
+Files: *
+Copyright: 2014 Paul Tagliamonte
+License: Expat
+
+Files: debian/*
+Copyright: 2014 Tianon Gravi <admwiggin at gmail.com>
+License: Expat
+
+License: Expat
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
Added: packages/python-aiodocker/trunk/debian/patches/series
===================================================================
Added: packages/python-aiodocker/trunk/debian/rules
===================================================================
--- packages/python-aiodocker/trunk/debian/rules (rev 0)
+++ packages/python-aiodocker/trunk/debian/rules 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,6 @@
+#!/usr/bin/make -f
+
+export PYBUILD_NAME=aiodocker
+
+%:
+ dh $@ --with python3 --buildsystem pybuild
Property changes on: packages/python-aiodocker/trunk/debian/rules
___________________________________________________________________
Added: svn:executable
+ *
Added: packages/python-aiodocker/trunk/debian/source/format
===================================================================
--- packages/python-aiodocker/trunk/debian/source/format (rev 0)
+++ packages/python-aiodocker/trunk/debian/source/format 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1 @@
+3.0 (quilt)
Added: packages/python-aiodocker/trunk/debian/watch
===================================================================
--- packages/python-aiodocker/trunk/debian/watch (rev 0)
+++ packages/python-aiodocker/trunk/debian/watch 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,3 @@
+version=3
+https://pypi.python.org/packages/source/a/aiodocker/ \
+ aiodocker-(\d.*).tar.gz
Added: packages/python-aiodocker/trunk/setup.cfg
===================================================================
--- packages/python-aiodocker/trunk/setup.cfg (rev 0)
+++ packages/python-aiodocker/trunk/setup.cfg 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
Added: packages/python-aiodocker/trunk/setup.py
===================================================================
--- packages/python-aiodocker/trunk/setup.py (rev 0)
+++ packages/python-aiodocker/trunk/setup.py 2014-07-16 04:11:48 UTC (rev 29765)
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+from setuptools import setup
+from aiodocker import __version__
+
+long_description = "AsyncIO Docker bindings"
+
+setup(
+ name="aiodocker",
+ version=__version__,
+ packages=['aiodocker',], # This is empty without the line below
+ author="Paul Tagliamonte",
+ author_email="paultag at debian.org",
+ long_description=long_description,
+ description='does some stuff with things & stuff',
+ license="Expat",
+ url="",
+ platforms=['any']
+)
Property changes on: packages/python-aiodocker/trunk/setup.py
___________________________________________________________________
Added: svn:executable
+ *
More information about the Python-modules-commits
mailing list