* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-02-14 6:00 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-02-14 6:00 UTC (permalink / raw
To: gentoo-commits
commit: 5c08a86e2c65c99a98bcfddf6f1f0d2b0c199a8c
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Aug 7 15:33:52 2010 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Feb 11 10:49:14 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=5c08a86e
Apply tulcod's g-common support changes.
---
layman/config.py | 1 +
layman/overlays/g_common.py | 75 +++++++++++++++++++++++++++++++++++++++++++
layman/overlays/overlay.py | 2 +
3 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/layman/config.py b/layman/config.py
index e62f535..ceafcc4 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -74,6 +74,7 @@ class BareConfig(object):
'cvs_command': '/usr/bin/cvs',
'darcs_command': '/usr/bin/darcs',
'git_command': '/usr/bin/git',
+ 'g-common_command': '/usr/bin/g-common',
'mercurial_command': '/usr/bin/hg',
'rsync_command': '/usr/bin/rsync',
'svn_command': '/usr/bin/svn',
diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
new file mode 100644
index 0000000..80d0742
--- /dev/null
+++ b/layman/overlays/g_common.py
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#################################################################################
+# LAYMAN G-COMMON OVERLAY HANDLER
+#################################################################################
+# File: g_common.py
+#
+# Handles g-common-style repositories
+#
+# Copyright:
+# (c) 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+#
+# Author(s):
+# Auke Booij <auke@tulcod.com>
+#
+''' G-common repository support.'''
+
+#===============================================================================
+#
+# Dependencies
+#
+#-------------------------------------------------------------------------------
+
+import os
+from layman.utils import path
+from layman.overlays.source import OverlaySource, require_supported
+
+#===============================================================================
+#
+# Class GCommonOverlay
+#
+#-------------------------------------------------------------------------------
+
+class GCommonOverlay(OverlaySource):
+ ''' Handles g-common-style repositories.'''
+
+ type = 'g-common'
+ type_key = 'g-common'
+
+ def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+ super(GCommonOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+ #split source into driver and remote uri.
+ self.driver=self.src[:self.src.find(' ')]
+ self.remote_uri=self.src[self.src.find(' ')+1:]
+
+ def add(self, base, quiet = False):
+ '''Add overlay.'''
+
+ self.supported()
+
+ os.makedirs(os.path.join(base,self.parent.name))
+ return self.sync(base, quiet)
+
+ def sync(self, base, quiet = False):
+ '''Sync overlay.'''
+
+ self.supported()
+
+ args = [os.path.join(base,self.parent.name), 'sync', self.driver, self.remote_uri]
+ returncode=self.run_command(*args,cwd=path([base,self.parent.name]))
+ if returncode: return returncode
+ args = [os.path.join(base,self.parent.name), 'generate-tree']
+ return self.run_command(*args,cwd=path([base,self.parent.name]))
+
+ def supported(self):
+ '''Overlay type supported?'''
+
+ return require_supported(
+ [(self.command(),
+ 'g-common',
+ 'app-portage/g-common'),
+ ('/usr/share/g-common/drivers/'+self.driver+'.cfg',
+ 'g-common for '+self.driver,
+ 'app-portage/g-'+self.driver),])
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 4036458..6f39ae8 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -40,6 +40,7 @@ from layman.utils import ensure_unicode
from layman.overlays.bzr import BzrOverlay
from layman.overlays.darcs import DarcsOverlay
from layman.overlays.git import GitOverlay
+from layman.overlays.g_common import GCommonOverlay
from layman.overlays.mercurial import MercurialOverlay
from layman.overlays.cvs import CvsOverlay
from layman.overlays.svn import SvnOverlay
@@ -54,6 +55,7 @@ from layman.overlays.tar import TarOverlay
OVERLAY_TYPES = dict((e.type_key, e) for e in (
GitOverlay,
+ GCommonOverlay,
CvsOverlay,
SvnOverlay,
RsyncOverlay,
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-02-14 6:00 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-02-14 6:00 UTC (permalink / raw
To: gentoo-commits
commit: c551ad652c54eaccc974c1bb87e8c7582adacbae
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Jan 17 06:52:52 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Feb 11 10:49:14 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c551ad65
move utility functions out of the Overlay class
---
layman/overlays/overlay.py | 47 ++++--------------------------------
layman/utils.py | 55 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 41 deletions(-)
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 6f39ae8..9e41fe9 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -33,8 +33,8 @@ import codecs
import locale
import xml.etree.ElementTree as ET # Python 2.5
-from layman.utils import ensure_unicode
-
+from layman.utils import (pad, terminal_width, get_encoding, encoder,
+ ensure_unicode)
#from layman.debug import OUT
from layman.overlays.bzr import BzrOverlay
@@ -103,7 +103,8 @@ class Overlay(object):
'''
self.output = config['output']
-
+ self._encoding_ = get_encoding(self.output)
+
def strip_text(node):
res = node.text
if res is None:
@@ -294,16 +295,6 @@ class Overlay(object):
assert len(self.sources) == 1
return self.sources[0].delete(base)
- def _get_encoding(self):
- if hasattr(sys.stdout, 'encoding') \
- and sys.stdout.encoding != None:
- return sys.stdout.encoding
- else:
- return locale.getpreferredencoding()
-
- def _encode(self, unicode_text):
- return codecs.encode(unicode_text, self._get_encoding(), 'replace')
-
def __str__(self):
'''
>>> here = os.path.dirname(os.path.realpath(__file__))
@@ -369,7 +360,7 @@ class Overlay(object):
result += u'\n %s' % i
result += u'\n'
- return self._encode(result)
+ return encoder(result, self._encoding_)
def short_list(self, width = 0):
'''
@@ -382,32 +373,6 @@ class Overlay(object):
wrobel [Subversion] (https://o.g.o/svn/dev/wrobel )
'''
- def pad(string, length):
- '''Pad a string with spaces.'''
- if len(string) <= length:
- return string + ' ' * (length - len(string))
- else:
- return string[:length - 3] + '...'
-
- def terminal_width():
- '''Determine width of terminal window.'''
- try:
- width = int(os.environ['COLUMNS'])
- if width > 0:
- return width
- except:
- pass
- try:
- import struct, fcntl, termios
- query = struct.pack('HHHH', 0, 0, 0, 0)
- response = fcntl.ioctl(1, termios.TIOCGWINSZ, query)
- width = struct.unpack('HHHH', response)[1]
- if width > 0:
- return width
- except:
- pass
- return 80
-
name = pad(self.name, 25)
if len(set(e.type for e in self.sources)) == 1:
@@ -424,7 +389,7 @@ class Overlay(object):
source = source.replace("overlays.gentoo.org", "o.g.o")
source = ' (' + pad(source, srclen) + ')'
- return self._encode(name + mtype + source)
+ return encoder(name + mtype + source, self._encoding_)
def is_official(self):
'''Is the overlay official?'''
diff --git a/layman/utils.py b/layman/utils.py
index 18bf442..79b3c18 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -30,14 +30,69 @@ __version__ = '$Id: utils.py 236 2006-09-05 20:39:37Z wrobel $'
#-------------------------------------------------------------------------------
import types, re, os
+import sys
+import locale
+import codecs
+
from layman.debug import OUT
+
#===============================================================================
#
# Helper functions
#
#-------------------------------------------------------------------------------
+def decode_selection(selection):
+ '''utility function to decode a list of strings
+ accoring to the filesystem encoding
+ '''
+ enc = sys.getfilesystemencoding()
+ if enc:
+ return [i.decode(enc) for i in selection]
+ return selection
+
+
+def encoder(unicode_text, _encoding_):
+ return codecs.encode(unicode_text, _encoding_, 'replace')
+
+
+def get_encoding(output):
+ if hasattr(output, 'encoding') \
+ and output.encoding != None:
+ return output.encoding
+ else:
+ return locale.getpreferredencoding()
+
+
+def pad(string, length):
+ '''Pad a string with spaces.'''
+ if len(string) <= length:
+ return string + ' ' * (length - len(string))
+ else:
+ return string[:length - 3] + '...'
+
+
+def terminal_width():
+ '''Determine width of terminal window.'''
+ try:
+ width = int(os.environ['COLUMNS'])
+ if width > 0:
+ return width
+ except:
+ pass
+ try:
+ import struct, fcntl, termios
+ query = struct.pack('HHHH', 0, 0, 0, 0)
+ response = fcntl.ioctl(1, termios.TIOCGWINSZ, query)
+ width = struct.unpack('HHHH', response)[1]
+ if width > 0:
+ return width
+ except:
+ pass
+ return 80
+
+
def ensure_unicode(obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, unicode):
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-02-14 6:00 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-02-14 6:00 UTC (permalink / raw
To: gentoo-commits
commit: 92298c7aa198f0492655d365fd8bb11f2d883869
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Tue Jan 18 04:05:48 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 03:48:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=92298c7a
add a generator for source types the same as source uris.
use the generator in get_all_info().
pylint cleanup.
---
layman/api.py | 23 ++++++++++++-----------
layman/overlays/overlay.py | 5 +++++
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index dfce4a0..99696f8 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -13,8 +13,8 @@
# Brian Dolbec <dol-sen@sourceforge.net>
#
-from sys import stderr, stdin, stdout
-import os, types
+from sys import stderr
+import os
from layman.config import BareConfig
#from layman.action import Sync
@@ -22,7 +22,7 @@ from layman.config import BareConfig
from layman.dbbase import UnknownOverlayException
from layman.db import DB, RemoteDB
#from layman.utils import path, delete_empty_directory
-from layman.debug import Message, OUT
+from layman.debug import OUT
# give them some values for now, these are from the packagekit backend
# TODO establish some proper errors for the api.
@@ -215,7 +215,8 @@ class LaymanAPI(object):
'description': overlay.description,
#'src_uris': [e.src for e in overlay.sources],
'src_uris': overlay.source_uris(),
- 'src_types': [e.type for e in overlay.sources],
+ 'src_types': overlay.source_types(),
+ #'src_types': [e.type for e in overlay.sources],
'priority': overlay.priority,
'quality': overlay.quality,
'status': overlay.status,
@@ -308,7 +309,7 @@ class LaymanAPI(object):
ordb = self._get_remote_db().select(ovl)
except UnknownOverlayException:
message = 'Overlay "%s" could not be found in the remote lists.\n' \
- 'Please check if it has been renamed and re-add if necessary.' %ovl
+ 'Please check if it has been renamed and re-add if necessary.' % ovl
warnings.append((ovl, message))
else:
current_src = odb.sources[0].src
@@ -420,10 +421,10 @@ class LaymanAPI(object):
defaults to stderr. This method may be removed, is here for now
due to code taken from the packagekit backend.
"""
- m = "Error: %d," %num, message
- self._error_messages.append(m)
+ msg = "Error: %d," % num, message
+ self._error_messages.append(msg)
if self.report_errors:
- print >>stderr, m
+ print >>stderr, msg
def get_errors(self):
@@ -445,8 +446,8 @@ def create_fd():
use in place of stdin, stdout, stderr.
"""
fd_r, fd_w = os.pipe()
- w = os.fdopen(fd_w, 'w')
- r = os.fdopen(fd_r, 'r')
- return (r, w, fd_r, fd_w)
+ write = os.fdopen(fd_w, 'w')
+ rread = os.fdopen(fd_r, 'r')
+ return (read, write, fd_r, fd_w)
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 9e41fe9..c7c9cce 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -403,6 +403,11 @@ class Overlay(object):
for i in self.sources:
yield i.src
+ def source_types(self):
+ for i in self.sources:
+ yield i.type
+
+
#================================================================================
#
# Testing
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-02-14 6:00 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-02-14 6:00 UTC (permalink / raw
To: gentoo-commits
commit: f91a4b9045933174384f558bd89aeb24a2579bef
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Feb 5 18:34:28 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 03:48:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f91a4b90
add an irc data element to the overlay xml
---
layman/api.py | 1 +
layman/overlays/overlay.py | 13 +++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index d97bf8e..77e95d8 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -212,6 +212,7 @@ class LaymanAPI(object):
'owner_name': overlay.owner_name,
'owner_email': overlay.owner_email,
'homepage': overlay.homepage,
+ 'irc': overlay.irc,
'description': overlay.description,
#'src_uris': [e.src for e in overlay.sources],
'src_uris': overlay.source_uris(),
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index c7c9cce..e73f7e4 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -210,6 +210,12 @@ class Overlay(object):
self.feeds = [ensure_unicode(strip_text(e)) for e in xml.findall('feed')]
+ _irc = xml.find('irc')
+ if _irc != None:
+ self.irc = ensure_unicode(strip_text(_irc))
+ else:
+ self.irc = None
+
def __eq__(self, other):
for i in ('description', 'homepage', 'name', 'owner_email',
@@ -249,6 +255,10 @@ class Overlay(object):
homepage = ET.Element('homepage')
homepage.text = self.homepage
repo.append(homepage)
+ if self.irc != None:
+ irc = ET.Element('irc')
+ irc.text = self.irc
+ repo.append(irc)
owner = ET.Element('owner')
repo.append(owner)
owner_email = ET.Element('email')
@@ -354,6 +364,9 @@ class Overlay(object):
result += u'\n '.join((u'\n' + link).split(u'\n'))
result += u'\n'
+ if self.irc != None:
+ result += u'\nIRC : ' + self.irc + u'\n'
+
if self.feeds:
result += u'\n%s:' % ((len(self.feeds) == 1) and "Feed" or "Feeds")
for i in self.feeds:
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-02-14 6:00 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-02-14 6:00 UTC (permalink / raw
To: gentoo-commits
commit: b9635c0d5a2b99263ba361bf957d31ac0907c5a0
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Feb 6 23:37:30 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 03:55:47 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b9635c0d
rename Overlay's __str__(). split out UnknownOverlayMessage() from the exception class
---
layman/dbbase.py | 8 +++++---
layman/overlays/overlay.py | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 3532062..5d082a0 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -41,10 +41,12 @@ from layman.overlays.overlay import Overlay
# Class UnknownOverlayException
#
#-------------------------------------------------------------------------------
+def UnknownOverlayMessage(ovl):
+ return 'Overlay "%s" does not exist.' % ovl
class UnknownOverlayException(Exception):
def __init__(self, repo_name):
- message = 'Overlay "%s" does not exist.' % repo_name
+ UnknownOverlayMessage(repo_name)
super(UnknownOverlayException, self).__init__(message)
#===============================================================================
@@ -242,8 +244,8 @@ class DbBase:
for overlay in selection:
if verbose:
- result.append((str(overlay), overlay.is_supported(),
- overlay.is_official()))
+ result.append(overlay.get_infostr(), overlay.is_supported(),
+ overlay.is_official())
else:
result.append((overlay.short_list(width), overlay.is_supported(),
overlay.is_official()))
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index e73f7e4..f93530e 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -305,7 +305,7 @@ class Overlay(object):
assert len(self.sources) == 1
return self.sources[0].delete(base)
- def __str__(self):
+ def get_infostr(self):
'''
>>> here = os.path.dirname(os.path.realpath(__file__))
>>> import xml.etree.ElementTree as ET # Python 2.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-04-27 10:58 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
To: gentoo-commits
commit: d0339cb228c16eb491d489a2276e254bacb41c81
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Mar 27 03:39:37 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 27 03:39:37 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d0339cb2
migrate except ... as
---
layman/api.py | 14 +++++++-------
layman/cli.py | 4 ++--
layman/db.py | 8 ++++----
layman/dbbase.py | 6 +++---
layman/makeconf.py | 4 ++--
layman/overlays/overlay.py | 2 +-
layman/overlays/tar.py | 10 +++++-----
layman/utils.py | 2 +-
8 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 9dfb1a3..9178dbe 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -116,7 +116,7 @@ class LaymanAPI(object):
try:
self._get_installed_db().delete(self._get_installed_db().select(ovl))
results.append(True)
- except Exception, e:
+ except Exception as e:
self._error(ERROR_INTERNAL_ERROR,
"Failed to disable repository '"+ovl+"':\n"+str(e))
results.append(False)
@@ -147,7 +147,7 @@ class LaymanAPI(object):
try:
self._get_installed_db().add(self._get_remote_db().select(ovl), quiet=True)
results.append(True)
- except Exception, e:
+ except Exception as e:
self._error(ERROR_INTERNAL_ERROR,
"Failed to enable repository '"+ovl+"' : "+str(e))
results.append(False)
@@ -198,7 +198,7 @@ class LaymanAPI(object):
continue
try:
overlay = db.select(ovl)
- except UnknownOverlayException, error:
+ except UnknownOverlayException as error:
self._error(error)
result[ovl] = ('', False, False)
else:
@@ -252,7 +252,7 @@ class LaymanAPI(object):
overlay = db.select(ovl)
#print("overlay = ", ovl)
#print("!!!", overlay)
- except UnknownOverlayException, error:
+ except UnknownOverlayException as error:
#print("ERRORS", str(error))
self._error(error)
result[ovl] = ('', False, False)
@@ -301,7 +301,7 @@ class LaymanAPI(object):
for ovl in repos:
try:
odb = db.select(ovl)
- except UnknownOverlayException, error:
+ except UnknownOverlayException as error:
self._error(UnknownOverlayException(error))
continue
@@ -344,7 +344,7 @@ class LaymanAPI(object):
try:
db.sync(ovl, self.config['quiet'])
success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))
- except Exception, error:
+ except Exception as error:
fatals.append((ovl,
'Failed to sync overlay "' + ovl + '".\nError was: '
+ str(error)))
@@ -374,7 +374,7 @@ class LaymanAPI(object):
"""Fetches the latest remote overlay list"""
try:
self._get_remote_db().cache()
- except Exception, error:
+ except Exception as error:
self._error('Failed to fetch overlay list!\n Original Error was: '
+ str(error))
return False
diff --git a/layman/cli.py b/layman/cli.py
index 1187ef2..d58c4ff 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -162,7 +162,7 @@ class Main(object):
try:
new_umask = int(umask, 8)
old_umask = os.umask(new_umask)
- except Exception, error:
+ except Exception as error:
self.output.die('Failed setting to umask "' + umask +
'"!\nError was: ' + str(error))
@@ -173,7 +173,7 @@ class Main(object):
if action[0] in self.config.keys():
try:
result += getattr(self, action[1])()
- except Exception, error:
+ except Exception as error:
for _error in self.api.get_errors():
self.output.error(_error)
result = -1 # So it cannot remain 0, i.e. success
diff --git a/layman/db.py b/layman/db.py
index ed2bb2e..6e3cba4 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -303,7 +303,7 @@ class RemoteDB(DbBase):
if not os.path.exists(os.path.dirname(mpath)):
try:
os.makedirs(os.path.dirname(mpath))
- except OSError, error:
+ except OSError as error:
raise OSError('Failed to create layman storage direct'
+ 'ory ' + os.path.dirname(mpath) + '\n'
+ 'Error was:' + str(error))
@@ -312,7 +312,7 @@ class RemoteDB(DbBase):
# file is intact and can be parsed
try:
self.read(olist, origin=url)
- except Exception, error:
+ except Exception as error:
raise IOError('Failed to parse the overlays list fetched fr'
'om ' + url + '\nThis means that the download'
'ed file is somehow corrupt or there was a pr'
@@ -325,12 +325,12 @@ class RemoteDB(DbBase):
out_file.write(olist)
out_file.close()
- except Exception, error:
+ except Exception as error:
raise IOError('Failed to temporarily cache overlays list in'
' ' + mpath + '\nError was:\n' + str(error))
- except IOError, error:
+ except IOError as error:
self.output.warn('Failed to update the overlay list from: '
+ url + '\nError was:\n' + str(error))
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 02aeb9d..5c45cb1 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -116,7 +116,7 @@ class DbBase:
try:
document = open(path, 'r').read()
- except Exception, error:
+ except Exception as error:
if not ignore_init_read_errors:
self.output.error('Failed to read the overlay list at ("'
+ path + '")')
@@ -146,7 +146,7 @@ class DbBase:
'''
try:
document = ET.fromstring(text)
- except xml.parsers.expat.ExpatError, error:
+ except xml.parsers.expat.ExpatError as error:
raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint())
overlays = document.findall('overlay') + \
@@ -216,7 +216,7 @@ class DbBase:
""")
tree.write(f, encoding='utf-8')
f.close()
- except Exception, error:
+ except Exception as error:
raise Exception('Failed to write to local overlays file: '
+ path + '\nError was:\n' + str(error))
diff --git a/layman/makeconf.py b/layman/makeconf.py
index b6f5d90..1dd2b56 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -257,7 +257,7 @@ class MakeConf:
make_conf.close()
- except Exception, error:
+ except Exception as error:
self.output.error('MakeConf: write(); Failed to write "'
+ self.path + '".\nError was:\n' + str(error))
return False
@@ -274,7 +274,7 @@ class MakeConf:
make_conf.close()
- except Exception, error:
+ except Exception as error:
self.output.error('MakeConf: content(); Failed to read "' +
self.path + '".\nError was:\n' + str(error))
raise error
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index aada4a2..b99c052 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -405,7 +405,7 @@ class Overlay(object):
# Worked, throw other sources away
self.sources = [s]
break
- except Exception, error:
+ except Exception as error:
self.output.warn(str(error), 4)
first_s = False
return res
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 9d59b71..204a626 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -107,7 +107,7 @@ class TarOverlay(OverlaySource):
try:
tar = urllib2.urlopen(tar_url).read()
- except Exception, error:
+ except Exception as error:
raise Exception('Failed to fetch the tar package from: '
+ self.src + '\nError was:' + str(error))
@@ -117,7 +117,7 @@ class TarOverlay(OverlaySource):
out_file = open(pkg, 'w')
out_file.write(tar)
out_file.close()
- except Exception, error:
+ except Exception as error:
raise Exception('Failed to store tar package in '
+ pkg + '\nError was:' + str(error))
@@ -136,7 +136,7 @@ class TarOverlay(OverlaySource):
try:
self.output.info('Deleting directory "%s"' % folder, 2)
shutil.rmtree(folder)
- except Exception, error:
+ except Exception as error:
raise Exception('Failed to remove unnecessary tar structure "'
+ folder + '"\nError was:' + str(error))
@@ -145,7 +145,7 @@ class TarOverlay(OverlaySource):
try:
result = self._extract(base=base, tar_url=self.src,
dest_dir=temp_path)
- except Exception, error:
+ except Exception as error:
try_to_wipe(temp_path)
raise error
@@ -161,7 +161,7 @@ class TarOverlay(OverlaySource):
try:
os.rename(source, final_path)
- except Exception, error:
+ except Exception as error:
raise Exception('Failed to rename tar subdirectory ' +
source + ' to ' + final_path +
'\nError was:' + str(error))
diff --git a/layman/utils.py b/layman/utils.py
index 86524ef..03ddb45 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -167,7 +167,7 @@ def delete_empty_directory(mdir, output=OUT):
output.info('Deleting _empty_ directory "%s"' % mdir, 2)
try:
os.rmdir(mdir)
- except OSError, error:
+ except OSError as error:
output.warn(str(error))
else:
output.warn('Insufficient permissions to delete _empty_ folder "%s".' % mdir)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-04-27 10:58 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
To: gentoo-commits
commit: 97c96c8f6d616889bf9dcc423f27675c11af4af8
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Mar 28 02:52:48 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Mar 28 02:52:48 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=97c96c8f
migrate to using explicit checks.
---
layman/api.py | 4 ++--
layman/argsparser.py | 2 +-
layman/db.py | 2 +-
layman/dbbase.py | 6 +++---
layman/overlays/bzr.py | 4 ++--
layman/overlays/cvs.py | 4 ++--
layman/overlays/darcs.py | 4 ++--
layman/overlays/git.py | 4 ++--
layman/overlays/mercurial.py | 4 ++--
layman/overlays/overlay.py | 2 +-
layman/overlays/rsync.py | 2 +-
layman/overlays/source.py | 6 +++---
layman/overlays/svn.py | 4 ++--
layman/utils.py | 2 +-
14 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 11fef62..cbb9d99 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -49,7 +49,7 @@ class LaymanAPI(object):
default is Message(module='layman') other params are defaults.
"""
- self.config = config if config else BareConfig(output=output)
+ self.config = config if config is not None else BareConfig(output=output)
self.output = self.config['output']
@@ -433,7 +433,7 @@ class LaymanAPI(object):
@rtype: list
@return: list of error strings
"""
- if self._error_messages:
+ if len(self._error_messages):
messages = self._error_messages[:]
self._error_messages = []
return messages
diff --git a/layman/argsparser.py b/layman/argsparser.py
index 708b1f8..9b6aa91 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -272,7 +272,7 @@ class ArgsParser(BareConfig):
overlays = '\n'.join(self.options.__dict__[key])
if self.config.has_option('MAIN', 'overlays'):
overlays += '\n' + self.config.get('MAIN', 'overlays')
- if overlays:
+ if len(overlays):
return overlays
self.output.debug('Retrieving option', 8)
diff --git a/layman/db.py b/layman/db.py
index 6e3cba4..aaba2b7 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -240,7 +240,7 @@ class RemoteDB(DbBase):
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
- self.urls = [i.strip() for i in config['overlays'].split('\n') if i]
+ self.urls = [i.strip() for i in config['overlays'].split('\n') if len(i)]
paths = [self.path(i) for i in self.urls]
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 5c45cb1..70d0cfa 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -164,9 +164,9 @@ class DbBase:
'''Reads xml text and dictionary definitions and adds
them to the db.
'''
- if xml:
+ if xml is not None:
self.read(xml, origin)
- if from_dict:
+ if from_dict is not None:
self.output.info("DbBase: add_new() from_dict")
if isinstance(from_dict, dict):
from_dict = [from_dict]
@@ -272,7 +272,7 @@ class DbBase:
result = []
selection = [overlay for (a, overlay) in self.overlays.items()]
- if repos:
+ if repos is not None:
selection = [overlay for overlay in selection if overlay.name in repos]
for overlay in selection:
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 957f9e7..ec57a7b 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -55,7 +55,7 @@ class BzrOverlay(OverlaySource):
target = path([base, self.parent.name])
# bzr get SOURCE TARGET
- if cfg_opts:
+ if len(cfg_opts):
args = ['get', cfg_opts,
self.src + '/', target]
else:
@@ -73,7 +73,7 @@ class BzrOverlay(OverlaySource):
target = path([base, self.parent.name])
# bzr pull --overwrite SOURCE
- if cfg_opts:
+ if len(cfg_opts):
args = ['pull', cfg_opts, '--overwrite', self.src]
else:
args = ['pull', '--overwrite', self.src]
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 69e0dd1..15a6c97 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -76,7 +76,7 @@ class CvsOverlay(OverlaySource):
args.append('-q')
args.append('co')
args.append('-d')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
args.append(self.parent.name)
args.append(self.subpath)
@@ -100,7 +100,7 @@ class CvsOverlay(OverlaySource):
args.append('-q')
args.append('update')
args.append('-d')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
return self.postsync(
self.run_command(self.command(), *args, cwd=target, cmd=self.type),
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 14a415b..358db2d 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -54,7 +54,7 @@ class DarcsOverlay(OverlaySource):
target = path([base, self.parent.name])
# darcs get --partial SOURCE TARGET
- if cfg_opts:
+ if len(cfg_opts):
args = ['get', '--partial', cfg_opts,
self.src + '/', target]
else:
@@ -74,7 +74,7 @@ class DarcsOverlay(OverlaySource):
target = path([base, self.parent.name])
# darcs pull --all SOURCE
- if cfg_opts:
+ if len(cfg_opts):
args = ['pull', '--all', cfg_opts, self.src]
else:
args = ['pull', '--all', self.src]
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index d65a5d3..1825f92 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -62,7 +62,7 @@ class GitOverlay(OverlaySource):
args = ['clone']
if quiet:
args.append('-q')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
args.append(fix_git_source(self.src))
args.append(target)
@@ -81,7 +81,7 @@ class GitOverlay(OverlaySource):
args = ['pull']
if quiet:
args.append('-q')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
return self.postsync(
self.run_command(self.command(), *args, cwd=target, cmd=self.type),
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 748588b..c6a9fce 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -55,7 +55,7 @@ class MercurialOverlay(OverlaySource):
target = path([base, self.parent.name])
# hg clone SOURCE TARGET
- if cfg_opts:
+ if len(cfg_opts):
args = ['clone', cfg_opts, self.src + '/', target]
else:
args = ['clone', self.src + '/', target]
@@ -73,7 +73,7 @@ class MercurialOverlay(OverlaySource):
target = path([base, self.parent.name])
# hg pull -u SOURCE
- if cfg_opts:
+ if len(cfg_opts):
args = ['pull', '-u', cfg_opts, self.src]
else:
args = ['pull', '-u', self.src]
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 9486c38..9d2006b 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -143,7 +143,7 @@ class Overlay(object):
return _class(parent=self, config=self.config,
_location=_location, ignore=ignore, quiet=quiet)
- if not _sources:
+ if not len(_sources):
raise Exception('Overlay "' + self.name + \
'" is missing a "source" entry!')
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 76b289e..d282b35 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -69,7 +69,7 @@ class RsyncOverlay(OverlaySource):
if quiet:
args.append('-q')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
args.append(self.src + '/')
args.append(target)
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 458f627..a845266 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -126,10 +126,10 @@ class OverlaySource(object):
env.update(env_updates)
command_repr = ' '.join(args)
- if env_updates:
+ if env_updates is not None:
command_repr = '%s %s' % (' '.join('%s=%s' % (k, v) for (k, v)
in sorted(env_updates.items())), command_repr)
- if cwd:
+ if cwd is not None:
command_repr = '( cd %s && %s )' % (cwd, command_repr)
cmd = kwargs.get('cmd', '')
@@ -176,7 +176,7 @@ class OverlaySource(object):
return failed_sync
# good to continue
postsync_opt = self.config['%s_postsync' % self.__class__.type_key]
- if postsync_opt:
+ if len(postsync_opt):
# repalce "%cwd=" while it's still a string'
_opt = postsync_opt.replace('%cwd=',
kwargs.get('cwd', '')).split()
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index e0eb632..6b124a3 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -58,7 +58,7 @@ class SvnOverlay(OverlaySource):
args = ['co']
if quiet:
args.append('-q')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
args.append(self.src + '/@')
args.append(target)
@@ -87,7 +87,7 @@ class SvnOverlay(OverlaySource):
args = ['up']
if quiet:
args.append('-q')
- if cfg_opts:
+ if len(cfg_opts):
args.append(cfg_opts)
args.append(target)
diff --git a/layman/utils.py b/layman/utils.py
index 03ddb45..e38ea7c 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -50,7 +50,7 @@ def decode_selection(selection):
# fix None passed in, return an empty list
selection = selection or []
enc = sys.getfilesystemencoding()
- if enc:
+ if enc is not None:
return [i.decode(enc) for i in selection]
return selection
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-07-29 6:11 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-07-29 6:11 UTC (permalink / raw
To: gentoo-commits
commit: ba4481d37cbedc5700b5ea21c5a1897389ecc1cb
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Fri Jul 29 06:10:33 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jul 29 06:10:33 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ba4481d3
fix the overly noisy output for unsupported overlay types. Thank you fuzzyray for reporting.
---
layman/dbbase.py | 2 +-
layman/overlays/bzr.py | 2 +-
layman/overlays/cvs.py | 2 +-
layman/overlays/darcs.py | 2 +-
layman/overlays/g_common.py | 3 ++-
layman/overlays/git.py | 2 +-
layman/overlays/mercurial.py | 2 +-
layman/overlays/rsync.py | 2 +-
layman/overlays/source.py | 33 +++++++++++++++++++++++----------
layman/overlays/svn.py | 2 +-
layman/overlays/tar.py | 2 +-
11 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/layman/dbbase.py b/layman/dbbase.py
index b6b0e6d..4714d5f 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -75,7 +75,7 @@ class BrokenOverlayCatalog(ValueError):
#
#-------------------------------------------------------------------------------
-class DbBase:
+class DbBase(object):
''' Handle a list of overlays.'''
def __init__(self, config, paths=None, ignore = 0,
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 5844176..40e5b81 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -89,4 +89,4 @@ class BzrOverlay(OverlaySource):
return require_supported(
[(self.command(), 'bzr', 'dev-vcs/bzr'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 83981e5..c902250 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -114,4 +114,4 @@ class CvsOverlay(OverlaySource):
return require_supported(
[(self.command(), 'cvs', 'dev-vcs/cvs'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 02ef3c7..3e24ebe 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -90,4 +90,4 @@ class DarcsOverlay(OverlaySource):
return require_supported(
[(self.command(), 'darcs', 'dev-vcs/darcs'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index df7c4a4..cb162e8 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -84,4 +84,5 @@ class GCommonOverlay(OverlaySource):
'app-portage/g-common'),
('/usr/share/g-common/drivers/'+self.driver+'.cfg',
'g-common for '+self.driver,
- 'app-portage/g-'+self.driver),], self.output.error)
+ 'app-portage/g-'+self.driver),],
+ self.output.warn)
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 5775277..f6a350f 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -95,4 +95,4 @@ class GitOverlay(OverlaySource):
return require_supported(
[(self.command(), 'git', 'dev-vcs/git'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index ebaf635..5247e78 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -90,4 +90,4 @@ class MercurialOverlay(OverlaySource):
return require_supported(
[(self.command(), 'mercurial', 'dev-vcs/mercurial'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index f4537ed..3c03ae2 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -86,4 +86,4 @@ class RsyncOverlay(OverlaySource):
return require_supported(
[(self.command(), 'rsync', 'net-misc/rsync'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index b833fd2..083beb6 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -20,11 +20,21 @@ import shutil
import subprocess
from layman.utils import path
-
-def _resolve_command(command, error_output):
+supported_cache = {}
+
+def _supported(key, check_supported=None):
+ """internal caching function that checks tracks any
+ un-supported/supported repo types."""
+ if key is None:
+ return False
+ if key not in supported_cache:
+ supported_cache[key] = check_supported()
+ return supported_cache[key]
+
+def _resolve_command(command, _output):
if os.path.isabs(command):
if not os.path.exists(command):
- error_output('Program "%s" not found' % command)
+ _output('Program "%s" not found' % command, 6)
return ('File', None)
return ('File', command)
else:
@@ -34,18 +44,18 @@ def _resolve_command(command, error_output):
f = os.path.join(d, command)
if os.path.exists(f):
return ('Command', f)
- error_output('Cound not resolve command ' +\
- '"%s" based on PATH "%s"' % (command, env_path))
+ _output('Cound not resolve command ' +\
+ '"%s" based on PATH "%s"' % (command, env_path), 6)
return ('Command', None)
-def require_supported(binaries, error_output):
+def require_supported(binaries, _output):
for command, mtype, package in binaries:
- kind, path = _resolve_command(command, error_output)
+ kind, path = _resolve_command(command, _output)
if not path:
- error_output(kind + ' ' + command + ' seems to be missing!'
+ _output(kind + ' ' + command + ' seems to be missing!'
' Overlay type "' + mtype + '" not support'
- 'ed. Did you emerge ' + package + '?')
+ 'ed. Did you emerge ' + package + '?', 6)
return False
return True
@@ -106,7 +116,10 @@ class OverlaySource(object):
def is_supported(self):
'''Is the overlay type supported?'''
- return self.supported()
+ return _supported(self.get_type_key(), self.supported)
+
+ def get_type_key(self):
+ return '%s' % self.__class__.type_key
def command(self):
return self.config['%s_command' % self.__class__.type_key]
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 59b6284..97f03d6 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -103,4 +103,4 @@ class SvnOverlay(OverlaySource):
return require_supported(
[(self.command(), 'svn','dev-vcs/subversion'),],
- self.output.error)
+ self.output.warn)
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index dc2234a..7be2ed2 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -210,7 +210,7 @@ class TarOverlay(OverlaySource):
return require_supported(
[(self.command(), 'tar', 'app-arch/tar'), ],
- self.output.error)
+ self.output.warn)
if __name__ == '__main__':
import doctest
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-07-30 16:53 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-07-30 16:53 UTC (permalink / raw
To: gentoo-commits
commit: 6bfa7e9204b4af2ee0fc816c87ea2bffcce61ccb
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Jul 30 16:52:54 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul 30 16:52:54 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6bfa7e92
add supported_types() to the api
---
layman/api.py | 12 ++++++++++++
layman/overlays/source.py | 3 ++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index fefb6a0..869d882 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -22,6 +22,7 @@ from layman.config import BareConfig
from layman.dbbase import UnknownOverlayException, UnknownOverlayMessage
from layman.db import DB, RemoteDB
+from layman.overlays.source import require_supported
#from layman.utils import path, delete_empty_directory
# give them some values for now, these are from the packagekit backend
@@ -499,6 +500,17 @@ class LaymanAPI(object):
return messages
return []
+ def supported_types(self):
+ """returns a dictionary of all repository types,
+ with boolean values"""
+ cmds = [x for x in self.config.keys() if '_command' in x]
+ supported = {}
+ for cmd in cmds:
+ type_key = cmd.split('_')[0]
+ supported[type_key] = require_supported(
+ [(self.config[cmd],type_key, '')], self.output.warn)
+ return supported
+
def create_fd():
"""creates file descriptor pairs an opens them ready for
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 083beb6..a62cd15 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -53,7 +53,8 @@ def require_supported(binaries, _output):
for command, mtype, package in binaries:
kind, path = _resolve_command(command, _output)
if not path:
- _output(kind + ' ' + command + ' seems to be missing!'
+ if _output:
+ _output(kind + ' ' + command + ' seems to be missing!'
' Overlay type "' + mtype + '" not support'
'ed. Did you emerge ' + package + '?', 6)
return False
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-08-06 18:29 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-08-06 18:29 UTC (permalink / raw
To: gentoo-commits
commit: b99c5c5c78a8d2e1313ae91e25d3938c01aab9bc
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Aug 6 18:26:44 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Aug 6 18:26:44 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b99c5c5c
add debug messages, fix broken UnknownOverlayException
---
layman/dbbase.py | 13 ++++++++++---
layman/overlays/git.py | 1 +
layman/overlays/overlay.py | 1 +
layman/overlays/source.py | 5 +++++
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 4714d5f..dfe6ec8 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -44,12 +44,14 @@ from layman.overlays.overlay import Overlay
#
#-------------------------------------------------------------------------------
def UnknownOverlayMessage(ovl):
- return 'Overlay "%s" does not exist.' % ovl
+ return 'Exception: Overlay "%s" does not exist.' % ovl
class UnknownOverlayException(Exception):
def __init__(self, repo_name):
- UnknownOverlayMessage(repo_name)
- super(UnknownOverlayException, self).__init__(message)
+ self.repo_name = repo_name
+
+ def __str__(self):
+ return UnknownOverlayMessage(self.repo_name)
#===============================================================================
#
@@ -236,7 +238,12 @@ class DbBase(object):
>>> list(a.select('wrobel-stable').source_uris())
[u'rsync://gunnarwrobel.de/wrobel-stable']
'''
+ self.output.debug("DbBase.select(), overlay = %s" % overlay, 5)
if not overlay in self.overlays.keys():
+ self.output.debug("DbBase.select(), unknown overlay = %s"
+ % overlay, 4)
+ self.output.debug("DbBase.select(), known overlays = %s"
+ % ', '.join(self.overlays.keys()), 4)
raise UnknownOverlayException(overlay)
return self.overlays[overlay]
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index f6a350f..64a0dfb 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -74,6 +74,7 @@ class GitOverlay(OverlaySource):
def sync(self, base, quiet = False):
'''Sync overlay.'''
+ self.output.debug("git.sync(); starting...%s" % self.parent.name, 6)
if not self.supported():
return 1
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 60d57d4..8eaa77e 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -420,6 +420,7 @@ class Overlay(object):
def sync(self, base, quiet = False):
+ self.output.debug("overlay.sync(); name = %s" % self.name, 4)
assert len(self.sources) == 1
return self.sources[0].sync(base, quiet)
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index a62cd15..a57baf4 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -173,6 +173,11 @@ class OverlaySource(object):
except KeyboardInterrupt:
self.output.info('Interrupted manually', 2)
result = 1
+ except Exception as err:
+ self.output.error(
+ 'Unknown exception running command: %s' % command_repr, 2)
+ self.output.error('Original error was: %s' % str(err), 2)
+ result = 1
if self.quiet:
output_target.close()
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-08-07 2:29 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-08-07 2:29 UTC (permalink / raw
To: gentoo-commits
commit: c3fe77a1e76daa7a2b5a7b92d0061eb2cc44eed8
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Aug 7 01:35:20 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 7 01:35:20 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c3fe77a1
adjust width for the leading space
---
layman/cli.py | 2 +-
layman/overlays/overlay.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/layman/cli.py b/layman/cli.py
index f545b0e..9690e54 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -39,7 +39,7 @@ class ListPrinter(object):
self.config = config
self.output = self.config['output']
if not self.config['width']:
- self.width = terminal_width()
+ self.width = terminal_width()-1
else:
self.width = self.config['width']
self.srclen = self.width - 43
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
old mode 100644
new mode 100755
index 8eaa77e..2e900e8
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -526,7 +526,7 @@ class Overlay(object):
mtype = ' [' + pad(_type, 10) + ']'
if not width:
- width = terminal_width()
+ width = terminal_width()-1
srclen = width - 43
source = ', '.join(self.source_uris())
if len(source) > srclen:
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-08-11 3:24 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-08-11 3:24 UTC (permalink / raw
To: gentoo-commits
commit: 779c56e34676bcf113dea93c748eeec5f214952f
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Wed Aug 10 00:47:00 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Aug 10 00:47:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=779c56e3
revert using "as" in exceptions. enable using the "with" statement in py-2.5.
fix run_command( ,*arg, )
---
layman/api.py | 12 ++++++------
layman/argsparser.py | 1 -
layman/cli.py | 2 +-
layman/db.py | 12 +++++++-----
layman/dbbase.py | 8 ++++----
layman/makeconf.py | 4 ++--
layman/overlays/overlay.py | 2 +-
layman/overlays/source.py | 4 ++--
layman/overlays/tar.py | 10 +++++-----
layman/utils.py | 2 +-
10 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 80b927f..f48e11f 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -117,7 +117,7 @@ class LaymanAPI(object):
try:
self._get_installed_db().delete(
self._get_installed_db().select(ovl))
- except Exception as e:
+ except Exception, e:
self._error(
"Exception caught disabling repository '"+ovl+
"':\n"+str(e))
@@ -151,7 +151,7 @@ class LaymanAPI(object):
try:
success = self._get_installed_db().add(
self._get_remote_db().select(ovl), quiet=True)
- except Exception as e:
+ except Exception, e:
self._error("Exception caught enabling repository '"+ovl+
"' : "+str(e))
results.append(success)
@@ -202,7 +202,7 @@ class LaymanAPI(object):
continue
try:
overlay = db.select(ovl)
- except UnknownOverlayException as error:
+ except UnknownOverlayException, error:
self._error(error)
result[ovl] = ('', False, False)
else:
@@ -310,7 +310,7 @@ class LaymanAPI(object):
#self.output.debug("API.sync(); selecting %s, db = %s" % (ovl, str(db)), 5)
odb = db.select(ovl)
self.output.debug("API.sync(); %s now selected" %ovl, 5)
- except UnknownOverlayException as error:
+ except UnknownOverlayException, error:
#self.output.debug("API.sync(); UnknownOverlayException selecting %s" %ovl, 5)
#self._error(str(error))
fatals.append((ovl,
@@ -363,7 +363,7 @@ class LaymanAPI(object):
self.output.debug("API.sync(); starting db.sync(ovl)", 5)
db.sync(ovl, self.config['quiet'])
success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))
- except Exception as error:
+ except Exception, error:
fatals.append((ovl,
'Failed to sync overlay "' + ovl + '".\nError was: '
+ str(error)))
@@ -449,7 +449,7 @@ class LaymanAPI(object):
self.output.debug(
'LaymanAPI.fetch_remote_list(); cache updated = %s'
% str(dbreload),8)
- except Exception as error:
+ except Exception, error:
self.output.error('Failed to fetch overlay list!\n Original Error was: '
+ str(error))
return False
diff --git a/layman/argsparser.py b/layman/argsparser.py
index af95901..8f0b45b 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -20,7 +20,6 @@
#
'''Defines the configuration options and provides parsing functionality.'''
-from __future__ import print_function
__version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
diff --git a/layman/cli.py b/layman/cli.py
index 53d81c6..95ec858 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -166,7 +166,7 @@ class Main(object):
try:
new_umask = int(umask, 8)
old_umask = os.umask(new_umask)
- except Exception as error:
+ except Exception, error:
self.output.die('Failed setting to umask "' + umask +
'"!\nError was: ' + str(error))
diff --git a/layman/db.py b/layman/db.py
index 05da83d..d9a558e 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -16,6 +16,8 @@
#
'''Handles different storage files.'''
+from __future__ import with_statement
+
__version__ = "$Id: db.py 309 2007-04-09 16:23:38Z wrobel $"
#===============================================================================
@@ -326,7 +328,7 @@ class RemoteDB(DbBase):
timestamp = connection.headers['date']
else:
timestamp = None
- except urllib2.HTTPError as e:
+ except urllib2.HTTPError, e:
if e.getcode() == 304:
self.output.info('Remote list already up to date: %s'
% url, 4)
@@ -335,7 +337,7 @@ class RemoteDB(DbBase):
self.output.info('RemoteDB.cache(); HTTPError was:\n %s'
% str(e))
continue
- except IOError as error:
+ except IOError, error:
self.output.warn('RemoteDB.cache(); Failed to update the overlay list from: '
+ url + '\nIOError was:\n' + str(error))
else:
@@ -353,7 +355,7 @@ class RemoteDB(DbBase):
if not os.path.exists(os.path.dirname(mpath)):
try:
os.makedirs(os.path.dirname(mpath))
- except OSError as error:
+ except OSError, error:
raise OSError('Failed to create layman storage direct'
+ 'ory ' + os.path.dirname(mpath) + '\n'
+ 'Error was:' + str(error))
@@ -362,7 +364,7 @@ class RemoteDB(DbBase):
# file is intact and can be parsed
try:
self.read(olist, origin=url)
- except Exception as error:
+ except Exception, error:
raise IOError('Failed to parse the overlays list fetched fr'
'om ' + url + '\nThis means that the download'
'ed file is somehow corrupt or there was a pr'
@@ -382,7 +384,7 @@ class RemoteDB(DbBase):
has_updates = True
- except Exception as error:
+ except Exception, error:
raise IOError('Failed to temporarily cache overlays list in'
' ' + mpath + '\nError was:\n' + str(error))
return has_updates
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 8eafbf7..45be724 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -116,7 +116,7 @@ class DbBase(object):
try:
document = open(path, 'r').read()
- except Exception as error:
+ except Exception, error:
if not ignore_init_read_errors:
self.output.error('Failed to read the overlay list at ("'
+ path + '")')
@@ -148,14 +148,14 @@ class DbBase(object):
'''
try:
document = ET.fromstring(text)
- except xml.parsers.expat.ExpatError as error:
+ except xml.parsers.expat.ExpatError, error:
raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint())
overlays = document.findall('overlay') + \
document.findall('repo')
for overlay in overlays:
- self.output.debug('Parsing overlay entry', 8)
+ self.output.debug('Parsing overlay: %s' % overlay, 9)
ovl = Overlay(config=self.config, xml=overlay,
ignore=self.ignore, quiet=self.quiet)
self.overlays[ovl.name] = ovl
@@ -220,7 +220,7 @@ class DbBase(object):
""")
tree.write(f, encoding='utf-8')
f.close()
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to write to local overlays file: '
+ path + '\nError was:\n' + str(error))
diff --git a/layman/makeconf.py b/layman/makeconf.py
index 1dd2b56..b6f5d90 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -257,7 +257,7 @@ class MakeConf:
make_conf.close()
- except Exception as error:
+ except Exception, error:
self.output.error('MakeConf: write(); Failed to write "'
+ self.path + '".\nError was:\n' + str(error))
return False
@@ -274,7 +274,7 @@ class MakeConf:
make_conf.close()
- except Exception as error:
+ except Exception, error:
self.output.error('MakeConf: content(); Failed to read "' +
self.path + '".\nError was:\n' + str(error))
raise error
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 2e900e8..a14aa99 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -413,7 +413,7 @@ class Overlay(object):
# Worked, throw other sources away
self.sources = [s]
break
- except Exception as error:
+ except Exception, error:
self.output.warn(str(error), 4)
first_s = False
return res
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 71e75fc..3e685e2 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -177,7 +177,7 @@ class OverlaySource(object):
self.output.warn("Checking for cleanup actions to perform", 4)
self.cleanup()
result = 1
- except Exception as err:
+ except Exception, err:
self.output.error(
'Unknown exception running command: %s' % command_repr, 2)
self.output.error('Original error was: %s' % str(err), 2)
@@ -205,7 +205,7 @@ class OverlaySource(object):
kwargs.get('cwd', '')).split()
command = _opt[0]
args = _opt[1:]
- return self.run_command(command, *args,
+ return self.run_command(command, args,
cmd='%s_postsync' % self.__class__.type_key)
return failed_sync
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 7be2ed2..f061ad6 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -111,7 +111,7 @@ class TarOverlay(OverlaySource):
try:
tar = urllib2.urlopen(tar_url).read()
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to fetch the tar package from: '
+ self.src + '\nError was:' + str(error))
@@ -121,7 +121,7 @@ class TarOverlay(OverlaySource):
out_file = open(pkg, 'w')
out_file.write(tar)
out_file.close()
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to store tar package in '
+ pkg + '\nError was:' + str(error))
@@ -140,7 +140,7 @@ class TarOverlay(OverlaySource):
try:
self.output.info('Deleting directory "%s"' % folder, 2)
shutil.rmtree(folder)
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to remove unnecessary tar structure "'
+ folder + '"\nError was:' + str(error))
@@ -149,7 +149,7 @@ class TarOverlay(OverlaySource):
try:
result = self._extract(base=base, tar_url=self.src,
dest_dir=temp_path)
- except Exception as error:
+ except Exception, error:
try_to_wipe(temp_path)
raise error
@@ -165,7 +165,7 @@ class TarOverlay(OverlaySource):
try:
os.rename(source, final_path)
- except Exception as error:
+ except Exception, error:
raise Exception('Failed to rename tar subdirectory ' +
source + ' to ' + final_path +
'\nError was:' + str(error))
diff --git a/layman/utils.py b/layman/utils.py
index e38ea7c..eedc5d7 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -167,7 +167,7 @@ def delete_empty_directory(mdir, output=OUT):
output.info('Deleting _empty_ directory "%s"' % mdir, 2)
try:
os.rmdir(mdir)
- except OSError as error:
+ except OSError, error:
output.warn(str(error))
else:
output.warn('Insufficient permissions to delete _empty_ folder "%s".' % mdir)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-08-21 16:42 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-08-21 16:42 UTC (permalink / raw
To: gentoo-commits
commit: c1b4c34bad86d4b4208ebdfa37cb55b96f16450a
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Aug 21 09:19:09 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 21 09:19:09 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c1b4c34b
clean out nearly useless quiet parameter, use config['quiet'] instead.
---
layman/api.py | 4 ++--
layman/db.py | 16 ++++++++--------
layman/dbbase.py | 7 +++----
layman/overlays/bzr.py | 8 ++++----
layman/overlays/cvs.py | 12 ++++++------
layman/overlays/darcs.py | 8 ++++----
layman/overlays/g_common.py | 10 +++++-----
layman/overlays/git.py | 12 ++++++------
layman/overlays/mercurial.py | 8 ++++----
layman/overlays/overlay.py | 23 +++++++++++------------
layman/overlays/rsync.py | 10 +++++-----
layman/overlays/source.py | 18 +++++++++---------
layman/overlays/svn.py | 12 ++++++------
layman/overlays/tar.py | 16 ++++++++--------
14 files changed, 81 insertions(+), 83 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 7894c56..5e624d1 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -146,7 +146,7 @@ class LaymanAPI(object):
success = False
try:
success = self._get_installed_db().add(
- self._get_remote_db().select(ovl), quiet=True)
+ self._get_remote_db().select(ovl))
except Exception, e:
self._error("Exception caught enabling repository '"+ovl+
"' : "+str(e))
@@ -357,7 +357,7 @@ class LaymanAPI(object):
try:
self.output.debug("API.sync(); starting db.sync(ovl)", 5)
- db.sync(ovl, self.config['quiet'])
+ db.sync(ovl)
success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))
except Exception, error:
fatals.append((ovl,
diff --git a/layman/db.py b/layman/db.py
index 08af0f6..17453b8 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -59,13 +59,13 @@ class DB(DbBase):
else:
ignore = 1
- quiet = int(config['quietness']) < 3
+ #quiet = int(config['quietness']) < 3
DbBase.__init__(self,
config,
paths=[config['local_list'], ],
ignore=ignore,
- quiet=quiet)
+ )
self.output.debug('DB handler initiated', 6)
@@ -73,7 +73,7 @@ class DB(DbBase):
def _broken_catalog_hint(self):
return ''
- def add(self, overlay, quiet = False):
+ def add(self, overlay):
'''
Add an overlay to the local list of overlays.
@@ -121,7 +121,7 @@ class DB(DbBase):
'''
if overlay.name not in self.overlays.keys():
- result = overlay.add(self.config['storage'], quiet)
+ result = overlay.add(self.config['storage'])
if result == 0:
if 'priority' in self.config.keys():
overlay.set_priority(self.config['priority'])
@@ -218,11 +218,11 @@ class DB(DbBase):
return False
return True
- def sync(self, overlay_name, quiet = False):
+ def sync(self, overlay_name):
'''Synchronize the given overlay.'''
overlay = self.select(overlay_name)
- result = overlay.sync(self.config['storage'], quiet)
+ result = overlay.sync(self.config['storage'])
if result:
raise Exception('Syncing overlay "' + overlay_name +
'" returned status ' + str(result) + '!' +
@@ -263,10 +263,10 @@ class RemoteDB(DbBase):
else:
ignore = 0
- quiet = int(config['quietness']) < 3
+ #quiet = int(config['quietness']) < 3
DbBase.__init__(self, config, paths=paths, ignore=ignore,
- quiet=quiet, ignore_init_read_errors=ignore_init_read_errors)
+ ignore_init_read_errors=ignore_init_read_errors)
# overrider
def _broken_catalog_hint(self):
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 45be724..a31ced9 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -79,11 +79,10 @@ class DbBase(object):
''' Handle a list of overlays.'''
def __init__(self, config, paths=None, ignore = 0,
- quiet = False, ignore_init_read_errors=False
+ ignore_init_read_errors=False
):
self.config = config
- self.quiet = quiet
self.paths = paths
self.ignore = ignore
self.output = config['output']
@@ -157,7 +156,7 @@ class DbBase(object):
for overlay in overlays:
self.output.debug('Parsing overlay: %s' % overlay, 9)
ovl = Overlay(config=self.config, xml=overlay,
- ignore=self.ignore, quiet=self.quiet)
+ ignore=self.ignore)
self.overlays[ovl.name] = ovl
return
@@ -184,7 +183,7 @@ class DbBase(object):
for overlay in overlays:
self.output.debug('Parsing overlay entry', 8)
ovl = Overlay(self.config, ovl_dict=overlay,
- ignore=self.ignore, quiet=self.quiet)
+ ignore=self.ignore)
self.overlays[ovl.name] = ovl
return
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 40e5b81..0fbd712 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -41,13 +41,13 @@ class BzrOverlay(OverlaySource):
type = 'Bzr'
type_key = 'bzr'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(BzrOverlay, self).__init__(parent,
- config, _location, ignore, quiet)
+ config, _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -66,7 +66,7 @@ class BzrOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index c902250..883baa3 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -41,9 +41,9 @@ class CvsOverlay(OverlaySource):
type = 'cvs'
type_key = 'cvs'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
- super(CvsOverlay, self).__init__(parent, config, _location, ignore, quiet)
+ super(CvsOverlay, self).__init__(parent, config, _location, ignore)
self.subpath = None
@@ -63,7 +63,7 @@ class CvsOverlay(OverlaySource):
repo_elem.append(_subpath)
del _subpath
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -74,7 +74,7 @@ class CvsOverlay(OverlaySource):
# cvs [-q] co -d SOURCE SCOPE
args = []
- if quiet:
+ if self.config['quiet']:
args.append('-q')
args.append('co')
args.append('-d')
@@ -88,7 +88,7 @@ class CvsOverlay(OverlaySource):
env=dict(CVSROOT=self.src), cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -99,7 +99,7 @@ class CvsOverlay(OverlaySource):
# cvs [-q] update -d
args = []
- if quiet:
+ if self.config['quiet']:
args.append('-q')
args.append('update')
args.append('-d')
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 3e24ebe..d3eec6a 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -40,13 +40,13 @@ class DarcsOverlay(OverlaySource):
type = 'Darcs'
type_key = 'darcs'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(DarcsOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -67,7 +67,7 @@ class DarcsOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index cb162e8..5f0e9bc 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -38,15 +38,15 @@ class GCommonOverlay(OverlaySource):
type = 'g-common'
type_key = 'g-common'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(GCommonOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
#split source into driver and remote uri.
self.driver=self.src[:self.src.find(' ')]
self.remote_uri=self.src[self.src.find(' ')+1:]
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -56,9 +56,9 @@ class GCommonOverlay(OverlaySource):
os.makedirs(target)
- return self.sync(base, quiet)
+ return self.sync(base)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 64a0dfb..3cdc21e 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -39,12 +39,12 @@ class GitOverlay(OverlaySource):
type = 'Git'
type_key = 'git'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(GitOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -61,7 +61,7 @@ class GitOverlay(OverlaySource):
# git clone [-q] SOURCE TARGET
args = ['clone']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
@@ -71,7 +71,7 @@ class GitOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
self.output.debug("git.sync(); starting...%s" % self.parent.name, 6)
@@ -82,7 +82,7 @@ class GitOverlay(OverlaySource):
target = path([base, self.parent.name])
args = ['pull']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 5247e78..0d8250e 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -41,13 +41,13 @@ class MercurialOverlay(OverlaySource):
type_key = 'mercurial'
def __init__(self, parent, config,
- _location, ignore = 0, quiet = False):
+ _location, ignore = 0):
super(MercurialOverlay, self).__init__(parent,
- config, _location, ignore, quiet)
+ config, _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -66,7 +66,7 @@ class MercurialOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index a14aa99..7eb76bb 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -73,8 +73,7 @@ class Overlay(object):
''' Derive the real implementations from this.'''
def __init__(self, config, xml=None, ovl_dict=None,
- ignore = 0, quiet = False
- ):
+ ignore = 0):
'''
>>> here = os.path.dirname(os.path.realpath(__file__))
>>> import xml.etree.ElementTree as ET # Python 2.5
@@ -104,12 +103,12 @@ class Overlay(object):
self._encoding_ = get_encoding(self.output)
if xml is not None:
- self.from_xml(xml, ignore, quiet)
+ self.from_xml(xml, ignore)
elif ovl_dict is not None:
- self.from_dict(ovl_dict, ignore, quiet)
+ self.from_dict(ovl_dict, ignore)
- def from_xml(self, xml, ignore, quiet):
+ def from_xml(self, xml, ignore):
"""Process an xml overlay definition
"""
def strip_text(node):
@@ -147,7 +146,7 @@ class Overlay(object):
'Unknown overlay type "%s"!' % _type)
_location = ensure_unicode(strip_text(source_elem))
return _class(parent=self, config=self.config,
- _location=_location, ignore=ignore, quiet=quiet)
+ _location=_location, ignore=ignore)
if not len(_sources):
raise Exception('Overlay from_xml(), "' + self.name + \
@@ -236,7 +235,7 @@ class Overlay(object):
self.irc = None
- def from_dict(self, overlay, ignore, quiet):
+ def from_dict(self, overlay, ignore):
"""Process an xml overlay definition
"""
self.output.debug("Overlay from_dict(); overlay" + str(overlay))
@@ -262,7 +261,7 @@ class Overlay(object):
'Unknown overlay type "%s"!' % _type)
_location = ensure_unicode(_src)
return _class(parent=self, config=self.config,
- _location=_location, ignore=ignore, quiet=quiet)
+ _location=_location, ignore=ignore)
self.sources = [create_dict_overlay_source(e) for e in _sources]
@@ -401,14 +400,14 @@ class Overlay(object):
return repo
- def add(self, base, quiet = False):
+ def add(self, base):
res = 1
first_s = True
for s in self.sources:
if not first_s:
self.output.info("\nTrying next source of listed sources...", 4)
try:
- res = s.add(base, quiet)
+ res = s.add(base)
if res == 0:
# Worked, throw other sources away
self.sources = [s]
@@ -419,10 +418,10 @@ class Overlay(object):
return res
- def sync(self, base, quiet = False):
+ def sync(self, base):
self.output.debug("overlay.sync(); name = %s" % self.name, 4)
assert len(self.sources) == 1
- return self.sources[0].sync(base, quiet)
+ return self.sources[0].sync(base)
def delete(self, base):
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 3c03ae2..f87a7e0 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -40,13 +40,13 @@ class RsyncOverlay(OverlaySource):
type_key = 'rsync'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(RsyncOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -56,7 +56,7 @@ class RsyncOverlay(OverlaySource):
return self.sync(base)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -70,7 +70,7 @@ class RsyncOverlay(OverlaySource):
cfg_opts = self.config["rsync_syncopts"]
target = path([base, self.parent.name])
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 3e685e2..22e55ca 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -66,12 +66,11 @@ class OverlaySource(object):
type_key = None
def __init__(self, parent, config, _location,
- ignore = 0, quiet = False):
+ ignore = 0):
self.parent = parent
self.src = _location
self.config = config
self.ignore = ignore
- self.quiet = quiet
self.output = config['output']
@@ -81,7 +80,7 @@ class OverlaySource(object):
def __ne__(self, other):
return not self.__eq__(other)
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add the overlay.'''
mdir = path([base, self.parent.name])
@@ -94,7 +93,7 @@ class OverlaySource(object):
os.makedirs(mdir)
return True
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync the overlay.'''
pass
@@ -151,13 +150,14 @@ class OverlaySource(object):
cmd = kwargs.get('cmd', '')
self.output.info('Running %s... # %s' % (cmd, command_repr), 2)
- if self.quiet:
+ if self.config['quiet']:
+
input_source = subprocess.PIPE
output_target = open('/dev/null', 'w')
else:
# Re-use parent file descriptors
- input_source = None
- output_target = None
+ input_source = self.config['stdin']
+ output_target = self.config['stdout']
proc = subprocess.Popen(args,
stdin=input_source,
@@ -166,7 +166,7 @@ class OverlaySource(object):
cwd=cwd,
env=env)
- if self.quiet:
+ if self.config['quiet']:
# Make child non-interactive
proc.stdin.close()
@@ -183,7 +183,7 @@ class OverlaySource(object):
self.output.error('Original error was: %s' % str(err), 2)
result = 1
- if self.quiet:
+ if self.config['quiet']:
output_target.close()
if result:
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index b9a5a34..3e5497c 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -40,13 +40,13 @@ class SvnOverlay(OverlaySource):
type_key = 'svn'
def __init__(self, parent, config, _location,
- ignore = 0, quiet = False):
+ ignore = 0):
super(SvnOverlay, self).__init__(
- parent, config, _location, ignore, quiet)
+ parent, config, _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -58,7 +58,7 @@ class SvnOverlay(OverlaySource):
self.target = path([base, self.parent.name])
args = ['co']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
@@ -69,7 +69,7 @@ class SvnOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=self.target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -88,7 +88,7 @@ class SvnOverlay(OverlaySource):
# svn up [-q] TARGET
args = ['up']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index f061ad6..6fd5ba8 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -62,7 +62,7 @@ class TarOverlay(OverlaySource):
>>> testdir = os.tmpnam()
>>> os.mkdir(testdir)
>>> from layman.overlays.overlay import Overlay
- >>> a = Overlay(config, repo, quiet=False)
+ >>> a = Overlay(config, repo)
>>> config['output'].set_colorize(False)
>>> a.add(testdir)
0
@@ -76,10 +76,10 @@ class TarOverlay(OverlaySource):
type = 'Tar'
type_key = 'tar'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(TarOverlay, self).__init__(parent,
- config, _location, ignore, quiet)
+ config, _location, ignore)
self.output = config['output']
self.subpath = None
@@ -132,7 +132,7 @@ class TarOverlay(OverlaySource):
os.unlink(pkg)
return result
- def _add_unchecked(self, base, quiet):
+ def _add_unchecked(self, base):
def try_to_wipe(folder):
if not os.path.exists(folder):
return
@@ -177,7 +177,7 @@ class TarOverlay(OverlaySource):
try_to_wipe(temp_path)
return result
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -190,10 +190,10 @@ class TarOverlay(OverlaySource):
' Will not overwrite its contents!')
return self.postsync(
- self._add_unchecked(base, quiet),
+ self._add_unchecked(base),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -202,7 +202,7 @@ class TarOverlay(OverlaySource):
target = path([base, self.parent.name])
return self.postsync(
- self._add_unchecked(base, quiet),
+ self._add_unchecked(base),
cwd=target)
def supported(self):
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-08-24 14:02 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-08-24 14:02 UTC (permalink / raw
To: gentoo-commits
commit: fb629bea7f7c19790078ec0b72acc7671f1ae2f3
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Aug 21 09:19:09 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Aug 24 14:01:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fb629bea
clean out nearly useless quiet parameter, use config['quiet'] instead.
---
layman/api.py | 4 ++--
layman/db.py | 16 ++++++++--------
layman/dbbase.py | 7 +++----
layman/overlays/bzr.py | 8 ++++----
layman/overlays/cvs.py | 12 ++++++------
layman/overlays/darcs.py | 8 ++++----
layman/overlays/g_common.py | 10 +++++-----
layman/overlays/git.py | 12 ++++++------
layman/overlays/mercurial.py | 8 ++++----
layman/overlays/overlay.py | 23 +++++++++++------------
layman/overlays/rsync.py | 10 +++++-----
layman/overlays/source.py | 14 +++++++-------
layman/overlays/svn.py | 12 ++++++------
layman/overlays/tar.py | 16 ++++++++--------
14 files changed, 79 insertions(+), 81 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 7894c56..5e624d1 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -146,7 +146,7 @@ class LaymanAPI(object):
success = False
try:
success = self._get_installed_db().add(
- self._get_remote_db().select(ovl), quiet=True)
+ self._get_remote_db().select(ovl))
except Exception, e:
self._error("Exception caught enabling repository '"+ovl+
"' : "+str(e))
@@ -357,7 +357,7 @@ class LaymanAPI(object):
try:
self.output.debug("API.sync(); starting db.sync(ovl)", 5)
- db.sync(ovl, self.config['quiet'])
+ db.sync(ovl)
success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))
except Exception, error:
fatals.append((ovl,
diff --git a/layman/db.py b/layman/db.py
index 08af0f6..17453b8 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -59,13 +59,13 @@ class DB(DbBase):
else:
ignore = 1
- quiet = int(config['quietness']) < 3
+ #quiet = int(config['quietness']) < 3
DbBase.__init__(self,
config,
paths=[config['local_list'], ],
ignore=ignore,
- quiet=quiet)
+ )
self.output.debug('DB handler initiated', 6)
@@ -73,7 +73,7 @@ class DB(DbBase):
def _broken_catalog_hint(self):
return ''
- def add(self, overlay, quiet = False):
+ def add(self, overlay):
'''
Add an overlay to the local list of overlays.
@@ -121,7 +121,7 @@ class DB(DbBase):
'''
if overlay.name not in self.overlays.keys():
- result = overlay.add(self.config['storage'], quiet)
+ result = overlay.add(self.config['storage'])
if result == 0:
if 'priority' in self.config.keys():
overlay.set_priority(self.config['priority'])
@@ -218,11 +218,11 @@ class DB(DbBase):
return False
return True
- def sync(self, overlay_name, quiet = False):
+ def sync(self, overlay_name):
'''Synchronize the given overlay.'''
overlay = self.select(overlay_name)
- result = overlay.sync(self.config['storage'], quiet)
+ result = overlay.sync(self.config['storage'])
if result:
raise Exception('Syncing overlay "' + overlay_name +
'" returned status ' + str(result) + '!' +
@@ -263,10 +263,10 @@ class RemoteDB(DbBase):
else:
ignore = 0
- quiet = int(config['quietness']) < 3
+ #quiet = int(config['quietness']) < 3
DbBase.__init__(self, config, paths=paths, ignore=ignore,
- quiet=quiet, ignore_init_read_errors=ignore_init_read_errors)
+ ignore_init_read_errors=ignore_init_read_errors)
# overrider
def _broken_catalog_hint(self):
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 45be724..a31ced9 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -79,11 +79,10 @@ class DbBase(object):
''' Handle a list of overlays.'''
def __init__(self, config, paths=None, ignore = 0,
- quiet = False, ignore_init_read_errors=False
+ ignore_init_read_errors=False
):
self.config = config
- self.quiet = quiet
self.paths = paths
self.ignore = ignore
self.output = config['output']
@@ -157,7 +156,7 @@ class DbBase(object):
for overlay in overlays:
self.output.debug('Parsing overlay: %s' % overlay, 9)
ovl = Overlay(config=self.config, xml=overlay,
- ignore=self.ignore, quiet=self.quiet)
+ ignore=self.ignore)
self.overlays[ovl.name] = ovl
return
@@ -184,7 +183,7 @@ class DbBase(object):
for overlay in overlays:
self.output.debug('Parsing overlay entry', 8)
ovl = Overlay(self.config, ovl_dict=overlay,
- ignore=self.ignore, quiet=self.quiet)
+ ignore=self.ignore)
self.overlays[ovl.name] = ovl
return
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 40e5b81..0fbd712 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -41,13 +41,13 @@ class BzrOverlay(OverlaySource):
type = 'Bzr'
type_key = 'bzr'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(BzrOverlay, self).__init__(parent,
- config, _location, ignore, quiet)
+ config, _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -66,7 +66,7 @@ class BzrOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index c902250..883baa3 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -41,9 +41,9 @@ class CvsOverlay(OverlaySource):
type = 'cvs'
type_key = 'cvs'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
- super(CvsOverlay, self).__init__(parent, config, _location, ignore, quiet)
+ super(CvsOverlay, self).__init__(parent, config, _location, ignore)
self.subpath = None
@@ -63,7 +63,7 @@ class CvsOverlay(OverlaySource):
repo_elem.append(_subpath)
del _subpath
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -74,7 +74,7 @@ class CvsOverlay(OverlaySource):
# cvs [-q] co -d SOURCE SCOPE
args = []
- if quiet:
+ if self.config['quiet']:
args.append('-q')
args.append('co')
args.append('-d')
@@ -88,7 +88,7 @@ class CvsOverlay(OverlaySource):
env=dict(CVSROOT=self.src), cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -99,7 +99,7 @@ class CvsOverlay(OverlaySource):
# cvs [-q] update -d
args = []
- if quiet:
+ if self.config['quiet']:
args.append('-q')
args.append('update')
args.append('-d')
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 3e24ebe..d3eec6a 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -40,13 +40,13 @@ class DarcsOverlay(OverlaySource):
type = 'Darcs'
type_key = 'darcs'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(DarcsOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -67,7 +67,7 @@ class DarcsOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index cb162e8..5f0e9bc 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -38,15 +38,15 @@ class GCommonOverlay(OverlaySource):
type = 'g-common'
type_key = 'g-common'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(GCommonOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
#split source into driver and remote uri.
self.driver=self.src[:self.src.find(' ')]
self.remote_uri=self.src[self.src.find(' ')+1:]
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -56,9 +56,9 @@ class GCommonOverlay(OverlaySource):
os.makedirs(target)
- return self.sync(base, quiet)
+ return self.sync(base)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 64a0dfb..3cdc21e 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -39,12 +39,12 @@ class GitOverlay(OverlaySource):
type = 'Git'
type_key = 'git'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(GitOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -61,7 +61,7 @@ class GitOverlay(OverlaySource):
# git clone [-q] SOURCE TARGET
args = ['clone']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
@@ -71,7 +71,7 @@ class GitOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
self.output.debug("git.sync(); starting...%s" % self.parent.name, 6)
@@ -82,7 +82,7 @@ class GitOverlay(OverlaySource):
target = path([base, self.parent.name])
args = ['pull']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 5247e78..0d8250e 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -41,13 +41,13 @@ class MercurialOverlay(OverlaySource):
type_key = 'mercurial'
def __init__(self, parent, config,
- _location, ignore = 0, quiet = False):
+ _location, ignore = 0):
super(MercurialOverlay, self).__init__(parent,
- config, _location, ignore, quiet)
+ config, _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -66,7 +66,7 @@ class MercurialOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index a14aa99..7eb76bb 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -73,8 +73,7 @@ class Overlay(object):
''' Derive the real implementations from this.'''
def __init__(self, config, xml=None, ovl_dict=None,
- ignore = 0, quiet = False
- ):
+ ignore = 0):
'''
>>> here = os.path.dirname(os.path.realpath(__file__))
>>> import xml.etree.ElementTree as ET # Python 2.5
@@ -104,12 +103,12 @@ class Overlay(object):
self._encoding_ = get_encoding(self.output)
if xml is not None:
- self.from_xml(xml, ignore, quiet)
+ self.from_xml(xml, ignore)
elif ovl_dict is not None:
- self.from_dict(ovl_dict, ignore, quiet)
+ self.from_dict(ovl_dict, ignore)
- def from_xml(self, xml, ignore, quiet):
+ def from_xml(self, xml, ignore):
"""Process an xml overlay definition
"""
def strip_text(node):
@@ -147,7 +146,7 @@ class Overlay(object):
'Unknown overlay type "%s"!' % _type)
_location = ensure_unicode(strip_text(source_elem))
return _class(parent=self, config=self.config,
- _location=_location, ignore=ignore, quiet=quiet)
+ _location=_location, ignore=ignore)
if not len(_sources):
raise Exception('Overlay from_xml(), "' + self.name + \
@@ -236,7 +235,7 @@ class Overlay(object):
self.irc = None
- def from_dict(self, overlay, ignore, quiet):
+ def from_dict(self, overlay, ignore):
"""Process an xml overlay definition
"""
self.output.debug("Overlay from_dict(); overlay" + str(overlay))
@@ -262,7 +261,7 @@ class Overlay(object):
'Unknown overlay type "%s"!' % _type)
_location = ensure_unicode(_src)
return _class(parent=self, config=self.config,
- _location=_location, ignore=ignore, quiet=quiet)
+ _location=_location, ignore=ignore)
self.sources = [create_dict_overlay_source(e) for e in _sources]
@@ -401,14 +400,14 @@ class Overlay(object):
return repo
- def add(self, base, quiet = False):
+ def add(self, base):
res = 1
first_s = True
for s in self.sources:
if not first_s:
self.output.info("\nTrying next source of listed sources...", 4)
try:
- res = s.add(base, quiet)
+ res = s.add(base)
if res == 0:
# Worked, throw other sources away
self.sources = [s]
@@ -419,10 +418,10 @@ class Overlay(object):
return res
- def sync(self, base, quiet = False):
+ def sync(self, base):
self.output.debug("overlay.sync(); name = %s" % self.name, 4)
assert len(self.sources) == 1
- return self.sources[0].sync(base, quiet)
+ return self.sources[0].sync(base)
def delete(self, base):
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 3c03ae2..f87a7e0 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -40,13 +40,13 @@ class RsyncOverlay(OverlaySource):
type_key = 'rsync'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(RsyncOverlay, self).__init__(parent, config,
- _location, ignore, quiet)
+ _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -56,7 +56,7 @@ class RsyncOverlay(OverlaySource):
return self.sync(base)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -70,7 +70,7 @@ class RsyncOverlay(OverlaySource):
cfg_opts = self.config["rsync_syncopts"]
target = path([base, self.parent.name])
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 3e685e2..03bccc4 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -66,12 +66,11 @@ class OverlaySource(object):
type_key = None
def __init__(self, parent, config, _location,
- ignore = 0, quiet = False):
+ ignore = 0):
self.parent = parent
self.src = _location
self.config = config
self.ignore = ignore
- self.quiet = quiet
self.output = config['output']
@@ -81,7 +80,7 @@ class OverlaySource(object):
def __ne__(self, other):
return not self.__eq__(other)
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add the overlay.'''
mdir = path([base, self.parent.name])
@@ -94,7 +93,7 @@ class OverlaySource(object):
os.makedirs(mdir)
return True
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync the overlay.'''
pass
@@ -151,7 +150,8 @@ class OverlaySource(object):
cmd = kwargs.get('cmd', '')
self.output.info('Running %s... # %s' % (cmd, command_repr), 2)
- if self.quiet:
+ if self.config['quiet']:
+
input_source = subprocess.PIPE
output_target = open('/dev/null', 'w')
else:
@@ -166,7 +166,7 @@ class OverlaySource(object):
cwd=cwd,
env=env)
- if self.quiet:
+ if self.config['quiet']:
# Make child non-interactive
proc.stdin.close()
@@ -183,7 +183,7 @@ class OverlaySource(object):
self.output.error('Original error was: %s' % str(err), 2)
result = 1
- if self.quiet:
+ if self.config['quiet']:
output_target.close()
if result:
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index b9a5a34..3e5497c 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -40,13 +40,13 @@ class SvnOverlay(OverlaySource):
type_key = 'svn'
def __init__(self, parent, config, _location,
- ignore = 0, quiet = False):
+ ignore = 0):
super(SvnOverlay, self).__init__(
- parent, config, _location, ignore, quiet)
+ parent, config, _location, ignore)
self.subpath = None
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -58,7 +58,7 @@ class SvnOverlay(OverlaySource):
self.target = path([base, self.parent.name])
args = ['co']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
@@ -69,7 +69,7 @@ class SvnOverlay(OverlaySource):
self.run_command(self.command(), args, cmd=self.type),
cwd=self.target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -88,7 +88,7 @@ class SvnOverlay(OverlaySource):
# svn up [-q] TARGET
args = ['up']
- if quiet:
+ if self.config['quiet']:
args.append('-q')
if len(cfg_opts):
args.append(cfg_opts)
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index f061ad6..6fd5ba8 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -62,7 +62,7 @@ class TarOverlay(OverlaySource):
>>> testdir = os.tmpnam()
>>> os.mkdir(testdir)
>>> from layman.overlays.overlay import Overlay
- >>> a = Overlay(config, repo, quiet=False)
+ >>> a = Overlay(config, repo)
>>> config['output'].set_colorize(False)
>>> a.add(testdir)
0
@@ -76,10 +76,10 @@ class TarOverlay(OverlaySource):
type = 'Tar'
type_key = 'tar'
- def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+ def __init__(self, parent, config, _location, ignore = 0):
super(TarOverlay, self).__init__(parent,
- config, _location, ignore, quiet)
+ config, _location, ignore)
self.output = config['output']
self.subpath = None
@@ -132,7 +132,7 @@ class TarOverlay(OverlaySource):
os.unlink(pkg)
return result
- def _add_unchecked(self, base, quiet):
+ def _add_unchecked(self, base):
def try_to_wipe(folder):
if not os.path.exists(folder):
return
@@ -177,7 +177,7 @@ class TarOverlay(OverlaySource):
try_to_wipe(temp_path)
return result
- def add(self, base, quiet = False):
+ def add(self, base):
'''Add overlay.'''
if not self.supported():
@@ -190,10 +190,10 @@ class TarOverlay(OverlaySource):
' Will not overwrite its contents!')
return self.postsync(
- self._add_unchecked(base, quiet),
+ self._add_unchecked(base),
cwd=target)
- def sync(self, base, quiet = False):
+ def sync(self, base):
'''Sync overlay.'''
if not self.supported():
@@ -202,7 +202,7 @@ class TarOverlay(OverlaySource):
target = path([base, self.parent.name])
return self.postsync(
- self._add_unchecked(base, quiet),
+ self._add_unchecked(base),
cwd=target)
def supported(self):
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2011-09-24 6:07 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2011-09-24 6:07 UTC (permalink / raw
To: gentoo-commits
commit: f3e1976da8eeef942a95019669633255fa3b6c50
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Sep 19 06:22:15 2011 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 23 03:12:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f3e1976d
py2, py3 compatability changes so 2to3 will work correctly.
---
layman/api.py | 6 +++-
layman/compatibility.py | 29 +++++++++++++++++++++++
layman/db.py | 26 +++++++++++++--------
layman/dbbase.py | 6 +++-
layman/output.py | 25 ++++++++++---------
layman/overlays/cvs.py | 2 +-
layman/overlays/overlay.py | 54 ++++++++++++++++++++++----------------------
layman/overlays/tar.py | 2 +-
layman/utils.py | 16 ++++---------
9 files changed, 100 insertions(+), 66 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 5e624d1..c1a0e97 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -22,6 +22,8 @@ from layman.dbbase import UnknownOverlayException, UnknownOverlayMessage
from layman.db import DB, RemoteDB
from layman.overlays.source import require_supported
#from layman.utils import path, delete_empty_directory
+from layman.compatibility import encode, fileopen
+
UNKNOWN_REPO_ID = "Repo ID '%s' " + \
"is not listed in the current available overlays list"
@@ -91,7 +93,7 @@ class LaymanAPI(object):
if isinstance(repos, basestring):
repos = [repos]
# else assume it is an iterable, if not it will error
- return repos
+ return [encode(i) for i in repos]
def delete_repos(self, repos):
@@ -411,7 +413,7 @@ class LaymanAPI(object):
>>> api.get_errors()
[]
>>> filename = api._get_remote_db().filepath(config['overlays'])+'.xml'
- >>> b = open(filename)
+ >>> b = fileopen(filename, 'r')
>>> b.readlines()[24]
' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].\\n'
diff --git a/layman/compatibility.py b/layman/compatibility.py
new file mode 100644
index 0000000..b71a8af
--- /dev/null
+++ b/layman/compatibility.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+""" Copyright 2005 - 2008 Gunnar Wrobel
+ 2011 - Brian Dolbec
+ Distributed under the terms of the GNU General Public License v2
+"""
+
+import sys, types
+
+
+def encode(text, enc="UTF-8"):
+ """py2, py3 compatibility function"""
+ if hasattr(text, 'decode'):
+ try:
+ return text.decode(enc)
+ except UnicodeEncodeError:
+ return unicode(text)
+ return str(text)
+
+
+def fileopen(path, mode='r', enc="UTF-8"):
+ """py2, py3 compatibility function"""
+ try:
+ f = open(path, mode, encoding=enc)
+ except TypeError:
+ f = open(path, mode)
+ return f
+
diff --git a/layman/db.py b/layman/db.py
index 49069b7..807a740 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -30,10 +30,11 @@ import os, os.path
import urllib2
import hashlib
-from layman.utils import path, delete_empty_directory
+from layman.utils import path, delete_empty_directory, encoder
from layman.dbbase import DbBase
from layman.makeconf import MakeConf
from layman.version import VERSION
+from layman.compatibility import fileopen
#from layman.debug import OUT
@@ -315,7 +316,7 @@ class RemoteDB(DbBase):
>>> a = RemoteDB(config)
>>> a.cache()
(True, True)
- >>> b = open(a.filepath(config['overlays'])+'.xml')
+ >>> b = fileopen(a.filepath(config['overlays'])+'.xml')
>>> b.readlines()[24]
' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].\\n'
@@ -341,7 +342,7 @@ class RemoteDB(DbBase):
opener.addheaders = [('User-Agent', 'Layman-' + VERSION)]
if os.path.exists(tpath):
- with open(tpath,'r') as previous:
+ with fileopen(tpath,'r') as previous:
timestamp = previous.read()
request.add_header('If-Modified-Since', timestamp)
@@ -350,10 +351,12 @@ class RemoteDB(DbBase):
try:
connection = opener.open(request)
- if 'last-modified' in connection.headers.keys():
- timestamp = connection.headers['last-modified']
- elif 'date' in connection.headers.keys():
- timestamp = connection.headers['date']
+ # py2, py3 compatibility, since only py2 returns keys as lower()
+ headers = dict((x.lower(), x) for x in connection.headers.keys())
+ if 'last-modified' in headers:
+ timestamp = connection.headers[headers['last-modified']]
+ elif 'date' in headers:
+ timestamp = connection.headers[headers['date']]
else:
timestamp = None
except urllib2.HTTPError, e:
@@ -406,12 +409,14 @@ class RemoteDB(DbBase):
# Ok, now we can overwrite the old cache
try:
- out_file = open(mpath, 'w')
+ out_file = fileopen(mpath, 'w')
+ if hasattr(olist, 'decode'):
+ olist = olist.decode("UTF-8")
out_file.write(olist)
out_file.close()
if timestamp is not None:
- out_file = open(tpath, 'w')
+ out_file = fileopen(tpath, 'w')
out_file.write(str(timestamp))
out_file.close()
@@ -431,8 +436,9 @@ class RemoteDB(DbBase):
base = self.config['cache']
self.output.debug('Generating cache path.', 6)
+ url_encoded = encoder(url, "UTF-8")
- return base + '_' + hashlib.md5(url).hexdigest()
+ return base + '_' + hashlib.md5(url_encoded).hexdigest()
def check_path(self, paths, hint=True):
diff --git a/layman/dbbase.py b/layman/dbbase.py
index ccd5806..149988b 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -34,6 +34,7 @@ import xml.etree.ElementTree as ET # Python 2.5
#from layman.debug import OUT
from layman.utils import indent
+from layman.compatibility import fileopen
from layman.overlays.overlay import Overlay
#===============================================================================
@@ -114,7 +115,8 @@ class DbBase(object):
'''Read the overlay definition file.'''
try:
- document = open(path, 'r').read()
+ df = fileopen(path, 'r')
+ document = df.read()
except Exception, error:
if not self.ignore_init_read_errors:
@@ -214,7 +216,7 @@ class DbBase(object):
indent(tree)
tree = ET.ElementTree(tree)
try:
- f = open(path, 'w')
+ f = fileopen(path, 'w')
f.write("""\
<?xml version="1.0" encoding="UTF-8"?>
""")
diff --git a/layman/output.py b/layman/output.py
index 37da0c5..7b42b81 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -13,6 +13,7 @@ __version__ = "0.1"
import sys, types
from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL, OFF
+from layman.compatibility import encode
class MessageBase(object):
@@ -110,8 +111,8 @@ class Message(MessageBase):
"""empty debug function, does nothing,
declared here for compatibility with DebugMessage
"""
- if type(info) not in types.StringTypes:
- info = str(info)
+ if type(info) != str:#not in types.StringTypes:
+ info = encode(info)
if level > self.debug_lev:
return
@@ -126,8 +127,8 @@ class Message(MessageBase):
def info (self, info, level = INFO_LEVEL):
- if type(info) not in types.StringTypes:
- info = str(info)
+ if type(info) != str:#not in types.StringTypes:
+ info = encode(info)
if level > self.info_lev:
return
@@ -138,8 +139,8 @@ class Message(MessageBase):
def status (self, message, status, info = 'ignored'):
- if type(message) not in types.StringTypes:
- message = str(message)
+ if type(message) != str:#not in types.StringTypes:
+ message = encode(message)
lines = message.split('\n')
@@ -167,8 +168,8 @@ class Message(MessageBase):
def warn (self, warn, level = WARN_LEVEL):
- if type(warn) not in types.StringTypes:
- warn = str(warn)
+ if type(warn) != str:#not in types.StringTypes:
+ warn = encode(warn)
if level > self.warn_lev:
return
@@ -179,8 +180,8 @@ class Message(MessageBase):
def error (self, error):
- if type(error) not in types.StringTypes:
- error = str(error)
+ if type(error) != str:#not in types.StringTypes:
+ error = encode(error)
for i in error.split('\n'):
# NOTE: Forced flushing ensures that stdout and stderr
@@ -195,8 +196,8 @@ class Message(MessageBase):
def die (self, error):
- if type(error) not in types.StringTypes:
- error = str(error)
+ if type(error) != str:#not in types.StringTypes:
+ error = encode(error)
for i in error.split('\n'):
self.error(self.color_func('red', 'Fatal error: ') + i)
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 883baa3..2bb6791 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -26,7 +26,7 @@ __version__ = "$Id$"
import xml.etree.ElementTree as ET # Python 2.5
-from layman.utils import path, ensure_unicode
+from layman.utils import path
from layman.overlays.source import OverlaySource, require_supported
#===============================================================================
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 7eb76bb..8eb0870 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -33,8 +33,8 @@ import codecs
import locale
import xml.etree.ElementTree as ET # Python 2.5
-from layman.utils import (pad, terminal_width, get_encoding, encoder,
- ensure_unicode)
+from layman.utils import pad, terminal_width, get_encoding, encoder
+from layman.compatibility import encode
from layman.overlays.bzr import BzrOverlay
from layman.overlays.darcs import DarcsOverlay
@@ -119,9 +119,9 @@ class Overlay(object):
_name = xml.find('name')
if _name != None:
- self.name = ensure_unicode(strip_text(_name))
+ self.name = encode(strip_text(_name))
elif 'name' in xml.attrib:
- self.name = ensure_unicode(xml.attrib['name'])
+ self.name = encode(xml.attrib['name'])
else:
raise Exception('Overlay from_xml(), "' + self.name + \
'is missing a "name" entry!')
@@ -144,7 +144,7 @@ class Overlay(object):
except KeyError:
raise Exception('Overlay from_xml(), "' + self.name + \
'Unknown overlay type "%s"!' % _type)
- _location = ensure_unicode(strip_text(source_elem))
+ _location = encode(strip_text(source_elem))
return _class(parent=self, config=self.config,
_location=_location, ignore=ignore)
@@ -156,9 +156,9 @@ class Overlay(object):
_subpath = xml.find('subpath')
if _subpath != None:
- self.subpath = ensure_unicode(_subpath.text.strip())
+ self.subpath = encode(_subpath.text.strip())
elif 'subpath' in xml.attrib:
- self.subpath = ensure_unicode(xml.attrib['subpath'])
+ self.subpath = encode(xml.attrib['subpath'])
else:
self.subpath = ''
@@ -168,14 +168,14 @@ class Overlay(object):
else:
_email = _owner.find('email')
if _owner != None and _email != None:
- self.owner_email = ensure_unicode(strip_text(_email))
+ self.owner_email = encode(strip_text(_email))
_name = _owner.find('name')
if _name != None:
- self.owner_name = ensure_unicode(strip_text(_name))
+ self.owner_name = encode(strip_text(_name))
else:
self.owner_name = None
elif 'contact' in xml.attrib:
- self.owner_email = ensure_unicode(xml.attrib['contact'])
+ self.owner_email = encode(xml.attrib['contact'])
self.owner_name = None
else:
self.owner_email = ''
@@ -190,7 +190,7 @@ class Overlay(object):
_desc = xml.find('description')
if _desc != None:
d = WHITESPACE_REGEX.sub(' ', strip_text(_desc))
- self.description = ensure_unicode(d)
+ self.description = encode(d)
del d
else:
self.description = ''
@@ -202,14 +202,14 @@ class Overlay(object):
'"description" entry!', 4)
if 'status' in xml.attrib:
- self.status = ensure_unicode(xml.attrib['status'])
+ self.status = encode(xml.attrib['status'])
else:
self.status = None
self.quality = u'experimental'
if 'quality' in xml.attrib:
if xml.attrib['quality'] in set(QUALITY_LEVELS):
- self.quality = ensure_unicode(xml.attrib['quality'])
+ self.quality = encode(xml.attrib['quality'])
if 'priority' in xml.attrib:
self.priority = int(xml.attrib['priority'])
@@ -219,18 +219,18 @@ class Overlay(object):
h = xml.find('homepage')
l = xml.find('link')
if h != None:
- self.homepage = ensure_unicode(strip_text(h))
+ self.homepage = encode(strip_text(h))
elif l != None:
- self.homepage = ensure_unicode(strip_text(l))
+ self.homepage = encode(strip_text(l))
else:
self.homepage = None
- self.feeds = [ensure_unicode(strip_text(e)) \
+ self.feeds = [encode(strip_text(e)) \
for e in xml.findall('feed')]
_irc = xml.find('irc')
if _irc != None:
- self.irc = ensure_unicode(strip_text(_irc))
+ self.irc = encode(strip_text(_irc))
else:
self.irc = None
@@ -241,7 +241,7 @@ class Overlay(object):
self.output.debug("Overlay from_dict(); overlay" + str(overlay))
_name = overlay['name']
if _name != None:
- self.name = ensure_unicode(_name)
+ self.name = encode(_name)
else:
raise Exception('Overlay from_dict(), "' + self.name +
'is missing a "name" entry!')
@@ -259,7 +259,7 @@ class Overlay(object):
except KeyError:
raise Exception('Overlay from_dict(), "' + self.name +
'Unknown overlay type "%s"!' % _type)
- _location = ensure_unicode(_src)
+ _location = encode(_src)
return _class(parent=self, config=self.config,
_location=_location, ignore=ignore)
@@ -270,10 +270,10 @@ class Overlay(object):
self.owner_name = None
_email = None
else:
- self.owner_name = ensure_unicode(_owner)
+ self.owner_name = encode(_owner)
_email = overlay['owner_email']
if _email != None:
- self.owner_email = ensure_unicode(_email)
+ self.owner_email = encode(_email)
else:
self.owner_email = None
if not ignore:
@@ -286,7 +286,7 @@ class Overlay(object):
_desc = overlay['description']
if _desc != None:
d = WHITESPACE_REGEX.sub(' ', _desc)
- self.description = ensure_unicode(d)
+ self.description = encode(d)
del d
else:
self.description = ''
@@ -298,14 +298,14 @@ class Overlay(object):
'" is missing a "description" entry!', 4)
if overlay['status']:
- self.status = ensure_unicode(overlay['status'])
+ self.status = encode(overlay['status'])
else:
self.status = None
self.quality = u'experimental'
if len(overlay['quality']):
if overlay['quality'] in set(QUALITY_LEVELS):
- self.quality = ensure_unicode(overlay['quality'])
+ self.quality = encode(overlay['quality'])
if overlay['priority']:
self.priority = int(overlay['priority'])
@@ -314,16 +314,16 @@ class Overlay(object):
h = overlay['homepage']
if h != None:
- self.homepage = ensure_unicode(h)
+ self.homepage = encode(h)
else:
self.homepage = None
- self.feeds = [ensure_unicode(e) \
+ self.feeds = [encode(e) \
for e in overlay['feeds']]
_irc = overlay['irc']
if _irc != None:
- self.irc = ensure_unicode(_irc)
+ self.irc = encode(_irc)
else:
self.irc = None
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 6fd5ba8..546c134 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -27,7 +27,7 @@ __version__ = "$Id: tar.py 310 2007-04-09 16:30:40Z wrobel $"
import os, os.path, sys, urllib2, shutil, tempfile
import xml.etree.ElementTree as ET # Python 2.5
-from layman.utils import path, ensure_unicode
+from layman.utils import path
#from layman.debug import OUT
from layman.overlays.source import OverlaySource, require_supported
diff --git a/layman/utils.py b/layman/utils.py
index 6f144be..9ffdda0 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -43,6 +43,10 @@ from layman.debug import OUT
#
#-------------------------------------------------------------------------------
+def encoder(text, _encoding_):
+ return codecs.encode(text, _encoding_, 'replace')
+
+
def decode_selection(selection):
'''utility function to decode a list of strings
accoring to the filesystem encoding
@@ -51,14 +55,10 @@ def decode_selection(selection):
selection = selection or []
enc = sys.getfilesystemencoding()
if enc is not None:
- return [i.decode(enc) for i in selection]
+ return [encoder(i, enc) for i in selection]
return selection
-def encoder(unicode_text, _encoding_):
- return codecs.encode(unicode_text, _encoding_, 'replace')
-
-
def get_encoding(output):
if hasattr(output, 'encoding') \
and output.encoding != None:
@@ -104,12 +104,6 @@ def terminal_width():
return 80
-def ensure_unicode(obj, encoding='utf-8'):
- if isinstance(obj, basestring):
- if not isinstance(obj, unicode):
- obj = unicode(obj, encoding)
- return obj
-
# From <http://effbot.org/zone/element-lib.htm>
# BEGIN
def indent(elem, level=0):
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2014-06-16 3:40 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2014-06-16 3:40 UTC (permalink / raw
To: gentoo-commits
commit: 0764934ac9670197a051af437f586d5594235c80
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 21:25:08 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:49 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0764934a
overlay.py: adds update() function
To update local database and overlay source urls, this function
has been created to allow the overlay.type functions to update
their source urls in their own methods.
source.py: Adds a stub update() function for overlay types
that don't have their own update() function.
config.py: Adds a list of supported overlay types that have their
own update() methods.
---
layman/config.py | 1 +
layman/overlays/overlay.py | 34 ++++++++++++++++++++++++++++++++++
layman/overlays/source.py | 8 ++++++++
3 files changed, 43 insertions(+)
diff --git a/layman/config.py b/layman/config.py
index c8fdf4f..40ee90a 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -165,6 +165,7 @@ class BareConfig(object):
'g-sorcery_postsync' : '',
'git_user': 'layman',
'git_email': 'layman@localhost',
+ 'support_url_updates': ['Bzr', 'cvs', 'Git', 'Mercurial', 'Subversion'],
}
self._options = {
'config': config if config else self._defaults['config'],
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 174518b..d3d81e2 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -422,6 +422,40 @@ class Overlay(object):
return res
+ def update(self, base, available_srcs):
+ res = 1
+ first_src = True
+ result = False
+
+ if isinstance(available_srcs, str):
+ available_srcs = [available_srcs]
+
+ if self.sources[0].type in self.config.get_option('support_url_updates'):
+ for src in available_srcs:
+ if not first_src:
+ self.output.info("\nTrying next source of listed sources...", 4)
+ try:
+ res = self.sources[0].update(base, src)
+ if res == 0:
+ # Updating it worked, no need to bother
+ # checking other sources.
+ self.sources[0].src = src
+ result = True
+ break
+ except Exception as error:
+ self.output.warn(str(error), 4)
+ first_s = False
+ else:
+ # Update the overlay source with the remote
+ # source, assuming that it's telling the truth
+ # so it can be written to the installed.xml.
+ self.output.debug("overlay.update(); type: %s does not support"\
+ " source URL updating" % self.sources[0].type, 4)
+ self.sources[0].src = available_srcs.pop()
+ result = True
+ return (self.sources, result)
+
+
def sync(self, base):
self.output.debug("overlay.sync(); name = %s" % self.name, 4)
assert len(self.sources) == 1
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 5044156..7c9674b 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -95,6 +95,14 @@ class OverlaySource(object):
os.makedirs(mdir)
return True
+ def update(self, src):
+ '''
+ Updates the overlay source url.
+
+ @params src: source URL.
+ '''
+ pass
+
def sync(self, base):
'''Sync the overlay.'''
pass
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2014-06-16 3:40 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2014-06-16 3:40 UTC (permalink / raw
To: gentoo-commits
commit: fda51375fed8b54e264e4577fb3d72385bbffa17
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 18:37:51 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fda51375
config.py: Adds proxies() @property function
Since remotedb.py and tar.py both made use of the same code
that determined available proxies, the code has been moved to a
function in config.py and both files have been changed to make use
of this function as a value.
---
layman/config.py | 23 ++++++++++++++++++++++-
layman/overlays/tar.py | 10 +---------
layman/remotedb.py | 11 ++---------
3 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/layman/config.py b/layman/config.py
index 40ee90a..9d2bc7f 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -66,7 +66,6 @@ def read_layman_config(config=None, defaults=None, output=None):
overlays.update(["file://" + _path])
config.set('MAIN', 'overlays', '\n'.join(overlays))
-
# establish the eprefix, initially set so eprefixify can
# set it on install
EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
@@ -280,6 +279,28 @@ class BareConfig(object):
"""
return option.lower() in ['yes', 'true', 'y', 't']
+ @property
+ def proxies(self):
+ """
+ Reads the config options to determine the available proxies.
+
+ @param config: config options dict.
+ @rtype dict
+ """
+ proxies = {}
+
+ for proxy in ['http_proxy', 'https_proxy']:
+ if self.config and self.config.get('MAIN', proxy):
+ proxies[proxy.split('_')[0]] = self.config.get('MAIN', proxy)
+ elif self.get_option(proxy):
+ proxies[proxy.split('_')[0]] = self.get_option(proxy)
+ elif os.getenv(proxy):
+ proxies[proxy.split('_')[0]] = os.getenv(proxy)
+ if self.config and proxies == {}:
+ self.output.debug("Warning: unable to determine proxies.", 6)
+
+ return proxies
+
class OptionConfig(BareConfig):
"""This subclasses BareCongig adding functions to make overriding
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index d2c1cc9..a819475 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -88,19 +88,11 @@ class TarOverlay(OverlaySource):
def __init__(self, parent, config, _location, ignore = 0):
- self.proxies = {}
-
- for proxy in ['http_proxy', 'https_proxy']:
- if config[proxy]:
- self.proxies[proxy.split('_')[0]] = config[proxy]
- elif os.getenv(proxy):
- self.proxies[proxy.split('_')[0]] = os.getenv(proxy)
-
-
super(TarOverlay, self).__init__(parent,
config, _location, ignore)
self.output = config['output']
+ self.proxies = config.proxies
self.subpath = None
def __eq__(self, other):
diff --git a/layman/remotedb.py b/layman/remotedb.py
index 175aeb5..f883799 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -57,15 +57,8 @@ class RemoteDB(DbBase):
self.output = config['output']
self.detached_urls = []
self.signed_urls = []
-
- self.proxies = {}
-
- for proxy in ['http_proxy', 'https_proxy']:
- if config[proxy]:
- self.proxies[proxy.split('_')[0]] = config[proxy]
- elif os.getenv(proxy):
- self.proxies[proxy.split('_')[0]] = os.getenv(proxy)
-
+ self.proxies = config.proxies
+
self.urls = [i.strip()
for i in config['overlays'].split('\n') if len(i)]
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
2014-06-16 3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
@ 2014-06-16 3:40 ` Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2014-06-16 3:40 UTC (permalink / raw
To: gentoo-commits
commit: e5aeb45de0db5912b57f1574562fc7d474afaa67
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 6 21:18:14 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 22:07:34 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e5aeb45d
Various syntax fixes
Fixes to docstring indentation, output messages, and function
definition syntax.
---
layman/api.py | 6 +++---
layman/overlays/bzr.py | 8 ++++----
layman/overlays/git.py | 8 ++++----
layman/overlays/mercurial.py | 8 ++++----
layman/overlays/svn.py | 8 ++++----
layman/repoconfmanager.py | 30 +++++++++++++++---------------
6 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index d9d3eb1..1d50adf 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -333,7 +333,7 @@ class LaymanAPI(object):
'\n'\
' %(remote_type)s\n'\
'\n'\
- 'the overlay will be readded using %(remote_name)s' %
+ 'the overlay will be readded using %(remote_name)s' %\
({
'repo_name': odb.name,
'current_type': current_type,
@@ -342,7 +342,7 @@ class LaymanAPI(object):
return True, msg
return False, ''
- def _verify_overlay_source(self, odb, ordb)
+ def _verify_overlay_source(self, odb, ordb):
"""
Verifies the overlay source url against the source url(s)
reported by the remote database.
@@ -367,7 +367,7 @@ class LaymanAPI(object):
msg = 'The source of the overlay "%(repo_name)s" seems to have changed.\n'\
'You currently sync from\n'\
'\n'\
- ' %(current_src)s\n'
+ ' %(current_src)s\n'\
'\n'\
'while the remote lists report\n'\
'\n'\
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 20d2491..162ba40 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -50,11 +50,11 @@ class BzrOverlay(OverlaySource):
self.subpath = None
def _fix_bzr_source(self, source):
- '''
- Adds trailing slash to source URL if needed.
+ '''
+ Adds trailing slash to source URL if needed.
- @params source: source URL, string.
- '''
+ @params source: source URL, string.
+ '''
if source.endswith("/"):
return source
return source + '/'
diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index ee8c53b..5e99a65 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -47,11 +47,11 @@ class GitOverlay(OverlaySource):
self.subpath = None
def _fix_git_source(self, source):
- '''
- Adds trailing slash to http sources
+ '''
+ Adds trailing slash to http sources
- @param source: source URL, string.
- '''
+ @param source: source URL, string.
+ '''
# http:// should get trailing slash, other protocols shouldn't
if source.split(':')[:1] == 'http':
if not source.endswith('/'):
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 74f1934..9f7d45c 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -51,11 +51,11 @@ class MercurialOverlay(OverlaySource):
self.subpath = None
def _fix_mercurial_source(self, source):
- '''
- Adds trailing slash to source URL if needed.
+ '''
+ Adds trailing slash to source URL if needed.
- @params source: source URL, string.
- '''
+ @params source: source URL, string.
+ '''
if source.endswith("/"):
return source
return source + '/'
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index f494eba..41dd862 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -54,11 +54,11 @@ class SvnOverlay(OverlaySource):
self.subpath = None
def _fix_svn_source(self, source):
- '''
- Adds @ to all sources that don't already include it.
+ '''
+ Adds @ to all sources that don't already include it.
- @params source: source URL, string.
- '''
+ @params source: source URL, string.
+ '''
if source.endswith("/"):
source = source + '@'
else:
diff --git a/layman/repoconfmanager.py b/layman/repoconfmanager.py
index 502dc2a..415a454 100644
--- a/layman/repoconfmanager.py
+++ b/layman/repoconfmanager.py
@@ -44,12 +44,12 @@ class RepoConfManager:
def add(self, overlay):
- '''
- Adds overlay information to the specified config type(s).
+ '''
+ Adds overlay information to the specified config type(s).
- @param overlay: layman.overlay.Overlay instance.
- @return boolean: represents success or failure.
- '''
+ @param overlay: layman.overlay.Overlay instance.
+ @return boolean: represents success or failure.
+ '''
if self.config['require_repoconfig']:
for types in self.conf_types:
conf = getattr(self.modules[types][0],
@@ -59,12 +59,12 @@ class RepoConfManager:
return True
def delete(self, overlay):
- '''
- Deletes overlay information from the specified config type(s).
+ '''
+ Deletes overlay information from the specified config type(s).
- @param overlay: layman.overlay.Overlay instance.
- @return boolean: represents success or failure.
- '''
+ @param overlay: layman.overlay.Overlay instance.
+ @return boolean: represents success or failure.
+ '''
if self.config['require_repoconfig']:
for types in self.conf_types:
conf = getattr(self.modules[types][0],
@@ -75,12 +75,12 @@ class RepoConfManager:
def update(self, overlay):
- '''
- Updates the source URL for the specified config type(s).
+ '''
+ Updates the source URL for the specified config type(s).
- @param overlay: layman.overlay.Overlay instance.
- @return boolean: represents success or failure.
- '''
+ @param overlay: layman.overlay.Overlay instance.
+ @return boolean: represents success or failure.
+ '''
if self.config['require_repoconfig']:
for types in self.conf_types:
conf = getattr(self.modules[types][0],
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/
@ 2020-04-24 20:59 Brian Dolbec
0 siblings, 0 replies; 19+ messages in thread
From: Brian Dolbec @ 2020-04-24 20:59 UTC (permalink / raw
To: gentoo-commits
commit: ae11c78123120e8c0a399e806dad224504aad574
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 24 12:35:38 2020 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Apr 24 13:56:12 2020 +0000
URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=ae11c781
Add additional debug statements to trace a py3.7, py3.8 error
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>
layman/db.py | 1 +
layman/overlays/overlay.py | 19 ++++++++++++++-----
layman/remotedb.py | 5 ++++-
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/layman/db.py b/layman/db.py
index d67ea87..9b32952 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -111,6 +111,7 @@ class DB(DbBase):
if overlay.name not in self.overlays.keys():
if not self._check_official(overlay):
return False
+ self.output.debug('RemoteDB.__init__(), DB.add overlay.add() call', 4)
result = overlay.add(self.config['storage'])
if result == 0:
if 'priority' in self.config.keys():
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 9cbeb99..03829a8 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -95,8 +95,9 @@ class Overlay(object):
def add(self, base):
res = 1
first_s = True
-
+ self.output.debug('Overlay.add()', 5)
self.sources = self.filter_protocols(self.sources)
+ self.output.debug('Overlay.add(), filtered protocols, sources:' + str(self.sources), 5)
if not self.sources:
msg = 'Overlay.add() error: overlay "%(name)s" does not support '\
' the given\nprotocol(s) %(protocol)s and cannot be '\
@@ -110,10 +111,12 @@ class Overlay(object):
if not first_s:
self.output.info('\nTrying next source of listed sources...', 4)
try:
+ self.output.debug('Overlay.add(), s.add(base)', 5)
res = s.add(base)
if res == 0:
# Worked, throw other sources away
self.sources = [s]
+ self.output.debug('Overlay.add(), back from s.add(base)', 5)
break
except Exception as error:
self.output.warn(str(error), 4)
@@ -132,11 +135,17 @@ class Overlay(object):
from the overlay's sources.
'''
_sources = []
- if not self.config['protocol_filter']:
+ self.output.debug('Overlay.filter_protocols()', 5)
+ self.output.debug('Overlay.filter_protocols() filters:' + str(type(self.config['protocol_filter'])), 5)
+ if not self.config['protocol_filter'] and not self.config['protocol_filter'] == []:
+ self.output.debug('Overlay.filter_protocols() no protocol_filter, returning', 5)
return sources
-
+ self.output.debug('Overlay.filter_protocols() sources:' + str(sources), 5)
for source in sources:
+ self.output.debug('Overlay.filter_protocols() source:' + str(type(source)), 5)
+ self.output.debug('Overlay.filter_protocols() filters:' + str(self.config['protocol_filter']), 5)
for protocol in self.config['protocol_filter']:
+ self.output.debug('Overlay.filter_protocols() protocol: ' + protocol + ' ' + str(type(protocol)), 5)
protocol = protocol.lower()
#re.search considers "\+" as the literal "+".
if protocol == 'git+ssh':
@@ -144,7 +153,7 @@ class Overlay(object):
protocol += '://'
if re.search('^' + protocol, source.src):
_sources.append(source)
-
+ self.output.debug('Overlay.filter_protocols(), returning sources' + str(_sources), 5)
return _sources
@@ -792,7 +801,7 @@ class Overlay(object):
try:
res = self.sources[0].update(base, src)
if res == 0:
- # Updating it worked, no need to bother
+ # Updating it worked, no need to bother
# checking other sources.
self.sources[0].src = src
result = True
diff --git a/layman/remotedb.py b/layman/remotedb.py
index 2df0c63..6e75bec 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -83,15 +83,18 @@ class RemoteDB(DbBase):
self.output.debug('RemoteDB.__init__(), paths to load = %s' %str(paths),
2)
if config['nocheck']:
+ self.output.debug('RemoteDB.__init__(), ignore = 2', 5)
ignore = 2
else:
+ self.output.debug('RemoteDB.__init__(), ignore = 0', 5)
ignore = 0
#quiet = int(config['quietness']) < 3
-
+ self.output.debug('RemoteDB.__init__(), DbBase.__init__() call', 5)
DbBase.__init__(self, config, paths=paths, ignore=ignore,
ignore_init_read_errors=ignore_init_read_errors)
+ self.output.debug('RemoteDB.__init__(), back from DbBase.__init__() call', 5)
self.gpg = None
self.gpg_config = None
^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2020-04-24 20:59 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14 6:00 [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2020-04-24 20:59 Brian Dolbec
2014-06-16 3:40 Brian Dolbec
2014-06-16 3:40 Brian Dolbec
2014-06-16 3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16 3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2011-09-24 6:07 Brian Dolbec
2011-08-24 14:02 Brian Dolbec
2011-08-21 16:42 Brian Dolbec
2011-08-11 3:24 Brian Dolbec
2011-08-07 2:29 Brian Dolbec
2011-08-06 18:29 Brian Dolbec
2011-07-30 16:53 Brian Dolbec
2011-07-29 6:11 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-02-14 6:00 Brian Dolbec
2011-02-14 6:00 Brian Dolbec
2011-02-14 6:00 Brian Dolbec
2011-02-14 6:00 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox