From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/
Date: Fri, 2 May 2014 23:13:32 +0000 (UTC) [thread overview]
Message-ID: <1398843526.7fa105b7153c20d63acfd4250764adb86985e8e1.dol-sen@gentoo> (raw)
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)
-
next reply other threads:[~2014-05-02 23:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-02 23:13 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-09-03 23:36 [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/cvs/ Brian Dolbec
2014-06-16 22:45 Brian Dolbec
2014-06-16 15:46 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
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=1398843526.7fa105b7153c20d63acfd4250764adb86985e8e1.dol-sen@gentoo \
--to=brian.dolbec@gmail.com \
--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