public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-01-29  6:32 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-01-29  6:32 UTC (permalink / raw
  To: gentoo-commits

commit:     abed8568369920c035f89d87e68f4e324099c61e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 29 06:28:24 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Jan 29 06:28:24 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=abed8568

Update the return info to match expectations

---
 pym/portage/sync/modules/cvs/cvs.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index c52627c..cd376b6 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -34,7 +34,7 @@ class CVSSync(object):
 		if not os.path.exists("/usr/bin/cvs"):
 			print("!!! /usr/bin/cvs does not exist, so CVS support is disabled.")
 			print("!!! Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM)
-			return os.EX_UNAVAILABLE
+			return os.EX_UNAVAILABLE, False
 
 		if kwargs:
 			options = kwargs.get('options', {})
@@ -54,7 +54,7 @@ class CVSSync(object):
 					sys.stderr.write(
 						"!!! existing '%s' directory; exiting.\n" % repo.location)
 					exitcode = 1
-					return self.post_sync(repo.location, exitcode)
+					return (exitcode, False)
 				del e
 			if portage.process.spawn_bash(
 					"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
@@ -73,8 +73,5 @@ class CVSSync(object):
 			if exitcode != os.EX_OK:
 				writemsg_level("!!! cvs update error; exiting.\n",
 					noiselevel=-1, level=logging.ERROR)
-		return self.post_sync(repo.location, exitcode)
+		return (exitcode, False)
 
-
-	def post_sync(self, location, exitcode):
-		return location, exitcode, False


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-02-11 17:28 Chris Reffett
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Reffett @ 2014-02-11 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     d7ed98d9e4cd3bea7f65c7ac5d84d082ab906b26
Author:     Chris Reffett <creffett <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 17:27:27 2014 +0000
Commit:     Chris Reffett <creffett <AT> gentoo <DOT> org>
CommitDate: Tue Feb 11 17:27:27 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d7ed98d9

Bring CVS module up to current module spec

Add exists(), new(), _sync() as in the git and rsync classes. Clean up
output style to use logger and writemsg_level instead of straight print
statements

---
 pym/portage/sync/modules/cvs/__init__.py |  21 ++++--
 pym/portage/sync/modules/cvs/cvs.py      | 119 ++++++++++++++++++++++---------
 2 files changed, 101 insertions(+), 39 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/__init__.py b/pym/portage/sync/modules/cvs/__init__.py
index a24eea9..7e786c0 100644
--- a/pym/portage/sync/modules/cvs/__init__.py
+++ b/pym/portage/sync/modules/cvs/__init__.py
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 """CVS plug-in module for portage.
-   Performs a git pull on the repo
+Performs a cvs up on repositories
 """
 
 
@@ -14,8 +14,21 @@ module_spec = {
 			'name': "cvs",
 			'class': "CVSSync",
 			'description': __doc__,
-			'functions': ['sync',],
-			'func_desc': {'sync': 'Performs a cvs up on the repo'}
-			}
+			'functions': ['sync', 'new', 'exists'],
+			'func_desc': {
+				'sync': 'Performs a cvs up on the repository',
+				'new': 'Creates the new repository at the specified location',
+				'exists': 'Returns a boolean of whether the specified dir ' +
+					'exists and is a valid CVS repository',
+			},
+			'func_parameters': {
+				'kwargs': {
+					'type': dict,
+					'description': 'Standard python **kwargs parameter format' +
+						'Please refer to the sync modules specs at ' +
+						'"https://wiki.gentoo.org:Project:Portage" for details',
+				},
+			},
 		}
 	}
+}

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index cd376b6..c71f8e5 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -13,7 +13,7 @@ from portage.util import writemsg_level
 class CVSSync(object):
 	'''CVS sync module'''
 
-	short_desc = "Perform sync operations on rsync based repositories"
+	short_desc = "Perform sync operations on CVS repositories"
 
 	def name():
 		return "CVSSync"
@@ -26,52 +26,101 @@ class CVSSync(object):
 
 	def __init__(self):
 		self.settings = None
