diff options
author | Stanislav Ochotnicky <sochotnicky@gmail.com> | 2009-07-30 17:03:50 +0200 |
---|---|---|
committer | Stanislav Ochotnicky <sochotnicky@gmail.com> | 2009-07-31 10:51:27 +0200 |
commit | de2338a5a2166002dc61dc012c67c82baad1a373 (patch) | |
tree | 08c9bb66c8c4bcb85e28c346ebc2fba3d9ccc826 | |
parent | Added instruction to initialize data to INSTALL (diff) | |
download | collagen-de2338a5a2166002dc61dc012c67c82baad1a373.tar.gz collagen-de2338a5a2166002dc61dc012c67c82baad1a373.tar.bz2 collagen-de2338a5a2166002dc61dc012c67c82baad1a373.zip |
Started adding information to database
and fixed imports
-rw-r--r-- | src/matchbox/__init__.py | 44 |
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 |