aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/matchbox/__init__.py44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/matchbox/__init__.py b/src/matchbox/__init__.py
index 80b8f4f..c6d470b 100644
--- a/src/matchbox/__init__.py
+++ b/src/matchbox/__init__.py
@@ -9,8 +9,9 @@ import time
import portage
import random
-import db
-from db import DjangoDB
+import matchbox.db
+import matchbox.db.main.models as dbm
+from matchbox.db import DjangoDB
class MatchboxServer(object):
@@ -61,7 +62,7 @@ class MatchboxServer(object):
if type(command) is protocol.GetNextPackage:
print "returning next package to compile"
# TODO get real package from database with missing info
- repl = protocol.GetNextPackageReply(self._get_next_package(),None,None)
+ repl = protocol.GetNextPackageReply(self._get_next_package(), None, None)
print "name: %s" % repl.package_name
client_socket.sendall(pickle.dumps(repl))
@@ -73,6 +74,7 @@ class MatchboxServer(object):
sys.stdout = fout
print pi
sys.stdout = sys.__stdout__
+ self._db_add_package_info(pi, client_address)
fout.close()
# TODO
@@ -105,6 +107,42 @@ class MatchboxServer(object):
return "%s/%s" % (selcat,selpkg)
+ def _db_add_package_info(self, pi, tinderbox_address):
+ db = self.db
+
+ pcat, pname = portage.catsplit(pi.name)
+ pid = db.add_package(pname)
+ package = dbm.Package.objects.get(pk=pid)
+ cid = db.add_category(pcat)
+ category = dbm.PackageCategory.objects.get(pk=cid)
+
+ pvid = db.add_package_version(package.id, category.id, pi.version)
+ packageversion = dbm.PackageVersion.objects.get(pk=pvid)
+ packageversion.dependencies.clear()
+ #we will update deps after all package infos have been inserted
+
+ profileid = db.add_portage_profile(pi.profile)
+ profile = dbm.PortageProfile.objects.get(pk=profileid)
+ tid = db.add_tinderbox(tinderbox_address[0])
+ tinderbox = dbm.Tinderbox.objects.get(pk=tid)
+ useflag_ids = []
+ if not pi.use_flags:
+ pi.use_flags = []
+ for useflag in pi.use_flags:
+ useflag_ids.append(db.add_useflag(useflag))
+ ecode = 0
+ if pi.error:
+ ecode = pi.error
+ ppid = db.add_packageproperties(pvid, profile.id, tinderbox.id, ecode)
+
+ db.add_useflags_to_packageproperies(ppid, useflag_ids)
+
+ for key in pi.attachments.keys():
+ db.add_attachment(ppid, key, pi.attachments[key], 'text/plain')
+
+ db.add_contents_to_packageproperties(ppid, pi.content)
+
+
def __get_override_package(self):
try:
line = None