public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Magnus Granberg" <zorry@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] dev/zorry:master commit in: gobs/bin/, gobs/pym/
Date: Sun, 31 Jul 2011 13:43:28 +0000 (UTC)	[thread overview]
Message-ID: <082e83c77c4368bb1c63c2fdf7e07167cea6b435.zorry@gentoo> (raw)

commit:     082e83c77c4368bb1c63c2fdf7e07167cea6b435
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 31 13:43:09 2011 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Sun Jul 31 13:43:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=082e83c7

fix and clean code for gobs_updatedb

---
 gobs/bin/gobs_updatedb |    6 +++---
 gobs/pym/arch.py       |   25 +++++++++++++------------
 gobs/pym/categories.py |   26 +++++++++++++++-----------
 gobs/pym/old_cpv.py    |   29 ++++++++++++++++++-----------
 gobs/pym/package.py    |   18 +++++++-----------
 5 files changed, 56 insertions(+), 48 deletions(-)

diff --git a/gobs/bin/gobs_updatedb b/gobs/bin/gobs_updatedb
index a9c8e4a..36b26bd 100755
--- a/gobs/bin/gobs_updatedb
+++ b/gobs/bin/gobs_updatedb
@@ -28,7 +28,7 @@ from gobs.old_cpv import gobs_old_cpv
 from gobs.categories import gobs_categories
 import portage
 
