[Pkg-debile-commits] [debile-master] 15/126: ok, time to do some real work.
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:56:06 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch scan-build-html
in repository debile-master.
commit f6531a87c347ab4ce8b74eaaef00c1c42ba583fb
Author: Paul Tagliamonte <tag at pault.ag>
Date: Sat May 25 23:28:37 2013 -0400
ok, time to do some real work.
---
eg/config.json | 9 ++-
lucy/__init__.py | 3 +-
lucy/archive.py | 88 --------------------------
lucy/changes.py | 12 ++++
lucy/core.py | 4 +-
lucy/models/binary.py | 4 +-
lucy/models/job.py | 8 ++-
lucy/server.py | 130 ---------------------------------------
lucy/tests/test_lucy_package.py | 18 +++---
setup.py | 8 +--
10 files changed, 45 insertions(+), 239 deletions(-)
diff --git a/eg/config.json b/eg/config.json
index 4f10188..4d00c40 100644
--- a/eg/config.json
+++ b/eg/config.json
@@ -2,6 +2,9 @@
"configs": [
{
"_id": "default",
+ "arches": [
+ "amd64"
+ ],
"incoming": "/srv/lucy.pault.ag/incoming",
"job_classes": {
"binary": [
@@ -25,12 +28,14 @@
{
"_id": "leliel",
"auth": "password",
- "owner": "paultag"
+ "owner": "paultag",
+ "gpg": "A998491ADCCB93C7A73A27403D3FDC7A47036CF7"
},
{
"_id": "loki",
"auth": "password",
- "owner": "paultag"
+ "owner": "paultag",
+ "gpg": null
}
],
"users": [
diff --git a/lucy/__init__.py b/lucy/__init__.py
index e00d649..8535b39 100644
--- a/lucy/__init__.py
+++ b/lucy/__init__.py
@@ -3,7 +3,8 @@ __version__ = "0.0.1"
from lucy.models.machine import Machine # NOQA
-from lucy.models.package import Package # NOQA
+from lucy.models.source import Source # NOQA
+from lucy.models.binary import Binary # NOQA
from lucy.models.config import Config # NOQA
from lucy.models.user import User # NOQA
from lucy.models.job import Job # NOQA
diff --git a/lucy/archive.py b/lucy/archive.py
deleted file mode 100644
index a7bddad..0000000
--- a/lucy/archive.py
+++ /dev/null
@@ -1,88 +0,0 @@
-from lucy.models.package import Package
-from lucy.models.user import User
-from lucy.models.job import Job
-
-from lucy.changes import parse_changes_file, ChangesFileException
-from lucy.utils import cd, fglob
-
-import os
-
-
-def reject(changes, config):
- print("Rejecting: {source}/{version}".format(
- source=changes['source'],
- version=changes['version']))
-
- for f in changes.get_files() + [changes.get_filename()]:
- print(" Removing: %s" % (f))
- os.unlink(f)
-
-
-def accept(changes, config, pool):
- print("Accepting: {source}/{version}".format(
- source=changes['source'],
- version=changes['version']))
-
- name = changes.get_package_name()
- version = changes['version']
- key = changes.validate_signature()
-
- try:
- who = User.get_by_key(key)
- except KeyError:
- # no such user
- return reject(changes, config)
-
- obj = Package(source=name,
- version=version,
- owner=who['_id'])
- obj.save()
- path = add_to_pool(pool, obj, changes)
- obj['path'] = path
- obj.save()
- os.unlink(changes.get_filename())
-
- for job in config['job_classes']:
- print(" -> New job: %s" % (job))
- Job(type=job, package=obj['_id']).save()
-
-
-def uuid_to_path(uuid, base=None):
- nodes = uuid.split("-")
- ids = os.path.join(*nodes)
- path = os.path.join(*list(nodes[-1])[:4])
- path = os.path.join(ids, path)
- return path
-
-
-def add_to_pool(pool, package, changes):
- uid = package['_id']
- ret = uuid_to_path(uid, base=pool)
-
- path = os.path.join(pool, ret)
-
- os.makedirs(path)
- for entry in changes.get_files():
- bn = os.path.basename(entry)
- dest = os.path.join(path, bn)
- os.rename(entry, dest)
-
- return ret
-
-
-def process(config):
- pool = config['pool']
- incoming = config['incoming']
-
- with cd(incoming):
- def _pc(x):
- obj = parse_changes_file(x, directory=incoming)
- try:
- obj.validate(check_signature=True)
- except ChangesFileException:
- reject(obj, config)
- return None
- return obj
-
- for x in filter(lambda x: x is not None, fglob("*changes", _pc)):
- accept(x, config, pool)
diff --git a/lucy/changes.py b/lucy/changes.py
index 2ed92ed..6abe1fe 100644
--- a/lucy/changes.py
+++ b/lucy/changes.py
@@ -111,6 +111,18 @@ class Changes(object):
if sys.version_info[0] >= 3:
self.is_python3 = True
+ def is_source_only_upload(self):
+ for f in self.get_files():
+ if f.endswith(".deb") or f.endswith(".udeb"):
+ return False
+ return True
+
+ def is_binry_upload(self):
+ for f in self.get_files():
+ if not (f.endswith(".deb") or f.endswith(".udeb")):
+ return False
+ return True
+
def get_filename(self):
"""
Returns the filename from which the changes file was generated from.
diff --git a/lucy/core.py b/lucy/core.py
index da12f28..48be1bf 100644
--- a/lucy/core.py
+++ b/lucy/core.py
@@ -6,11 +6,11 @@ db = connection.lucy
config = None
-def get_config():
+def get_config(name='default'):
global config
if config:
return config
from lucy.models.config import Config
- config = Config.load('default')
+ config = Config.load(name)
return config
diff --git a/lucy/models/binary.py b/lucy/models/binary.py
index 555b55e..a4cbd8e 100644
--- a/lucy/models/binary.py
+++ b/lucy/models/binary.py
@@ -5,8 +5,10 @@ from lucy.models.user import User
class Binary(LucyObject):
_type = 'binaries'
- def __init__(self, source, arch, suite, **kwargs):
+ def __init__(self, source, arch, suite, binaries, builder, **kwargs):
super(Binary, self).__init__(source=source,
arch=arch,
suite=suite,
+ builder=builder,
+ binaries=binaries,
**kwargs)
diff --git a/lucy/models/job.py b/lucy/models/job.py
index 9a4462b..d1bd484 100644
--- a/lucy/models/job.py
+++ b/lucy/models/job.py
@@ -1,4 +1,5 @@
-from lucy.models.package import Package
+from lucy.models.source import Source
+from lucy.models.binary import Binary
from lucy.models.machine import Machine
from lucy.models import LucyObject
@@ -9,7 +10,10 @@ class Job(LucyObject):
def __init__(self, type, package, builder=None, finished_at=None,
assigned_at=None, **kwargs):
- package = Package.load(package)['_id']
+ try:
+ package = Source.load(package)['_id']
+ except KeyError:
+ package = Binary.load(package)['_id']
if builder:
builder = Machine.load(builder)['_id']
diff --git a/lucy/server.py b/lucy/server.py
deleted file mode 100644
index 14f732c..0000000
--- a/lucy/server.py
+++ /dev/null
@@ -1,130 +0,0 @@
-from lucy.models.package import Package
-from lucy.models.machine import Machine
-from lucy.models.report import Report
-from lucy.models.job import Job
-from lucy.core import get_config
-
-from xmlrpc.server import SimpleXMLRPCServer
-from xmlrpc.server import SimpleXMLRPCRequestHandler
-
-from base64 import b64decode
-import datetime as dt
-import socketserver
-import threading
-
-NAMESPACE = threading.local()
-
-
-def get_builder_id():
- return NAMESPACE.machine['_id']
-
-
-class LucyAuthMixIn(SimpleXMLRPCRequestHandler):
- def authenticate(self):
- (basic, _, encoded) = self.headers.get('Authorization').partition(' ')
- if basic.lower() != 'basic':
- self.send_error(401, 'Only allowed basic type thing')
-
- machine, password = b64decode(encoded.encode()).decode().split(":", 1)
- machine = Machine.load(machine)
- if machine.auth(password):
- NAMESPACE.machine = machine
- return True
- NAMESPACE.machine = None
- return False
-
- def parse_request(self, *args):
- if super(LucyAuthMixIn, self).parse_request(*args):
- if self.authenticate():
- return True
- else:
- self.send_error(401, 'Authentication failed')
- return False
-
-
-class AsyncXMLRPCServer(socketserver.ThreadingMixIn, LucyAuthMixIn):
- pass
-
-
-class LucyInterface(object):
- def version(self):
- return "1.0"
-
- def identify(self):
- return get_builder_id()
-
- def get_dsc_url(self, package):
- config = get_config()
- package = Package.load(package)
- url = "{public}/{path}/{source}_{version}.dsc".format(
- public=config['public'],
- path=package['path'],
- source=package['source'],
- version=package['version'])
- return url
-
- def get_next_job(self, job_type):
- ajobs = list(Job.assigned_jobs(get_builder_id()))
- if ajobs != []:
- return dict(ajobs[0])
-
- try:
- job = Job.next_job(type=job_type)
- except KeyError:
- return None
-
- job['builder'] = get_builder_id()
- job['assigned_at'] = dt.datetime.utcnow()
- job.save()
- return dict(job)
-
- def submit_report(self, job, report, log, failed):
- job = Job.load(job)
- if job.is_finished():
- raise ValueError("Job is finished")
-
- builder = job.get_builder()
- builder = builder['_id'] if builder else None
-
- if builder != get_builder_id():
- raise ValueError("Machine isn't assigned.")
-
- r = Report(builder=get_builder_id(),
- package=job['package'],
- job=job['_id'],
- failed=failed,
- report=report,
- log=log)
- return r.save()
-
- def close_job(self, job):
- job = Job.load(job)
- if job.is_finished():
- raise ValueError("job is already closed")
-
- builder = job.get_builder()
- builder = builder['_id'] if builder else None
-
- if builder != get_builder_id():
- raise ValueError("Machine isn't assigned.")
-
- job['finished_at'] = dt.datetime.utcnow()
- return job.save()
-
-
-def serve(server, port):
- print("Serving on `{server}' on port `{port}'".format(**locals()))
- server = SimpleXMLRPCServer((server, port),
- requestHandler=AsyncXMLRPCServer,
- allow_none=True)
- server.register_introspection_functions()
- server.register_instance(LucyInterface())
- server.serve_forever()
-
-
-def main():
- serve("localhost", 20017)
-
-
-if __name__ == "__main__":
- main()
diff --git a/lucy/tests/test_lucy_package.py b/lucy/tests/test_lucy_package.py
index 77a53e2..47d5d08 100644
--- a/lucy/tests/test_lucy_package.py
+++ b/lucy/tests/test_lucy_package.py
@@ -1,26 +1,26 @@
-from lucy.models.package import Package
+from lucy.models.source import Source
-def test_basic_package():
- """ Test that package routines works """
+def test_basic_source():
+ """ Test that source routines works """
- p = Package(source='fluxbox',
+ p = Source(source='fluxbox',
version='1.0',
owner=None)
p.save()
- p = Package(source='fluxbox',
+ p = Source(source='fluxbox',
version='2.0',
owner=None)
p.save()
- p = Package(source='frucksbox',
+ p = Source(source='frucksbox',
version='2.0',
owner=None)
x = p.save()
- assert len(list(Package.get_all_versions("fluxbox"))) == 2
- assert len(list(Package.get_all_versions("frucksbox"))) == 1
+ assert len(list(Source.get_all_versions("fluxbox"))) == 2
+ assert len(list(Source.get_all_versions("frucksbox"))) == 1
- obj = Package.load(x)
+ obj = Source.load(x)
assert obj['version'] == '2.0'
diff --git a/setup.py b/setup.py
index 9116983..993a248 100755
--- a/setup.py
+++ b/setup.py
@@ -20,10 +20,10 @@ setup(
platforms=['any'],
entry_points={
'console_scripts': [
- 'lucy-nuke = lucy.cli.nuke:main',
- 'lucy-process-incoming = lucy.cli.incoming:main',
- 'lucy-init = lucy.cli.init:main',
- 'lucyd = lucy.server:main',
+# 'lucy-nuke = lucy.cli.nuke:main',
+# 'lucy-process-incoming = lucy.cli.incoming:main',
+# 'lucy-init = lucy.cli.init:main',
+# 'lucyd = lucy.server:main',
],
}
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git
More information about the Pkg-debile-commits
mailing list