+		self.options = None
+		self.logger = None
+		self.xterm_titles = None
+		self.has_cvs = True
+		if portage.process.find_binary("cvs") is None:
+			msg = "Command not found: cvs"
+			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
+			for l in msg:
+				writemsg_level("!!! %s\n" % l,
+					level=logging.ERROR, noiselevel=-1)
+			self.has_cvs = False
+
+	def _kwargs(self, **kwargs):
+		self.options = kwargs.get('options', {})
+		self.repo = self.options.get('repo', None)
+		self.logger = self.options.get('logger', None)
+		self.xterm_titles = self.options.get('xterm_titles', None)
+
+
+	def exists(self, **kwargs):
+		if kwargs:
+			self._kwargs(kwargs)
+		elif not self.repo:
+			return False
+		spawn_kwargs = self.options.get('spawn_kwargs', None)
+
+		if not os.path.exists(os.path.join(repo.location, "CVS")):
+			return False
+		return True
 
 
 	def sync(self, **kwargs):
-		'''repo.sync_type == "cvs":'''
+		if kwargs:
+			self._kwargs(kwargs)
 
-		if not os.path.exists("/usr/bin/cvs"):
-			print("!!! /usr/bin/cvs does not exist, so CVS support is disabled.")
-			print("!!! Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM)
-			return os.EX_UNAVAILABLE, False
+		if not self.has_cvs:
+			return (1, False)
 
+		if not self.exists():
+			return self.new()
+		return self.sync()
+
+
+	def new(self, **kwargs):
 		if kwargs:
-			options = kwargs.get('options', {})
-			repo = options.get('repo', None)
-			spawn_kwargs = options.get('spawn_kwargs', None)
+			self._kwargs(kwargs)
+		#initial checkout
+		msg = ">>> Starting initial cvs checkout with %s..." % self.repo.sync_uri
+		self.logger(self.xterm_titles, msg)
+		writemsg_level(msg + "\n")
+		try:
+			os.rmdir(self.repo.location)
+		except OSError as e:
+			if e.errno != errno.ENOENT:
+				msg = "!!! existing '%s' directory; exiting." % self.repo.location
+				self.logger(self.xterm_titles, msg)
+				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
+				return (1, False)
+			del e
+		if portage.process.spawn_bash(
+			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
+			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
+				portage._shell_quote(os.path.basename(self.repo.location)),
+				portage._shell_quote(self.repo.sync_cvs_self.repo)),
+				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+			msg = "!!! cvs checkout error; exiting."
+			self.logger(self.xterm_titles, msg)
+			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
+			return (1, False)
+		return (0, False)
+
+	def _sync(self):
+		"""
+		Internal function to sync an existing CVS repository
+
+		@return: tuple of return code (0=success), whether the cache
+			needs to be updated
+		@rtype: (int, bool)
+		"""
+
+		spawn_kwargs = options.get('spawn_kwargs', None)
+		cvs_root = self.repo.sync_uri
 
-		cvs_root = repo.sync_uri
 		if cvs_root.startswith("cvs://"):
 			cvs_root = cvs_root[6:]
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			#initial checkout
-			print(">>> Starting initial cvs checkout with "+repo.sync_uri+"...")
-			try:
-				os.rmdir(repo.location)
-			except OSError as e:
-				if e.errno != errno.ENOENT:
-					sys.stderr.write(
-						"!!! existing '%s' directory; exiting.\n" % repo.location)
-					exitcode = 1
-					return (exitcode, False)
-				del e
-			if portage.process.spawn_bash(
-					"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
-					(portage._shell_quote(os.path.dirname(repo.location)), portage._shell_quote(cvs_root),
-					portage._shell_quote(os.path.basename(repo.location)), portage._shell_quote(repo.sync_cvs_repo)),
-					**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
-				print("!!! cvs checkout error; exiting.")
-				exitcode = 1
-		else:
 			#cvs update
-			print(">>> Starting cvs update with "+repo.sync_uri+"...")
+			msg = ">>> Starting cvs update with %s..." % self.repo.sync_uri
+			self.logger(self.xterm_titles, msg)
+			writemsg_level(msg + "\n")
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
-				(portage._shell_quote(repo.location),),
+				(portage._shell_quote(self.repo.location),),
 				**portage._native_kwargs(spawn_kwargs))
 			if exitcode != os.EX_OK:
-				writemsg_level("!!! cvs update error; exiting.\n",
-					noiselevel=-1, level=logging.ERROR)
+				msg = "!!! cvs update error; exiting."
+				self.logger(self.xterm_titles, msg)
+				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 		return (exitcode, False)
-


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-03-14 16:23 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-03-14 16:23 UTC (permalink / raw
  To: gentoo-commits

commit:     ec7f025e6b9139bbbbbe67dbdd1c721112310d84
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Mar 14 16:18:39 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ec7f025e

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index e169dbb..9cc4d6a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
 	'''CVS sync module'''
 
 	short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
 		return "CVSSync"
 
 
-	def can_progressbar(self, func):
-		return False
-
-
 	def __init__(self):
-		self.settings = None
-		self.options = None
-		self.logger = None
-		self.xterm_titles = None
-		self.has_cvs = True
-		if portage.process.find_binary("cvs") is None:
-			msg = "Command not found: cvs"
-			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
-			for l in msg:
-				writemsg_level("!!! %s\n" % l,
-					level=logging.ERROR, noiselevel=-1)
-			self.has_cvs = False
-
-	def _kwargs(self, **kwargs):
-		self.options = kwargs.get('options', {})
-		self.repo = self.options.get('repo', None)
-		self.logger = self.options.get('logger', None)
-		self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-	def exists(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-		spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			return False
-		return True
-
-
-	def sync(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-
-		if not self.has_cvs:
-			return (1, False)
-
-		if not self.exists():
-			return self.new()
-		return self.sync()
+		SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
 	def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
 				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 				return (1, False)
 			del e
+		cvs_root = self.repo.sync_uri
 		if portage.process.spawn_bash(
 			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
 			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
 				portage._shell_quote(os.path.basename(self.repo.location)),
 				portage._shell_quote(self.repo.sync_cvs_self.repo)),
-				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+				**portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
 			msg = "!!! cvs checkout error; exiting."
 			self.logger(self.xterm_titles, msg)
 			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 			return (1, False)
 		return (0, False)
 
+
 	def _sync(self):
 		"""
 		Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
 		@rtype: (int, bool)
 		"""
 
-		spawn_kwargs = options.get('spawn_kwargs', None)
 		cvs_root = self.repo.sync_uri
 
 		if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
 				(portage._shell_quote(self.repo.location),),
-				**portage._native_kwargs(spawn_kwargs))
+				**portage._native_kwargs(self.spawn_kwargs))
 			if exitcode != os.EX_OK:
 				msg = "!!! cvs update error; exiting."
 				self.logger(self.xterm_titles, msg)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-04-22  2:36 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-04-22  2:36 UTC (permalink / raw
  To: gentoo-commits

commit:     384951033ef135cc1c2a660d400d171938fbedfe
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Mar 29 22:46:20 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=38495103

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index dadbf7b..52d5d9a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
 	'''CVS sync module'''
 
 	short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
 		return "CVSSync"
 
 
-	def can_progressbar(self, func):
-		return False
-
-
 	def __init__(self):
-		self.settings = None
-		self.options = None
-		self.logger = None
-		self.xterm_titles = None
-		self.has_cvs = True
-		if portage.process.find_binary("cvs") is None:
-			msg = "Command not found: cvs"
-			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
-			for l in msg:
-				writemsg_level("!!! %s\n" % l,
-					level=logging.ERROR, noiselevel=-1)
-			self.has_cvs = False
-
-	def _kwargs(self, **kwargs):
-		self.options = kwargs.get('options', {})
-		self.repo = self.options.get('repo', None)
-		self.logger = self.options.get('logger', None)
-		self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-	def exists(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-		spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			return False
-		return True
-
-
-	def sync(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-
-		if not self.has_cvs:
-			return (1, False)
-
-		if not self.exists():
-			return self.new()
-		return self.sync()
+		SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
 	def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
 				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 				return (1, False)
 			del e
+		cvs_root = self.repo.sync_uri
 		if portage.process.spawn_bash(
 			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
 			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
 				portage._shell_quote(os.path.basename(self.repo.location)),
 				portage._shell_quote(self.repo.sync_cvs_repo)),
-				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+				**portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
 			msg = "!!! cvs checkout error; exiting."
 			self.logger(self.xterm_titles, msg)
 			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 			return (1, False)
 		return (0, False)
 
+
 	def _sync(self):
 		"""
 		Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
 		@rtype: (int, bool)
 		"""
 
-		spawn_kwargs = options.get('spawn_kwargs', None)
 		cvs_root = self.repo.sync_uri
 
 		if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
 				(portage._shell_quote(self.repo.location),),
-				**portage._native_kwargs(spawn_kwargs))
+				**portage._native_kwargs(self.spawn_kwargs))
 			if exitcode != os.EX_OK:
 				msg = "!!! cvs update error; exiting."
 				self.logger(self.xterm_titles, msg)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-04-22  2:36 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-04-22  2:36 UTC (permalink / raw
  To: gentoo-commits

commit:     f371a7c65ebe5913952f63b97035ba3f096832c7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 30 09:44:15 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 30 09:44:15 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f371a7c6

Re-order the class definition for visibility

---
 pym/portage/sync/modules/cvs/__init__.py | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/__init__.py b/pym/portage/sync/modules/cvs/__init__.py
index 9452631..f38acc5 100644
--- a/pym/portage/sync/modules/cvs/__init__.py
+++ b/pym/portage/sync/modules/cvs/__init__.py
@@ -6,7 +6,23 @@ Performs a cvs up on repositories
 """
 
 
+from portage.localization import _
 from portage.sync.config_checks import CheckSyncConfig
+from portage.util import writemsg_level
+
+
+class CheckCVSConfig(CheckSyncConfig):
+
+	def __init__(self, logger):
+		CheckSyncConfig.__init__(self, logger)
+		self.checks.append('check_cvs_repo')
+
+
+	def check_cvs_repo(self):
+		if self.repo.sync_cvs_repo is None:
+			writemsg_level("!!! %s\n" %
+				_("Repository '%s' has sync-type=cvs, but is missing sync-cvs-repo attribute")
+				% self.repo.name, level=self.logger.ERROR, noiselevel=-1)
 
 
 module_spec = {
@@ -37,17 +53,3 @@ module_spec = {
 	}
 }
 
-
-class CheckCVSConfig(CheckSyncConfig):
-
-	def __init__(self, logger):
-		CheckSyncConfig.__init__(self, logger)
-		self.checks.append('check_cvs_repo')
-
-
-	def check_cvs_repo(self):
-		if self.repo.sync_cvs_repo is None:
-			writemsg_level("!!! %s\n" %
-				_("Repository '%s' has sync-type=cvs, but is missing sync-cvs-repo attribute")
-				% self.repo.name, level=self.logger.ERROR, noiselevel=-1)
-


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-04-22  2:36 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-04-22  2:36 UTC (permalink / raw
  To: gentoo-commits

commit:     14564aa7d433728336bbd6c8dbd352fcc8ab1cdf
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 30 08:54:48 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 30 08:54:48 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=14564aa7

Remove the redundant repo.sync_type check

---
 pym/portage/sync/modules/cvs/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/sync/modules/cvs/__init__.py b/pym/portage/sync/modules/cvs/__init__.py
index 9549aad..9452631 100644
--- a/pym/portage/sync/modules/cvs/__init__.py
+++ b/pym/portage/sync/modules/cvs/__init__.py
@@ -46,7 +46,7 @@ class CheckCVSConfig(CheckSyncConfig):
 
 
 	def check_cvs_repo(self):
-		if self.repo.sync_type == "cvs" and self.repo.sync_cvs_repo is None:
+		if self.repo.sync_cvs_repo is None:
 			writemsg_level("!!! %s\n" %
 				_("Repository '%s' has sync-type=cvs, but is missing sync-cvs-repo attribute")
 				% self.repo.name, level=self.logger.ERROR, noiselevel=-1)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-05-02 23:13 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-05-02 23:13 UTC (permalink / raw
  To: gentoo-commits

commit:     7fa105b7153c20d63acfd4250764adb86985e8e1
Author:     Chris Reffett <creffett <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 17:27:27 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Apr 30 07:38:46 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7fa105b7

Bring CVS module up to current module spec

Add exists(), new(), _sync() as in the git and rsync classes. Clean up
output style to use logger and writemsg_level instead of straight print
statements

---
 pym/portage/sync/modules/cvs/__init__.py |  19 +++--
 pym/portage/sync/modules/cvs/cvs.py      | 119 ++++++++++++++++++++++---------
 2 files changed, 99 insertions(+), 39 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/__init__.py b/pym/portage/sync/modules/cvs/__init__.py
index 56f6902..7e786c0 100644
--- a/pym/portage/sync/modules/cvs/__init__.py
+++ b/pym/portage/sync/modules/cvs/__init__.py
@@ -14,10 +14,21 @@ module_spec = {
 			'name': "cvs",
 			'class': "CVSSync",
 			'description': __doc__,
-			'functions': ['sync',],
+			'functions': ['sync', 'new', 'exists'],
 			'func_desc': {
-				'sync', 'Performs a cvs up on the repository',
-				}
-			}
+				'sync': 'Performs a cvs up on the repository',
+				'new': 'Creates the new repository at the specified location',
+				'exists': 'Returns a boolean of whether the specified dir ' +
+					'exists and is a valid CVS repository',
+			},
+			'func_parameters': {
+				'kwargs': {
+					'type': dict,
+					'description': 'Standard python **kwargs parameter format' +
+						'Please refer to the sync modules specs at ' +
+						'"https://wiki.gentoo.org:Project:Portage" for details',
+				},
+			},
 		}
 	}
+}

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index 69edac4..dadbf7b 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -13,7 +13,7 @@ from portage.util import writemsg_level
 class CVSSync(object):
 	'''CVS sync module'''
 
-	short_desc = "Perform sync operations on rsync based repositories"
+	short_desc = "Perform sync operations on CVS repositories"
 
 	@staticmethod
 	def name():
@@ -26,52 +26,101 @@ class CVSSync(object):
 
 	def __init__(self):
 		self.settings = None
+		self.options = None
+		self.logger = None
+		self.xterm_titles = None
+		self.has_cvs = True
+		if portage.process.find_binary("cvs") is None:
+			msg = "Command not found: cvs"
+			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
+			for l in msg:
+				writemsg_level("!!! %s\n" % l,
+					level=logging.ERROR, noiselevel=-1)
+			self.has_cvs = False
+
+	def _kwargs(self, **kwargs):
+		self.options = kwargs.get('options', {})
+		self.repo = self.options.get('repo', None)
+		self.logger = self.options.get('logger', None)
+		self.xterm_titles = self.options.get('xterm_titles', None)
+
+
+	def exists(self, **kwargs):
+		if kwargs:
+			self._kwargs(kwargs)
+		elif not self.repo:
+			return False
+		spawn_kwargs = self.options.get('spawn_kwargs', None)
+
+		if not os.path.exists(os.path.join(repo.location, "CVS")):
+			return False
+		return True
 
 
 	def sync(self, **kwargs):
-		'''repo.sync_type == "cvs":'''
+		if kwargs:
+			self._kwargs(kwargs)
 
-		if not os.path.exists("/usr/bin/cvs"):
-			print("!!! /usr/bin/cvs does not exist, so CVS support is disabled.")
-			print("!!! Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM)
-			return os.EX_UNAVAILABLE, False
+		if not self.has_cvs:
+			return (1, False)
 
+		if not self.exists():
+			return self.new()
+		return self.sync()
+
+
+	def new(self, **kwargs):
 		if kwargs:
-			options = kwargs.get('options', {})
-			repo = options.get('repo', None)
-			spawn_kwargs = options.get('spawn_kwargs', None)
+			self._kwargs(kwargs)
+		#initial checkout
+		msg = ">>> Starting initial cvs checkout with %s..." % self.repo.sync_uri
+		self.logger(self.xterm_titles, msg)
+		writemsg_level(msg + "\n")
+		try:
+			os.rmdir(self.repo.location)
+		except OSError as e:
+			if e.errno != errno.ENOENT:
+				msg = "!!! existing '%s' directory; exiting." % self.repo.location
+				self.logger(self.xterm_titles, msg)
+				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
+				return (1, False)
+			del e
+		if portage.process.spawn_bash(
+			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
+			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
+				portage._shell_quote(os.path.basename(self.repo.location)),
+				portage._shell_quote(self.repo.sync_cvs_repo)),
+				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+			msg = "!!! cvs checkout error; exiting."
+			self.logger(self.xterm_titles, msg)
+			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
+			return (1, False)
+		return (0, False)
+
+	def _sync(self):
+		"""
+		Internal function to sync an existing CVS repository
+
+		@return: tuple of return code (0=success), whether the cache
+			needs to be updated
+		@rtype: (int, bool)
+		"""
+
+		spawn_kwargs = options.get('spawn_kwargs', None)
+		cvs_root = self.repo.sync_uri
 
-		cvs_root = repo.sync_uri
 		if cvs_root.startswith("cvs://"):
 			cvs_root = cvs_root[6:]
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			#initial checkout
-			print(">>> Starting initial cvs checkout with "+repo.sync_uri+"...")
-			try:
-				os.rmdir(repo.location)
-			except OSError as e:
-				if e.errno != errno.ENOENT:
-					sys.stderr.write(
-						"!!! existing '%s' directory; exiting.\n" % repo.location)
-					exitcode = 1
-					return (exitcode, False)
-				del e
-			if portage.process.spawn_bash(
-					"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
-					(portage._shell_quote(os.path.dirname(repo.location)), portage._shell_quote(cvs_root),
-					portage._shell_quote(os.path.basename(repo.location)), portage._shell_quote(repo.sync_cvs_repo)),
-					**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
-				print("!!! cvs checkout error; exiting.")
-				exitcode = 1
-		else:
 			#cvs update
-			print(">>> Starting cvs update with "+repo.sync_uri+"...")
+			msg = ">>> Starting cvs update with %s..." % self.repo.sync_uri
+			self.logger(self.xterm_titles, msg)
+			writemsg_level(msg + "\n")
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
-				(portage._shell_quote(repo.location),),
+				(portage._shell_quote(self.repo.location),),
 				**portage._native_kwargs(spawn_kwargs))
 			if exitcode != os.EX_OK:
-				writemsg_level("!!! cvs update error; exiting.\n",
-					noiselevel=-1, level=logging.ERROR)
+				msg = "!!! cvs update error; exiting."
+				self.logger(self.xterm_titles, msg)
+				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 		return (exitcode, False)
-


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-05-02 23:13 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-05-02 23:13 UTC (permalink / raw
  To: gentoo-commits

commit:     4135c7482c4ab327291de32120b40295088ba9cf
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri May  2 23:09:16 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4135c748

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index dadbf7b..52d5d9a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
 	'''CVS sync module'''
 
 	short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
 		return "CVSSync"
 
 
-	def can_progressbar(self, func):
-		return False
-
-
 	def __init__(self):
-		self.settings = None
-		self.options = None
-		self.logger = None
-		self.xterm_titles = None
-		self.has_cvs = True
-		if portage.process.find_binary("cvs") is None:
-			msg = "Command not found: cvs"
-			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
-			for l in msg:
-				writemsg_level("!!! %s\n" % l,
-					level=logging.ERROR, noiselevel=-1)
-			self.has_cvs = False
-
-	def _kwargs(self, **kwargs):
-		self.options = kwargs.get('options', {})
-		self.repo = self.options.get('repo', None)
-		self.logger = self.options.get('logger', None)
-		self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-	def exists(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-		spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			return False
-		return True
-
-
-	def sync(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-
-		if not self.has_cvs:
-			return (1, False)
-
-		if not self.exists():
-			return self.new()
-		return self.sync()
+		SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
 	def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
 				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 				return (1, False)
 			del e
+		cvs_root = self.repo.sync_uri
 		if portage.process.spawn_bash(
 			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
 			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
 				portage._shell_quote(os.path.basename(self.repo.location)),
 				portage._shell_quote(self.repo.sync_cvs_repo)),
-				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+				**portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
 			msg = "!!! cvs checkout error; exiting."
 			self.logger(self.xterm_titles, msg)
 			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 			return (1, False)
 		return (0, False)
 
+
 	def _sync(self):
 		"""
 		Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
 		@rtype: (int, bool)
 		"""
 
-		spawn_kwargs = options.get('spawn_kwargs', None)
 		cvs_root = self.repo.sync_uri
 
 		if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
 				(portage._shell_quote(self.repo.location),),
-				**portage._native_kwargs(spawn_kwargs))
+				**portage._native_kwargs(self.spawn_kwargs))
 			if exitcode != os.EX_OK:
 				msg = "!!! cvs update error; exiting."
 				self.logger(self.xterm_titles, msg)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-06-16 15:46 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-06-16 15:46 UTC (permalink / raw
  To: gentoo-commits

commit:     1a483c5918ab54b6453dd1b88af1dbfc238434fa
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 15:36:56 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1a483c59

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index dadbf7b..52d5d9a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
 	'''CVS sync module'''
 
 	short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
 		return "CVSSync"
 
 
-	def can_progressbar(self, func):
-		return False
-
-
 	def __init__(self):
-		self.settings = None
-		self.options = None
-		self.logger = None
-		self.xterm_titles = None
-		self.has_cvs = True
-		if portage.process.find_binary("cvs") is None:
-			msg = "Command not found: cvs"
-			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
-			for l in msg:
-				writemsg_level("!!! %s\n" % l,
-					level=logging.ERROR, noiselevel=-1)
-			self.has_cvs = False
-
-	def _kwargs(self, **kwargs):
-		self.options = kwargs.get('options', {})
-		self.repo = self.options.get('repo', None)
-		self.logger = self.options.get('logger', None)
-		self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-	def exists(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-		spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			return False
-		return True
-
-
-	def sync(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-
-		if not self.has_cvs:
-			return (1, False)
-
-		if not self.exists():
-			return self.new()
-		return self.sync()
+		SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
 	def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
 				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 				return (1, False)
 			del e
+		cvs_root = self.repo.sync_uri
 		if portage.process.spawn_bash(
 			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
 			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
 				portage._shell_quote(os.path.basename(self.repo.location)),
 				portage._shell_quote(self.repo.sync_cvs_repo)),
-				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+				**portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
 			msg = "!!! cvs checkout error; exiting."
 			self.logger(self.xterm_titles, msg)
 			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 			return (1, False)
 		return (0, False)
 
+
 	def _sync(self):
 		"""
 		Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
 		@rtype: (int, bool)
 		"""
 
-		spawn_kwargs = options.get('spawn_kwargs', None)
 		cvs_root = self.repo.sync_uri
 
 		if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
 				(portage._shell_quote(self.repo.location),),
-				**portage._native_kwargs(spawn_kwargs))
+				**portage._native_kwargs(self.spawn_kwargs))
 			if exitcode != os.EX_OK:
 				msg = "!!! cvs update error; exiting."
 				self.logger(self.xterm_titles, msg)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-06-16 22:45 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-06-16 22:45 UTC (permalink / raw
  To: gentoo-commits

commit:     5970bd1432c54e5ab1138f2378eb30c86b182354
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 22:43:10 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5970bd14

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index dadbf7b..52d5d9a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
 	'''CVS sync module'''
 
 	short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
 		return "CVSSync"
 
 
-	def can_progressbar(self, func):
-		return False
-
-
 	def __init__(self):
-		self.settings = None
-		self.options = None
-		self.logger = None
-		self.xterm_titles = None
-		self.has_cvs = True
-		if portage.process.find_binary("cvs") is None:
-			msg = "Command not found: cvs"
-			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
-			for l in msg:
-				writemsg_level("!!! %s\n" % l,
-					level=logging.ERROR, noiselevel=-1)
-			self.has_cvs = False
-
-	def _kwargs(self, **kwargs):
-		self.options = kwargs.get('options', {})
-		self.repo = self.options.get('repo', None)
-		self.logger = self.options.get('logger', None)
-		self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-	def exists(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-		spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			return False
-		return True
-
-
-	def sync(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-
-		if not self.has_cvs:
-			return (1, False)
-
-		if not self.exists():
-			return self.new()
-		return self.sync()
+		SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
 	def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
 				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 				return (1, False)
 			del e
+		cvs_root = self.repo.sync_uri
 		if portage.process.spawn_bash(
 			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
 			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
 				portage._shell_quote(os.path.basename(self.repo.location)),
 				portage._shell_quote(self.repo.sync_cvs_repo)),
-				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+				**portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
 			msg = "!!! cvs checkout error; exiting."
 			self.logger(self.xterm_titles, msg)
 			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 			return (1, False)
 		return (0, False)
 
+
 	def _sync(self):
 		"""
 		Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
 		@rtype: (int, bool)
 		"""
 
-		spawn_kwargs = options.get('spawn_kwargs', None)
 		cvs_root = self.repo.sync_uri
 
 		if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
 				(portage._shell_quote(self.repo.location),),
-				**portage._native_kwargs(spawn_kwargs))
+				**portage._native_kwargs(self.spawn_kwargs))
 			if exitcode != os.EX_OK:
 				msg = "!!! cvs update error; exiting."
 				self.logger(self.xterm_titles, msg)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
@ 2014-09-03 23:36 Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2014-09-03 23:36 UTC (permalink / raw
  To: gentoo-commits

commit:     298343c71b280346038b417d1a77fc29a2a7325e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 15:56:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Sep  3 23:34:52 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=298343c7

portage/sync/modules/cvs: Use SyncBase class.

---
 pym/portage/sync/modules/cvs/cvs.py | 58 +++++--------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)

diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py
index dadbf7b..52d5d9a 100644
--- a/pym/portage/sync/modules/cvs/cvs.py
+++ b/pym/portage/sync/modules/cvs/cvs.py
@@ -1,16 +1,16 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import sys
 import logging
 import errno
 
 import portage
 from portage import os
 from portage.util import writemsg_level
+from portage.sync.syncbase import SyncBase
 
 
-class CVSSync(object):
+class CVSSync(SyncBase):
 	'''CVS sync module'''
 
 	short_desc = "Perform sync operations on CVS repositories"
@@ -20,53 +20,8 @@ class CVSSync(object):
 		return "CVSSync"
 
 
-	def can_progressbar(self, func):
-		return False
-
-
 	def __init__(self):
-		self.settings = None
-		self.options = None
-		self.logger = None
-		self.xterm_titles = None
-		self.has_cvs = True
-		if portage.process.find_binary("cvs") is None:
-			msg = "Command not found: cvs"
-			"Type \"emerge %s\" to enable CVS support." % portage.const.CVS_PACKAGE_ATOM
-			for l in msg:
-				writemsg_level("!!! %s\n" % l,
-					level=logging.ERROR, noiselevel=-1)
-			self.has_cvs = False
-
-	def _kwargs(self, **kwargs):
-		self.options = kwargs.get('options', {})
-		self.repo = self.options.get('repo', None)
-		self.logger = self.options.get('logger', None)
-		self.xterm_titles = self.options.get('xterm_titles', None)
-
-
-	def exists(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-		spawn_kwargs = self.options.get('spawn_kwargs', None)
-
-		if not os.path.exists(os.path.join(repo.location, "CVS")):
-			return False
-		return True
-
-
-	def sync(self, **kwargs):
-		if kwargs:
-			self._kwargs(kwargs)
-
-		if not self.has_cvs:
-			return (1, False)
-
-		if not self.exists():
-			return self.new()
-		return self.sync()
+		SyncBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM)
 
 
 	def new(self, **kwargs):
@@ -85,18 +40,20 @@ class CVSSync(object):
 				writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 				return (1, False)
 			del e
+		cvs_root = self.repo.sync_uri
 		if portage.process.spawn_bash(
 			"cd %s; exec cvs -z0 -d %s co -P -d %s %s" %
 			(portage._shell_quote(os.path.dirname(self.repo.location)), portage._shell_quote(cvs_root),
 				portage._shell_quote(os.path.basename(self.repo.location)),
 				portage._shell_quote(self.repo.sync_cvs_repo)),
-				**portage._native_kwargs(spawn_kwargs)) != os.EX_OK:
+				**portage._native_kwargs(self.spawn_kwargs)) != os.EX_OK:
 			msg = "!!! cvs checkout error; exiting."
 			self.logger(self.xterm_titles, msg)
 			writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR)
 			return (1, False)
 		return (0, False)
 
+
 	def _sync(self):
 		"""
 		Internal function to sync an existing CVS repository
@@ -106,7 +63,6 @@ class CVSSync(object):
 		@rtype: (int, bool)
 		"""
 
-		spawn_kwargs = options.get('spawn_kwargs', None)
 		cvs_root = self.repo.sync_uri
 
 		if cvs_root.startswith("cvs://"):
@@ -118,7 +74,7 @@ class CVSSync(object):
 			exitcode = portage.process.spawn_bash(
 				"cd %s; exec cvs -z0 -q update -dP" % \
 				(portage._shell_quote(self.repo.location),),
-				**portage._native_kwargs(spawn_kwargs))
+				**portage._native_kwargs(self.spawn_kwargs))
 			if exitcode != os.EX_OK:
 				msg = "!!! cvs update error; exiting."
 				self.logger(self.xterm_titles, msg)


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-09-03 23:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-16 15:46 [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2014-09-03 23:36 Brian Dolbec
2014-06-16 22:45 Brian Dolbec
2014-05-02 23:13 Brian Dolbec
2014-05-02 23:13 Brian Dolbec
2014-04-22  2:36 Brian Dolbec
2014-04-22  2:36 Brian Dolbec
2014-04-22  2:36 Brian Dolbec
2014-03-14 16:23 Brian Dolbec
2014-02-11 17:28 Chris Reffett
2014-01-29  6:32 Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox