[Python-modules-commits] r29766 - in packages/python-aiodocker/trunk (7 files)
tianon-guest at users.alioth.debian.org
tianon-guest at users.alioth.debian.org
Wed Jul 16 04:21:57 UTC 2014
Date: Wednesday, July 16, 2014 @ 04:20:50
Author: tianon-guest
Revision: 29766
Remove upstream artifacts (I know I used -o... how did these get here?)
Deleted:
packages/python-aiodocker/trunk/PKG-INFO
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/setup.cfg
packages/python-aiodocker/trunk/setup.py
Deleted: packages/python-aiodocker/trunk/PKG-INFO
===================================================================
--- packages/python-aiodocker/trunk/PKG-INFO 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/PKG-INFO 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1,10 +0,0 @@
-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
Deleted: packages/python-aiodocker/trunk/aiodocker/__init__.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/__init__.py 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/aiodocker/__init__.py 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1 +0,0 @@
-__version__ = "0.3"
Deleted: packages/python-aiodocker/trunk/aiodocker/channel.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/channel.py 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/aiodocker/channel.py 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1,29 +0,0 @@
-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)
Deleted: packages/python-aiodocker/trunk/aiodocker/docker.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/docker.py 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/aiodocker/docker.py 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1,285 +0,0 @@
-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
Deleted: packages/python-aiodocker/trunk/aiodocker/utils.py
===================================================================
--- packages/python-aiodocker/trunk/aiodocker/utils.py 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/aiodocker/utils.py 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1,19 +0,0 @@
-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
Deleted: packages/python-aiodocker/trunk/setup.cfg
===================================================================
--- packages/python-aiodocker/trunk/setup.cfg 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/setup.cfg 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1,5 +0,0 @@
-[egg_info]
-tag_build =
-tag_date = 0
-tag_svn_revision = 0
-
Deleted: packages/python-aiodocker/trunk/setup.py
===================================================================
--- packages/python-aiodocker/trunk/setup.py 2014-07-16 04:11:48 UTC (rev 29765)
+++ packages/python-aiodocker/trunk/setup.py 2014-07-16 04:20:50 UTC (rev 29766)
@@ -1,19 +0,0 @@
-#!/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']
-)
More information about the Python-modules-commits
mailing list