-def init_portage_settings(CM, gobs_settings_dict):
+def init_portage_settings(gobs_settings_dict):
 	
 	""" Get the BASE Setup/Config for portage.settings
 	@type: module
@@ -101,8 +101,8 @@ def update_cpv_db(mysettings, gobs_settings_dict):
 def main():
 	# Main
 	# Init settings for the default config
-	mysettings =  init_portage_settings(CM,gobs_settings_dict)
-	init_arch = gobs_arch(CM)
+	mysettings =  init_portage_settings(gobs_settings_dict)
+	init_arch = gobs_arch()
 	init_arch.update_arch_db()
 	# Update the cpv db
 	update_cpv_db(mysettings, gobs_settings_dict)

diff --git a/gobs/pym/arch.py b/gobs/pym/arch.py
index 7e11041..1a26083 100644
--- a/gobs/pym/arch.py
+++ b/gobs/pym/arch.py
@@ -1,24 +1,25 @@
 import portage
+from gobs.readconf import get_conf_settings
+reader=get_conf_settings()
+gobs_settings_dict=reader.read_gobs_settings_all()
+# make a CM
+from gobs.ConnectionManager import connectionManager
+CM=connectionManager(gobs_settings_dict)
+#selectively import the pgsql/mysql querys
+if CM.getName()=='pgsql':
+	from gobs.pgsql import *
 
 class gobs_arch(object):
 	
-	def __init__(self, CM):
-		#selective import the pgsql/mysql queries
-		if CM.getName() is 'pgsql':
-			from gobs.pgsql import *
-		self._CM = CM
-		self._conn = CM.getConnection()
-
-	def __del__(self):
-		self._CM.putConnection(self._conn)
-
 	def update_arch_db(self):
+		conn = CM.getConnection()
 		# FIXME: check for new keyword
 		# Add arch db (keywords)
-		if get_arch_db(self._conn) is None:
+		if get_arch_db(conn) is None:
 			arch_list =  portage.archlist
 			for arch in arch_list:
 				if arch[0] not in ["~","-"]:
 					arch_list.append("-" + arch)
 					arch_list.append("-*")
-					add_new_arch_db(self._conn,arch_list)
\ No newline at end of file
+					add_new_arch_db(conn,arch_list)
+		CM.putConnection(conn)
\ No newline at end of file

diff --git a/gobs/pym/categories.py b/gobs/pym/categories.py
index f9f4367..dae1207 100644
--- a/gobs/pym/categories.py
+++ b/gobs/pym/categories.py
@@ -1,26 +1,30 @@
 #from gobs.text import gobs_text
 from gobs.text import get_file_text
 import portage
+from gobs.readconf import get_conf_settings
+reader=get_conf_settings()
+gobs_settings_dict=reader.read_gobs_settings_all()
+# make a CM
+from gobs.ConnectionManager import connectionManager
+CM=connectionManager(gobs_settings_dict)
+#selectively import the pgsql/mysql querys
+if CM.getName()=='pgsql':
+	from gobs.pgsql import *
 
 class gobs_categories(object):
 	
-	def __init__(self, CM, mysettings):
-		self._CM = CM
-		self._conn=CM.getConnection()
+	def __init__(self, mysettings):
 		self._mysettings = mysettings
-		if CM.getName() is 'pgsql':
-		  from gobs.pgsql import *
-	
-	def __del__(self):
-	 self._CM.putConnection(self._conn)
 	  
 	def update_categories_db(self, categories):
+		conn=CM.getConnection()
 		# Update categories_meta in the db
 		categories_dir = self._mysettings['PORTDIR'] + "/" + categories + "/"
 		categories_metadata_xml_checksum_tree = portage.checksum.sha256hash(categories_dir + "metadata.xml")[0]
 		categories_metadata_xml_text_tree = get_file_text(categories_dir + "metadata.xml")
-		categories_metadata_xml_checksum_db = get_categories_checksum_db(self._conn, categories)
+		categories_metadata_xml_checksum_db = get_categories_checksum_db(conn, categories)
 		if categories_metadata_xml_checksum_db is None:
-			add_new_categories_meta_sql(self._conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree)
+			add_new_categories_meta_sql(conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree)
 		elif categories_metadata_xml_checksum_db != categories_metadata_xml_checksum_tree:
-			update_categories_meta_sql(self._conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree)
+			update_categories_meta_sql(conn,categories, categories_metadata_xml_checksum_tree, categories_metadata_xml_text_tree)
+		CM.putConnection(conn)

diff --git a/gobs/pym/old_cpv.py b/gobs/pym/old_cpv.py
index c577033..4923bf7 100644
--- a/gobs/pym/old_cpv.py
+++ b/gobs/pym/old_cpv.py
@@ -1,15 +1,22 @@
 from __future__ import print_function
+from gobs.readconf import get_conf_settings
+reader=get_conf_settings()
+gobs_settings_dict=reader.read_gobs_settings_all()
+# make a CM
+from gobs.ConnectionManager import connectionManager
+CM=connectionManager(gobs_settings_dict)
+#selectively import the pgsql/mysql querys
+if CM.getName()=='pgsql':
+	from gobs.pgsql import *
+
 class gobs_old_cpv(object):
 	
-	def __init__(self, CM, myportdb, mysettings):
-		self._CM = CM
+	def __init__(self, myportdb, mysettings):
 		self._mysettings = mysettings
 		self._myportdb = myportdb
-		if CM.getName() is 'pgsql':
-		  from gobs.pgsql import *
 
 	def mark_old_ebuild_db(self, categories, package, package_id):
-		conn=self._CM.getConnection()
+		conn=CM.getConnection()
 		ebuild_list_tree = sorted(self._myportdb.cp_list((categories + "/" + package), use_cache=1, mytree=None))
 		# Get ebuild list on categories, package in the db
 		ebuild_list_db = cp_list_db(conn,package_id)
@@ -24,7 +31,7 @@ class gobs_old_cpv(object):
 			if  old_ebuild_list != []:
 				for old_ebuild in old_ebuild_list:
 					print("O", categories + "/" + package + "-" + old_ebuild[0])
-					self.dbquerys.add_old_ebuild(conn,package_id, old_ebuild_list)
+					add_old_ebuild(conn,package_id, old_ebuild_list)
 		# Check if we have older no activ ebuilds then 60 days
 		ebuild_old_list_db = cp_list_old_db(conn,package_id)
 		# Delete older ebuilds in the db
@@ -32,10 +39,10 @@ class gobs_old_cpv(object):
 			for del_ebuild_old in ebuild_old_list_db:
 				print("D", categories + "/" + package + "-" + del_ebuild_old[1])
 			del_old_ebuild(conn,ebuild_old_list_db)
-		self._CM.putConnection(conn)
+		CM.putConnection(conn)
 
 	def mark_old_package_db(self, package_id_list_tree):
-		conn=self._CM.getConnection()
+		conn=CM.getConnection()
 		# Get categories/package list from db
 		package_list_db = cp_all_db(conn)
 		old_package_id_list = []
@@ -59,10 +66,10 @@ class gobs_old_cpv(object):
 				element = get_cp_from_package_id(conn,i)
 				print("D", element)
 			del_old_package(conn,del_package_id_old_list)
-		self._CM.putConnection(conn)
+		CM.putConnection(conn)
 		
 	def mark_old_categories_db(self):
-		conn=self._CM.getConnection()
+		conn=CM.getConnection()
 		# Get categories list from the tree and db
 		categories_list_tree = self._mysettings.categories
 		categories_list_db =get_categories_db(conn)
@@ -79,4 +86,4 @@ class gobs_old_cpv(object):
 			for real_old_categories in categories_old_list:
 				del_old_categories(conn,real_old_categoriess)
 				print("D", real_old_categories)
-		self._CM.putConnection(conn)
\ No newline at end of file
+		CM.putConnection(conn)
\ No newline at end of file

diff --git a/gobs/pym/package.py b/gobs/pym/package.py
index f240e4e..8d94936 100644
--- a/gobs/pym/package.py
+++ b/gobs/pym/package.py
@@ -18,7 +18,7 @@ if CM.getName()=='pgsql':
 
 class gobs_package(object):
 
-	def __init__(self, mysettings, CM, myportdb, gobs_settings_dict):
+	def __init__(self, mysettings, myportdb, gobs_settings_dict):
 		self._mysettings = mysettings
 		self._gobs_settings_dict = gobs_settings_dict
 		self._myportdb = myportdb
@@ -41,16 +41,12 @@ class gobs_package(object):
 			# Change config/setup
 			mysettings_setup = self.change_config(config_id)
 			myportdb_setup = portage.portdbapi(mysettings=mysettings_setup)
-			# Get cpv from portage with the config
-			ebuild_match_list = myportdb_setup.match(categories + "/" + package, use_cache=1)
-			latest_ebuild = ""
+			# Get latest cpv from portage with the config
+			latest_ebuild = myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package)
 			latest_ebuild_version = unicode("")
 			# Check if could get cpv from portage
-			# and get the lastes ebuild on that config/setup
-			if ebuild_match_list != []:
-				for ebuild_match_line in ebuild_match_list:
-					latest_ebuild = ebuild_match_line
-					# Get the version of cpv
+			if latest_ebuild != "":
+				# Get the version of cpv
 				latest_ebuild_version = portage.versions.cpv_getversion(latest_ebuild)
 				# Get the iuse and use flags for that config/setup
 				init_useflags = gobs_use_flags(mysettings_setup, myportdb_setup, latest_ebuild)
@@ -268,7 +264,7 @@ class gobs_package(object):
 			add_new_metadata(conn,metadataDict)
 			# Get the text in Manifest and update it
 			get_manifest_text = get_file_text(pkgdir + "/Manifest")
-			self._dbquerys.update_manifest_sql(conn,package_id, get_manifest_text, manifest_checksum_tree)
+			update_manifest_sql(conn,package_id, get_manifest_text, manifest_checksum_tree)
 			# Add any qa and repoman erros to buildlog
 			qa_error = []
 			init_manifest =  gobs_manifest(self._mysettings, pkgdir)
@@ -280,7 +276,7 @@ class gobs_package(object):
 			# Add the ebuild to the buildqueru table if needed
 			self.add_new_ebuild_buildquery_db(ebuild_id_list, packageDict, config_cpv_listDict)
 			# Mark or remove any old ebuilds
-			init_old_cpv = gobs_old_cpv(self._CM, self._myportdb, self._mysettings)
+			init_old_cpv = gobs_old_cpv(self._myportdb, self._mysettings)
 			init_old_cpv.mark_old_ebuild_db(categories, package, package_id)
 		CM.putConnection(conn)
 



             reply	other threads:[~2011-07-31 14:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-31 13:43 Magnus Granberg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-12-27 23:09 [gentoo-commits] dev/zorry:master commit in: gobs/bin/, gobs/pym/ Magnus Granberg
2012-12-23 17:09 Magnus Granberg
2012-12-22  2:59 Magnus Granberg
2012-12-21  1:44 Magnus Granberg
2012-12-19  2:11 Magnus Granberg
2012-12-07 14:07 Magnus Granberg
2012-12-05 23:56 Magnus Granberg
2012-11-29 22:22 Magnus Granberg
2012-07-17  0:07 Magnus Granberg
2012-06-26 22:10 Magnus Granberg
2012-05-13 17:59 Magnus Granberg
2012-05-09 23:12 Magnus Granberg
2012-05-06 10:41 Magnus Granberg
2012-05-04 22:32 Magnus Granberg
2012-05-01  1:12 Magnus Granberg
2012-04-30 12:08 Magnus Granberg
2012-04-29 14:43 Magnus Granberg
2012-04-29 13:16 Magnus Granberg
2012-04-29 13:13 Magnus Granberg
2012-04-28 16:01 Magnus Granberg
2012-04-27 22:22 Magnus Granberg
2012-04-27 20:59 Magnus Granberg
2011-11-01 21:14 Magnus Granberg
2011-10-29  0:14 Magnus Granberg
2011-09-28 10:53 Magnus Granberg
2011-09-28  0:33 Magnus Granberg
2011-09-26 23:25 Magnus Granberg
2011-08-31  1:46 Magnus Granberg
2011-08-30 23:02 Magnus Granberg
2011-04-24 22:13 Magnus Granberg
2011-04-23 14:23 Magnus Granberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=082e83c77c4368bb1c63c2fdf7e07167cea6b435.zorry@gentoo \
    --to=zorry@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox