[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/modules/

2014-08-15 Thread Devan Franchini
commit: be6be3dd00ed173a9a95a75314c9f3a065d8
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 00:28:59 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=be6be3dd

Adds module directory for overlay types

---
 layman/overlays/modules/__init__.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/layman/overlays/modules/__init__.py 
b/layman/overlays/modules/__init__.py
new file mode 100644
index 000..e69de29



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/cvs/

2014-08-15 Thread Devan Franchini
commit: 23a73e67ab6a9be9ce9c8f5a4b814bc84b8fbca9
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 00:40:24 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=23a73e67

cvs.py: Converts to plug-in module

---
 layman/overlays/modules/cvs/__init__.py  | 26 ++
 layman/overlays/{ = modules/cvs}/cvs.py |  0
 2 files changed, 26 insertions(+)

diff --git a/layman/overlays/modules/cvs/__init__.py 
b/layman/overlays/modules/cvs/__init__.py
new file mode 100644
index 000..f085919
--- /dev/null
+++ b/layman/overlays/modules/cvs/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+CVS plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'cvs',
+'description': __doc__,
+'provides':{
+'cvs-module': {
+'name': 'cvs',
+'class': 'CvsOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync', 'update'],
+'func_desc': {
+'add': 'Performs a cvs checkout on a repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a cvs update on the repository',
+'update': 'Updates a cvs overlay\'s source URL',
+},
+}
+}
+}
+

diff --git a/layman/overlays/cvs.py b/layman/overlays/modules/cvs/cvs.py
similarity index 100%
rename from layman/overlays/cvs.py
rename to layman/overlays/modules/cvs/cvs.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/, bin/

2014-08-15 Thread Devan Franchini
commit: c3b6f7c9de1bd5723cd132e2ed66a9e8e557f22a
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Aug 11 01:00:49 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c3b6f7c9

Adds layman-mounter utility script

api.py: Adds Mounter() initialization in the LaymanAPI.
constants.py: Adds MOUNT_TYPES to constants to keep track of
mountable overlay classes.
archive.py: Adds check to unmount overlays if they are being
synced.

---
 bin/layman-mounter |  42 ++
 layman/api.py  |   5 +
 layman/constants.py|   9 +-
 layman/mounter.py  | 313 +
 layman/overlays/archive.py |   5 +
 5 files changed, 373 insertions(+), 1 deletion(-)

diff --git a/bin/layman-mounter b/bin/layman-mounter
new file mode 100755
index 000..cd41078
--- /dev/null
+++ b/bin/layman-mounter
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+# LAYMAN - A UTILITY TO HANDLE MOUNTING OVERLAYS
+
+# Distributed under the terms of the GNU General Public License v2
+#
+# Copyright:
+# (c) 2014 Devan Franchini
+# Distributed under the terms of the GNU General Public License v2
+#
+# Author(s):
+# Devan Franchini twitch...@gentoo.org
+#
+
+__version__ = 0.1
+
+#===
+#
+# Dependencies
+#
+#---
+
+from layman.api import LaymanAPI
+from layman.config  import OptionConfig
+from layman.mounter import Interactive
+
+#===
+#
+# MAIN
+#
+#---
+
+config = OptionConfig()
+layman_api = LaymanAPI(config,
+   report_errors=True,
+   output=config['output'])
+
+main = Interactive(config=config, mounter=config['mounts'])
+main()
+

diff --git a/layman/api.py b/layman/api.py
index bae6972..0f43f28 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -27,6 +27,7 @@ from layman.overlays.source import require_supported
 #from layman.utils import path, delete_empty_directory
 from layman.compatibility   import encode
 from layman.utils   import verify_overlay_src
+from layman.mounter import Mounter
 
 if sys.hexversion = 0x30200f0:
 STR = str
@@ -68,6 +69,10 @@ class LaymanAPI(object):
 self._error_messages = []
 self.sync_results = []
 
+self.config.set_option('mounts', Mounter(self._get_installed_db,
+ self.get_installed,
+ config=self.config))
+
 
 def is_repo(self, ovl):
 validates that the ovl given is a known repo id

diff --git a/layman/constants.py b/layman/constants.py
index c526cb6..7379429 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -67,7 +67,6 @@ COMPONENT_DEFAULTS  = ['name', 'descriptions', 'owner', 
'type', 'sources']
 POSSIBLE_COMPONENTS = ['name', 'descriptions', 'homepage', 'owner', 'quality',
'priority', 'sources', 'branch', 'irc', 'feeds']
 
-
 ###
 ##
 ## Archive overlay possible file extensions
@@ -77,3 +76,11 @@ POSSIBLE_COMPONENTS = ['name', 'descriptions', 'homepage', 
'owner', 'quality',
 FILE_EXTENSIONS = {'Tar': ('bz2', 'gz', 'lzma', 'xz', 'Z', 'tgz', 'tbz', 'taz',
'tlz', 'txz')
   }
+
+###
+##
+## Overlay types mountable by script
+##
+
+
+MOUNT_TYPES = []

diff --git a/layman/mounter.py b/layman/mounter.py
new file mode 100644
index 000..f041a9a
--- /dev/null
+++ b/layman/mounter.py
@@ -0,0 +1,313 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+###
+# LAYMAN MOUNTING OVERLAY HANDLER
+###
+# File:   mounter.py
+#
+# Controls all mountable overlay types
+#
+# Copyright:
+# (c) 2014 Devan Franchini
+# Distributed under the terms of the GNU General Public License v2
+#
+# Author(s):
+# Devan Franchini twitch...@gentoo.org
+#
+'''
+Controls all mountable overlay types.
+'''
+#==
+#
+# 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-08-15 Thread Devan Franchini
commit: 3ea8512b470742610c3e450cbab20fc9e5609bb2
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Aug 12 04:09:34 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:40 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=3ea8512b

Migrates run_command to utily.py

---
 layman/overlays/bzr.py   |  9 ++--
 layman/overlays/cvs.py   | 13 +++---
 layman/overlays/darcs.py |  7 ++--
 layman/overlays/g_common.py  |  8 ++--
 layman/overlays/g_sorcery.py |  8 ++--
 layman/overlays/git.py   | 16 +---
 layman/overlays/mercurial.py |  9 ++--
 layman/overlays/rsync.py |  4 +-
 layman/overlays/source.py| 95 ++
 layman/overlays/svn.py   | 16 
 layman/overlays/tar.py   |  3 +-
 layman/utils.py  | 98 ++--
 12 files changed, 152 insertions(+), 134 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index ea3e787..614f816 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -28,7 +28,7 @@ __version__ = $Id: bzr.py 236 2006-09-05 20:39:37Z wrobel $
 #
 
#---
 
-from   layman.utils import path
+from   layman.utils import path, run_command
 from   layman.overlays.source   import OverlaySource, require_supported
 
 
#===
@@ -77,7 +77,7 @@ class BzrOverlay(OverlaySource):
 else:
 args = ['branch', src, target]
 return self.postsync(
-self.run_command(self.command(), args, cmd=self.type),
+run_command(self.config, self.command(), args, cmd=self.type),
 cwd=target)
 
 def update(self, base, src):
@@ -98,7 +98,7 @@ class BzrOverlay(OverlaySource):
 if self.config['quiet']:
 args.append('--quiet')
 return self.postsync(
-self.run_command(self.command(), args, cmd=self.type),
+run_command(self.config, self.command(), args, cmd=self.type),
 cwd=target)
 
 def sync(self, base):
@@ -116,7 +116,8 @@ class BzrOverlay(OverlaySource):
 else:
 args = ['pull', '--overwrite', self.src]
 return self.postsync(
-self.run_command(self.command(), args, cwd=target, cmd=self.type),
+run_command(self.config, self.command(), args, cwd=target,
+cmd=self.type),
 cwd=target)
 
 def supported(self):

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 70638e3..62ad156 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -29,7 +29,7 @@ __version__ = $Id$
 import xml.etree.ElementTree as ET # Python 2.5
 import re
 
-from   layman.utils import path
+from   layman.utils import path, run_command
 from   layman.overlays.source   import OverlaySource, require_supported
 
 
#===
@@ -71,7 +71,7 @@ class CvsOverlay(OverlaySource):
 args.append(self.branch)
 
 return self.postsync(
-self.run_command(self.command(), args, cwd=base,
+run_command(self.config, self.command(), args, cwd=base,
 env=dict(CVSROOT=self.src), cmd=self.type),
 cwd=target)
 
@@ -90,7 +90,8 @@ class CvsOverlay(OverlaySource):
 
 # First echo the new repository to CVS/Root
 args = [src, '', '/CVS/Root']
-result = self.run_command('echo', args, cmd='echo', cwd=target)
+result = run_command(self.config, 'echo', args, cmd='echo',
+ cwd=target)
 
 if result == 0:
 location = src.split(':')[3]
@@ -106,7 +107,8 @@ class CvsOverlay(OverlaySource):
 # sed -i 's/old_location/new_location/ 
target/CVS/Repository
 args = ['-i', expression, '/CVS/Repository']
 
-return self.run_command('sed', args, cmd='sed', cwd=target)
+return run_command(self.config, 'sed', args, cmd='sed',
+   cwd=target)
 
 return result
 
@@ -129,7 +131,8 @@ class CvsOverlay(OverlaySource):
 if len(cfg_opts):
 args.append(cfg_opts)
 return self.postsync(
-self.run_command(self.command(), args, cwd=target, cmd=self.type),
+run_command(self.config, self.command(), args, cwd=target,
+cmd=self.type),
 cwd=target)
 
 def supported(self):

diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 53966c6..9e951da 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -27,7 +27,7 @@ __version__ = $Id: darcs.py 236 2006-09-05 20:39:37Z wrobel 
$
 #
 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/modules/svn/

2014-08-15 Thread Devan Franchini
commit: f1db156a7d11e0bfb8d7b6a19f066c5d0b0fba5d
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug 15 22:08:42 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 22:08:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f1db156a

svn.py: fixes svn sync output for python 3.x

X-Gentoo-Bug: 520020
X-Gentoo-Bug-URL: https://bugs.gentoo.org/520020

---
 layman/overlays/modules/svn/svn.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/modules/svn/svn.py 
b/layman/overlays/modules/svn/svn.py
index d5e598e..51bb487 100644
--- a/layman/overlays/modules/svn/svn.py
+++ b/layman/overlays/modules/svn/svn.py
@@ -166,13 +166,13 @@ class SvnOverlay(OverlaySource):
 '''
 file_to_run = resolve_command(self.command(), self.output.error)[1]
 args =  .join([file_to_run,  upgrade, target])
-pipe = Popen(args, shell=True, stdout=PIPE, stderr=PIPE)
-if pipe:
+stdout, stderr = Popen(args, shell=True, stdout=PIPE, 
stderr=PIPE).communicate()
+if stdout:
 self.output.debug(SVN: check_upgrade()... have a valid pipe, 
 running upgrade, 4)
-upgrade_output = pipe.stdout.readline().strip('\n')
+upgrade_output = stdout.readline().split('\n')
 if upgrade_output:
 self.output.debug(  output: %s % upgrade_output, 4)
 self.output.debug(SVN: check_upgrade()... svn upgrade done, 4)
-pipe.terminate()
+stdout.terminate()
 return



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/g_common/

2014-08-15 Thread Devan Franchini
commit: 7fe9df5d0d668734d27cb3854f99d5c10aad8939
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 00:51:20 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=7fe9df5d

g_common.py: Converts to plug-in module

---
 layman/overlays/modules/g_common/__init__.py   | 25 ++
 layman/overlays/{ = modules/g_common}/g_common.py |  0
 2 files changed, 25 insertions(+)

diff --git a/layman/overlays/modules/g_common/__init__.py 
b/layman/overlays/modules/g_common/__init__.py
new file mode 100644
index 000..d8ea23d
--- /dev/null
+++ b/layman/overlays/modules/g_common/__init__.py
@@ -0,0 +1,25 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+G-Common plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'g-common',
+'description': __doc__,
+'provides':{
+'g-common-module': {
+'name': 'g-common',
+'class': 'GCommonOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync'],
+'func_desc': {
+'add': 'Creates the base dir and clones a g_common repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a sync of the repository',
+},
+}
+}
+}
+

diff --git a/layman/overlays/g_common.py 
b/layman/overlays/modules/g_common/g_common.py
similarity index 100%
rename from layman/overlays/g_common.py
rename to layman/overlays/modules/g_common/g_common.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/darcs/

2014-08-15 Thread Devan Franchini
commit: 2eb6cd7d517a14a8b80537fd1a8ca8b8ab28fe14
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 00:44:30 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2eb6cd7d

darcs.py: Converts to plug-in module

---
 layman/overlays/modules/darcs/__init__.py| 25 +
 layman/overlays/{ = modules/darcs}/darcs.py |  0
 2 files changed, 25 insertions(+)

diff --git a/layman/overlays/modules/darcs/__init__.py 
b/layman/overlays/modules/darcs/__init__.py
new file mode 100644
index 000..be5d267
--- /dev/null
+++ b/layman/overlays/modules/darcs/__init__.py
@@ -0,0 +1,25 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Darcs plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'darcs',
+'description': __doc__,
+'provides':{
+'darcs-module': {
+'name': 'darcs',
+'class': 'DarcsOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync'],
+'func_desc': {
+'add': 'Performs a darcs get on a repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a darcs pull on the repository',
+},
+}
+}
+}
+

diff --git a/layman/overlays/darcs.py b/layman/overlays/modules/darcs/darcs.py
similarity index 100%
rename from layman/overlays/darcs.py
rename to layman/overlays/modules/darcs/darcs.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-08-15 Thread Devan Franchini
commit: aa264e4ef3c620f2dae3f8b3bccf38574412742c
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug  1 21:13:42 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=aa264e4e

overlay.py: Adds self.ovl_type

To allow a stub function to tell the user the current overlay type
of the unsupported overlay, this variable will be passed in along
with the parent variable.

---
 layman/overlays/overlay.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index ee2c279..bc57e2e 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -101,6 +101,7 @@ class Overlay(object):
 def create_overlay_source(source_elem):
 _branch = ''
 _type = source_elem.attrib['type']
+self.ovl_type = _type
 if 'branch' in source_elem.attrib:
 _branch = source_elem.attrib['branch']
 
@@ -215,6 +216,7 @@ class Overlay(object):
 
 def create_dict_overlay_source(source_):
 _src, _type, _sub = source_
+self.ovl_type = _type
 try:
 _class = self.module_controller.get_class(_type)
 except InvalidModuleName:



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/modules/g_common/

2014-08-15 Thread Devan Franchini
commit: 49b5507b6d95dfefe26ac0a3b1ec629f3f11066f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug 15 21:27:01 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=49b5507b

Removes g-common overlay support

---
 layman/overlays/modules/g_common/__init__.py | 25 
 layman/overlays/modules/g_common/g_common.py | 92 
 2 files changed, 117 deletions(-)

diff --git a/layman/overlays/modules/g_common/__init__.py 
b/layman/overlays/modules/g_common/__init__.py
deleted file mode 100644
index d8ea23d..000
--- a/layman/overlays/modules/g_common/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-'''
-G-Common plug-in module for layman.
-'''
-
-module_spec = {
-'name': 'g-common',
-'description': __doc__,
-'provides':{
-'g-common-module': {
-'name': 'g-common',
-'class': 'GCommonOverlay',
-'description': __doc__,
-'functions': ['add', 'supported', 'sync'],
-'func_desc': {
-'add': 'Creates the base dir and clones a g_common repository',
-'supported': 'Confirms if overlay type is supported',
-'sync': 'Performs a sync of the repository',
-},
-}
-}
-}
-

diff --git a/layman/overlays/modules/g_common/g_common.py 
b/layman/overlays/modules/g_common/g_common.py
deleted file mode 100644
index 9c5f6b7..000
--- a/layman/overlays/modules/g_common/g_common.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/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 a...@tulcod.com
-#
-''' G-common repository support.'''
-
-from __future__ import unicode_literals
-
-#===
-#
-# Dependencies
-#
-#---
-
-import os
-from   layman.utils import path, run_command
-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, config, _location, ignore = 0):
-super(GCommonOverlay, self).__init__(parent, config,
-_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.branch = None
-
-def add(self, base):
-'''Add overlay.'''
-
-if not self.supported():
-return 1
-
-target = path([base, self.parent.name])
-
-os.makedirs(target)
-
-return self.sync(base)
-
-def sync(self, base):
-'''Sync overlay.'''
-
-if not self.supported():
-return 1
-
-target = path([base, self.parent.name])
-
-args = [target, 'sync', self.driver, self.remote_uri]
-returncode = run_command(self.config, self.command(), args,
- cwd=target)
-if returncode:
-return returncode
-args = [target, 'generate-tree']
-return self.postsync(
-run_command(self.config, self.command(), args, cwd=target,
-cmd=self.type),
-cwd=target)
-
-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),],
-self.output.warn)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/rsync/

2014-08-15 Thread Devan Franchini
commit: e328e21a39c92630a1314cdb0ab0252e565fd219
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 01:49:26 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e328e21a

rsync.py: Converts to plug-in module

---
 layman/overlays/modules/rsync/__init__.py| 25 +
 layman/overlays/{ = modules/rsync}/rsync.py |  0
 2 files changed, 25 insertions(+)

diff --git a/layman/overlays/modules/rsync/__init__.py 
b/layman/overlays/modules/rsync/__init__.py
new file mode 100644
index 000..862f647
--- /dev/null
+++ b/layman/overlays/modules/rsync/__init__.py
@@ -0,0 +1,25 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Rsync plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'rsync',
+'description': __doc__,
+'provides':{
+'rsync-module': {
+'name': 'rsync',
+'class': 'RsyncOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync'],
+'func_desc': {
+'add': 'Creates the base dir and syncs a rsync repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a rsync sync',
+},
+}
+}
+}
+

diff --git a/layman/overlays/rsync.py b/layman/overlays/modules/rsync/rsync.py
similarity index 100%
rename from layman/overlays/rsync.py
rename to layman/overlays/modules/rsync/rsync.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-08-15 Thread Devan Franchini
commit: 4be4ecf142526e54ff052118aa856699a7251986
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug  1 21:05:54 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4be4ecf1

overlay.py: Adds plug-in module controller

This commit implements the module controller system for the overlay
plug-in modules.

---
 layman/overlays/overlay.py | 45 +
 1 file changed, 13 insertions(+), 32 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 81dadcd..8dd0b4b 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -35,38 +35,16 @@ import codecs
 import locale
 import xml.etree.ElementTree as ET # Python 2.5
 
-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
-from   layman.overlays.git   import GitOverlay
-from   layman.overlays.g_common  import GCommonOverlay
-from   layman.overlays.g_sorcery import GSorceryOverlay
-from   layman.overlays.mercurial import MercurialOverlay
-from   layman.overlays.cvs   import CvsOverlay
-from   layman.overlays.svn   import SvnOverlay
-from   layman.overlays.rsync import RsyncOverlay
-from   layman.overlays.tar   import TarOverlay
+from  layman.compatibility import encode
+from  layman.moduleimport Modules, InvalidModuleName
+from  layman.utils import pad, terminal_width, get_encoding, encoder
 
 
#===
 #
 # Constants
 #
 
#---
-
-OVERLAY_TYPES = dict((e.type_key, e) for e in (
-GitOverlay,
-GCommonOverlay,
-GSorceryOverlay,
-CvsOverlay,
-SvnOverlay,
-RsyncOverlay,
-TarOverlay,
-BzrOverlay,
-MercurialOverlay,
-DarcsOverlay
-))
+MOD_PATH = path = os.path.join(os.path.dirname(__file__), 'modules')
 
 QUALITY_LEVELS = 'core|stable|testing|experimental|graveyard'.split('|')
 
@@ -80,6 +58,9 @@ class Overlay(object):
 ignore = 0):
 self.config = config
 self.output = config['output']
+self.module_controller = Modules(path=MOD_PATH,
+ namepath='layman.overlays.modules',
+ output=self.output)
 self._encoding_ = get_encoding(self.output)
 
 if xml is not None:
@@ -124,10 +105,10 @@ class Overlay(object):
 _branch = source_elem.attrib['branch']
 
 try:
-_class = OVERLAY_TYPES[_type]
-except KeyError:
+_class = self.module_controller.get_class(_type)
+except InvalidModuleName:
 raise Exception('Overlay from_xml(), ' + self.name + \
-'Unknown overlay type %s!' % _type)
+' Unknown overlay type %s!' % _type)
 
 _location = encode(strip_text(source_elem))
 
@@ -236,10 +217,10 @@ class Overlay(object):
 def create_dict_overlay_source(source_):
 _src, _type, _sub = source_
 try:
-_class = OVERLAY_TYPES[_type]
-except KeyError:
+_class = self.module_controller.get_class(_type)
+except InvalidModuleName:
 raise Exception('Overlay from_dict(), ' + self.name +
-'Unknown overlay type %s!' % _type)
+' Unknown overlay type %s!' % _type)
 _location = encode(_src)
 if _sub:
 self.branch = encode(_sub)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/stub/

2014-08-15 Thread Devan Franchini
commit: 0d6e5980d18b75832cb95f78e2053e8a9c0c2902
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug  1 21:09:22 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0d6e5980

Adds stub module

In the event that a user doesn't install layman with a specific
overlay type, the StubOverlay class will be used.

---
 layman/overlays/modules/stub/__init__.py | 26 ++
 layman/overlays/modules/stub/stub.py | 62 
 layman/overlays/overlay.py   |  7 ++--
 3 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/modules/stub/__init__.py 
b/layman/overlays/modules/stub/__init__.py
new file mode 100644
index 000..a124d6a
--- /dev/null
+++ b/layman/overlays/modules/stub/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Stub plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'stub',
+'description': __doc__,
+'provides':{
+'stub-module': {
+'name': 'stub',
+'class': 'StubOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync', 'update'],
+'func_desc': {
+'add': 'Stub add function',
+'supported': 'Stub supported function',
+'sync': 'Stub sync function',
+'update': 'Stub update function',
+},
+}
+}
+}
+

diff --git a/layman/overlays/modules/stub/stub.py 
b/layman/overlays/modules/stub/stub.py
new file mode 100644
index 000..86612fe
--- /dev/null
+++ b/layman/overlays/modules/stub/stub.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+#===
+#
+# Dependencies
+#
+#---
+
+from   layman.utils import path
+from   layman.overlays.source   import OverlaySource
+
+#===
+#
+# Class StubOverlay
+#
+#---
+
+class StubOverlay(OverlaySource):
+''' Handles overlays with missing modules. '''
+
+type = 'N/A'
+type_key = 'n/a'
+
+def __init__(self, parent, config, _location, ignore = 0):
+super(StubOverlay, self).__init__(parent,
+config, _location, ignore)
+self.branch = self.parent.branch
+self.info = {'name': self.parent.name, 'type': self.parent.ovl_type}
+self.missing_msg = 'Overlay %(name)s is missing %(type)s module!'\
+% self.info
+self.hint = 'Did you install layman with %(type)s support?'\
+% self.info
+
+
+def add(self, base):
+'''Add overlay.'''
+self.output.error(self.missing_msg)
+self.output.warn(self.hint)
+return True
+
+
+def update(self, base, src):
+'''
+Updates overlay src-url.
+'''
+self.output.error(self.missing_msg)
+self.output.warn(self.hint)
+return True
+
+
+def sync(self, base):
+'''Sync overlay.'''
+self.output.error(self.missing_msg)
+self.output.warn(self.hint)
+return True
+
+
+def supported(self):
+'''Overlay type supported?'''
+return False

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8dd0b4b..ee2c279 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -107,8 +107,7 @@ class Overlay(object):
 try:
 _class = self.module_controller.get_class(_type)
 except InvalidModuleName:
-raise Exception('Overlay from_xml(), ' + self.name + \
-' Unknown overlay type %s!' % _type)
+_class = self.module_controller.get_class('stub')
 
 _location = encode(strip_text(source_elem))
 
@@ -219,8 +218,8 @@ class Overlay(object):
 try:
 _class = self.module_controller.get_class(_type)
 except InvalidModuleName:
-raise Exception('Overlay from_dict(), ' + self.name +
-' Unknown overlay type %s!' % _type)
+_class = self.module_controller.get_class('stub')
+
 _location = encode(_src)
 if _sub:
 self.branch = encode(_sub)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/svn/

2014-08-15 Thread Devan Franchini
commit: dfe7e56f5351d64b61e66eefa3c6c0f9e2855516
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 01:54:30 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=dfe7e56f

svn.py: Converts to plug-in module

---
 layman/overlays/modules/svn/__init__.py  | 26 ++
 layman/overlays/{ = modules/svn}/svn.py |  0
 2 files changed, 26 insertions(+)

diff --git a/layman/overlays/modules/svn/__init__.py 
b/layman/overlays/modules/svn/__init__.py
new file mode 100644
index 000..f7d72c7
--- /dev/null
+++ b/layman/overlays/modules/svn/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Subversion plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'svn',
+'description': __doc__,
+'provides':{
+'svn-module': {
+'name': 'svn',
+'class': 'SvnOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync', 'update'],
+'func_desc': {
+'add': 'Performs a svn checkout on a repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a svn up on the repository',
+'update': 'Updates a svn overlay\'s source URL',
+},
+}
+}
+}
+

diff --git a/layman/overlays/svn.py b/layman/overlays/modules/svn/svn.py
similarity index 100%
rename from layman/overlays/svn.py
rename to layman/overlays/modules/svn/svn.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/bzr/

2014-08-15 Thread Devan Franchini
commit: 852e8b970bb0ef10ba676962933aa017a2ced2e8
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 00:34:02 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=852e8b97

bzr.py: Converts to plug-in module

---
 layman/overlays/modules/bzr/__init__.py  | 26 ++
 layman/overlays/{ = modules/bzr}/bzr.py |  0
 2 files changed, 26 insertions(+)

diff --git a/layman/overlays/modules/bzr/__init__.py 
b/layman/overlays/modules/bzr/__init__.py
new file mode 100644
index 000..e69cc6d
--- /dev/null
+++ b/layman/overlays/modules/bzr/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Bazaar plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'bzr',
+'description': __doc__,
+'provides':{
+'bzr-module': {
+'name': 'bzr',
+'class': 'BzrOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync', 'update'],
+'func_desc': {
+'add': 'Performs a bzr get on a repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a bzr pull on the repository',
+'update': 'Updates a bzr overlay\'s source URL via bzr bind',
+},
+}
+}
+}
+

diff --git a/layman/overlays/bzr.py b/layman/overlays/modules/bzr/bzr.py
similarity index 100%
rename from layman/overlays/bzr.py
rename to layman/overlays/modules/bzr/bzr.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-08-15 Thread Devan Franchini
commit: 691dc445082cc455159d699498a714d40754fedd
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon Jul  7 18:27:24 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 20:57:38 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=691dc445

Centralizes common archive overlay code

This commit brings archive overlay code to one common place, in
an attempt to make maintaining and adding archive overlay types
to layman much easier.

config.py: Alters the clean_tar option to clean_archive.

tar.py: Removes doctest tests from tar.py as there is already an
existing external.py test.

---
 layman/config.py   |   2 +-
 layman/constants.py|  11 +++
 layman/overlays/archive.py | 197 +
 layman/overlays/tar.py | 179 ++--
 4 files changed, 235 insertions(+), 154 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 4849d5e..91c179e 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -100,7 +100,7 @@ class BareConfig(object):
 'check_official': 'Yes',
 'conf_type': 'make.conf',
 'require_repoconfig': 'Yes',
-'clean_tar': 'yes',
+'clean_archive': 'yes',
 'make_conf' : '%(storage)s/make.conf',
 'repos_conf': path([self.root, 
EPREFIX,'/etc/portage/repos.conf/layman.conf']),
 'conf_module': ['make_conf', 'repos_conf'],

diff --git a/layman/constants.py b/layman/constants.py
index 24d1f36..c526cb6 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -66,3 +66,14 @@ SUCCEED = 0
 COMPONENT_DEFAULTS  = ['name', 'descriptions', 'owner', 'type', 'sources']
 POSSIBLE_COMPONENTS = ['name', 'descriptions', 'homepage', 'owner', 'quality',
'priority', 'sources', 'branch', 'irc', 'feeds']
+
+
+###
+##
+## Archive overlay possible file extensions
+##
+###
+
+FILE_EXTENSIONS = {'Tar': ('bz2', 'gz', 'lzma', 'xz', 'Z', 'tgz', 'tbz', 'taz',
+   'tlz', 'txz')
+  }

diff --git a/layman/overlays/archive.py b/layman/overlays/archive.py
new file mode 100644
index 000..68c8b47
--- /dev/null
+++ b/layman/overlays/archive.py
@@ -0,0 +1,197 @@
+#!/usr/bin/python
+from __future__ import unicode_literals
+
+import os
+import sys
+import shutil
+import tempfile
+
+import xml.etree.ElementTree as ET # Python 2.5
+
+from  layman.constants import MOUNT_TYPES
+from  layman.compatibility import fileopen
+from  layman.overlays.source   import OverlaySource, require_supported
+from  layman.utils import path
+from  layman.version   import VERSION
+from  sslfetch.connections import Connector
+
+USERAGENT = Layman- + VERSION
+
+class ArchiveOverlay(OverlaySource):
+
+type = 'Archive'
+type_key = 'archive'
+
+def __init__(self, parent, config, _location, ignore = 0):
+
+super(ArchiveOverlay, self).__init__(parent,
+config, _location, ignore)
+
+self.clean_archive = config['clean_archive']
+self.output = config['output']
+self.proxies = config.proxies
+self.branch = self.parent.branch
+self.mount_me = bool(self.type in MOUNT_TYPES)
+
+
+def _fetch(self, base, archive_url, dest_dir):
+'''
+Fetches overlay source archive.
+
+@params base: string of directory base for installed overlays.
+@params archive_url: string of URL where archive is located.
+@params dest_dir: string of destination of extracted archive.
+@rtype tuple (str of package location, bool to clean_archive)
+'''
+ext = self.get_extension()
+ 
+if 'file://' not in archive_url:
+# set up ssl-fetch output map
+connector_output = {
+'info': self.output.debug,
+'error': self.output.error,
+'kwargs-info': {'level': 2},
+'kwargs-error': {'level': None},
+}
+
+fetcher = Connector(connector_output, self.proxies, USERAGENT)
+
+success, archive, timestamp = fetcher.fetch_content(archive_url)
+
+pkg = path([base, self.parent.name + ext])
+
+try:
+with fileopen(pkg, 'w+b') as out_file:
+out_file.write(archive)
+
+except Exception as error:
+raise Exception('Failed to store archive package in '\
+'%(pkg)s\nError was: %(error)s'\
+% ({'pkg': pkg, 'error': error}))
+
+else:
+self.clean_archive = False
+pkg = archive_url.replace('file://', '')
+
+return pkg
+
+
+def 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-08-15 Thread Devan Franchini
commit: a4cacd7fec67b377ca7ce882c3257326e0259d2b
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed Aug 13 23:24:01 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a4cacd7f

Adds Squashfs overlay support

constants.py: Adds Squashfs overlay type to MOUNT_TYPES constants,
as well as different possible file extensions to FILE_EXTENSIONS
constants.

---
 layman/constants.py |   7 ++-
 layman/overlays/squashfs.py | 148 
 2 files changed, 152 insertions(+), 3 deletions(-)

diff --git a/layman/constants.py b/layman/constants.py
index 7379429..787b610 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -73,8 +73,9 @@ POSSIBLE_COMPONENTS = ['name', 'descriptions', 'homepage', 
'owner', 'quality',
 ##
 ###
 
-FILE_EXTENSIONS = {'Tar': ('bz2', 'gz', 'lzma', 'xz', 'Z', 'tgz', 'tbz', 'taz',
-   'tlz', 'txz')
+FILE_EXTENSIONS = {'Squashfs': ('.squashfs', '.squash', '.sqfs', '.sfs'),
+   'Tar': ('bz2', 'gz', 'lzma', 'xz', 'Z', 'tgz', 'tbz', 'taz',
+   'tlz', 'txz'),
   }
 
 
###
@@ -83,4 +84,4 @@ FILE_EXTENSIONS = {'Tar': ('bz2', 'gz', 'lzma', 'xz', 'Z', 
'tgz', 'tbz', 'taz',
 ##
 

 
-MOUNT_TYPES = []
+MOUNT_TYPES = ['Squashfs']

diff --git a/layman/overlays/squashfs.py b/layman/overlays/squashfs.py
new file mode 100644
index 000..48711ce
--- /dev/null
+++ b/layman/overlays/squashfs.py
@@ -0,0 +1,148 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# LAYMAN SQUASHFS OVERLAY HANDLER
+
+# File:   squashfs.py
+#
+# Handles squashfs overlays
+#
+# Copyright:
+# (c) 2014 Devan Franchini
+# Distributed under the terms of the GNU General Public License v2
+#
+# Author(s):
+# Devan Franchini twitch...@gentoo.org
+#
+''' Squashfs overlay support.'''
+
+from __future__ import unicode_literals
+
+#===
+#
+# Dependencies
+#
+#---
+
+import os
+import shutil
+import sys
+
+from   layman.constantsimport FILE_EXTENSIONS
+from   layman.overlays.archive import ArchiveOverlay
+from   layman.overlays.source  import require_supported
+from   layman.utilsimport path
+
+#===
+#
+# Class SquashfsOverlay
+#
+#---
+
+class SquashfsOverlay(ArchiveOverlay):
+''' Handles squashfs overlays.'''
+
+type = 'Squashfs'
+type_key = 'squashfs'
+
+def __init__(self, parent, config, _location, ignore=0):
+super(SquashfsOverlay, self).__init__(parent,
+config, _location, ignore)
+self.mounter = config.get_option('mounts')
+
+
+def get_extension(self):
+'''
+Determines squashfs file extension.
+
+@rtype str
+'''
+ext = ''
+for i in FILE_EXTENSIONS[self.type]:
+candidate_ext = i
+if self.src.endswith(candidate_ext):
+ext = candidate_ext
+break
+
+return ext
+
+
+def delete(self, base):
+'''
+Deletes the selected overlay.
+
+@params base: Base dir where the overlay is installed.
+@rtype bool
+'''
+mdir = path([base, self.parent.name])
+
+source = self.src
+if 'file://' in source:
+pkg = source.replace('file://', '')
+else:
+pkg_name = self.parent.name + self.get_extension()
+pkg = path([self.config['storage'], pkg_name])
+
+if os.path.ismount(mdir):
+result = self.mounter.umount([self.parent.name])
+else:
+result = 1
+
+shutil.rmtree(mdir)
+if self.clean_archive:
+if os.path.exists(pkg):
+os.unlink(pkg)
+
+return result
+
+
+def post_fetch(self, pkg, dest_dir):
+'''
+Runs initial squashfs archive mounting.
+
+@params pkg: string location where squashfs archive is located.
+@params dest_dir: string of mounting destination.
+@rtype bool
+'''
+result = self.mounter.mount([self.parent.name],
+dest_dir,
+

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/squashfs/, ...

2014-08-15 Thread Devan Franchini
commit: 92f7f0c65c819e54e5be0033c4179d5fc9e906fb
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Aug 15 19:52:12 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=92f7f0c6

Converts archive code to plug-in module

---
 layman/overlays/{ = modules}/archive.py   |  0
 layman/overlays/modules/squashfs/__init__.py   | 25 ++
 layman/overlays/{ = modules/squashfs}/squashfs.py |  8 +++
 layman/overlays/modules/tar/__init__.py| 25 ++
 layman/overlays/{ = modules/tar}/tar.py   |  8 +++
 5 files changed, 58 insertions(+), 8 deletions(-)

diff --git a/layman/overlays/archive.py b/layman/overlays/modules/archive.py
similarity index 100%
rename from layman/overlays/archive.py
rename to layman/overlays/modules/archive.py

diff --git a/layman/overlays/modules/squashfs/__init__.py 
b/layman/overlays/modules/squashfs/__init__.py
new file mode 100644
index 000..753fe21
--- /dev/null
+++ b/layman/overlays/modules/squashfs/__init__.py
@@ -0,0 +1,25 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Squashfs plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'squashfs',
+'description': __doc__,
+'provides':{
+'squashfs-module': {
+'name': 'squashfs',
+'class': 'SquashfsOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync'],
+'func_desc': {
+'add': 'Fetches overlay package and mounts it locally',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Refetches overlay package and mounts it locally',
+},
+}
+}
+}
+

diff --git a/layman/overlays/squashfs.py 
b/layman/overlays/modules/squashfs/squashfs.py
similarity index 94%
rename from layman/overlays/squashfs.py
rename to layman/overlays/modules/squashfs/squashfs.py
index 48711ce..d7307bd 100644
--- a/layman/overlays/squashfs.py
+++ b/layman/overlays/modules/squashfs/squashfs.py
@@ -28,10 +28,10 @@ import os
 import shutil
 import sys
 
-from   layman.constantsimport FILE_EXTENSIONS
-from   layman.overlays.archive import ArchiveOverlay
-from   layman.overlays.source  import require_supported
-from   layman.utilsimport path
+from   layman.constantsimport FILE_EXTENSIONS
+from   layman.overlays.modules.archive import ArchiveOverlay
+from   layman.overlays.source  import require_supported
+from   layman.utilsimport path
 
 
#===
 #

diff --git a/layman/overlays/modules/tar/__init__.py 
b/layman/overlays/modules/tar/__init__.py
new file mode 100644
index 000..c3a5ca8
--- /dev/null
+++ b/layman/overlays/modules/tar/__init__.py
@@ -0,0 +1,25 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Tar plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'tar',
+'description': __doc__,
+'provides':{
+'tar-module': {
+'name': 'tar',
+'class': 'TarOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync'],
+'func_desc': {
+'add': 'Creates the base dir and extracts the tar repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a sync on the repository',
+},
+}
+}
+}
+

diff --git a/layman/overlays/tar.py b/layman/overlays/modules/tar/tar.py
similarity index 91%
rename from layman/overlays/tar.py
rename to layman/overlays/modules/tar/tar.py
index bcba32c..322b46c 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/modules/tar/tar.py
@@ -28,10 +28,10 @@ __version__ = $Id: tar.py 310 2007-04-09 16:30:40Z wrobel 
$
 
 import sys
 
-from   layman.constants import FILE_EXTENSIONS
-from   layman.overlays.archive  import ArchiveOverlay
-from   layman.overlays.source   import require_supported
-from   layman.utils import run_command
+from   layman.constantsimport FILE_EXTENSIONS
+from   layman.overlays.modules.archive import ArchiveOverlay
+from   layman.overlays.source  import require_supported
+from   layman.utilsimport run_command
 
 
#===
 #



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/g_sorcery/

2014-08-15 Thread Devan Franchini
commit: 4250b143b1c54c9050727814d70beb23a556bda1
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 01:32:14 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4250b143

g_sorcery.py: Converts to plug-in module

---
 layman/overlays/modules/g_sorcery/__init__.py  | 25 ++
 .../overlays/{ = modules/g_sorcery}/g_sorcery.py  |  0
 2 files changed, 25 insertions(+)

diff --git a/layman/overlays/modules/g_sorcery/__init__.py 
b/layman/overlays/modules/g_sorcery/__init__.py
new file mode 100644
index 000..2b3caf3
--- /dev/null
+++ b/layman/overlays/modules/g_sorcery/__init__.py
@@ -0,0 +1,25 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+G-Sorcery plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'g-sorcery',
+'description': __doc__,
+'provides':{
+'g-sorcery-module': {
+'name': 'g-sorcery',
+'class': 'GSorceryOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync'],
+'func_desc': {
+'add': 'Creates the base dir and clones a g_common repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a sync of the repository',
+},
+}
+}
+}
+

diff --git a/layman/overlays/g_sorcery.py 
b/layman/overlays/modules/g_sorcery/g_sorcery.py
similarity index 100%
rename from layman/overlays/g_sorcery.py
rename to layman/overlays/modules/g_sorcery/g_sorcery.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/git/

2014-08-15 Thread Devan Franchini
commit: 75d6ab3c1ac9dd71cd26b19133e50bff7031110d
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 01:36:11 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=75d6ab3c

git.py: Converts to plug-in module

---
 layman/overlays/modules/git/__init__.py  | 26 ++
 layman/overlays/{ = modules/git}/git.py |  0
 2 files changed, 26 insertions(+)

diff --git a/layman/overlays/modules/git/__init__.py 
b/layman/overlays/modules/git/__init__.py
new file mode 100644
index 000..3a2d932
--- /dev/null
+++ b/layman/overlays/modules/git/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Git plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'git',
+'description': __doc__,
+'provides':{
+'git-module': {
+'name': 'git',
+'class': 'GitOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync', 'update'],
+'func_desc': {
+'add': 'Performs a git clone on a repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a git pull on the repository',
+'update': 'Updates a git overlay\'s source URL',
+},
+}
+}
+}
+

diff --git a/layman/overlays/git.py b/layman/overlays/modules/git/git.py
similarity index 100%
rename from layman/overlays/git.py
rename to layman/overlays/modules/git/git.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/overlays/modules/mercurial/

2014-08-15 Thread Devan Franchini
commit: 754084ab0925bbc924b691119d7ebada0f92f048
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jul 29 01:44:50 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri Aug 15 21:42:42 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=754084ab

mercurial.py: Converts to plug-in module

---
 layman/overlays/modules/mercurial/__init__.py  | 26 ++
 .../overlays/{ = modules/mercurial}/mercurial.py  |  0
 2 files changed, 26 insertions(+)

diff --git a/layman/overlays/modules/mercurial/__init__.py 
b/layman/overlays/modules/mercurial/__init__.py
new file mode 100644
index 000..1999109
--- /dev/null
+++ b/layman/overlays/modules/mercurial/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''
+Mercurial plug-in module for layman.
+'''
+
+module_spec = {
+'name': 'mercurial',
+'description': __doc__,
+'provides':{
+'mercurial-module': {
+'name': 'mercurial',
+'class': 'MercurialOverlay',
+'description': __doc__,
+'functions': ['add', 'supported', 'sync', 'update'],
+'func_desc': {
+'add': 'Performs a hg clone on a repository',
+'supported': 'Confirms if overlay type is supported',
+'sync': 'Performs a hg pull on the repository',
+'update': 'Updates a mercurial overlay\'s source URL',
+},
+}
+}
+}
+

diff --git a/layman/overlays/mercurial.py 
b/layman/overlays/modules/mercurial/mercurial.py
similarity index 100%
rename from layman/overlays/mercurial.py
rename to layman/overlays/modules/mercurial/mercurial.py



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-26 Thread Devan Franchini
commit: 5762ca4893af37816d09a39b7254a85381d7fcc2
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed Jun 18 02:20:14 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu Jun 19 03:49:57 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=5762ca48

overlay.py: Improves dictionary checking logic

---
 layman/overlays/overlay.py | 73 --
 1 file changed, 44 insertions(+), 29 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 72c5d53..176f146 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -150,13 +150,21 @@ class Overlay(object):
 del s
 
 def create_overlay_source(source_elem):
+_branch = ''
 _type = source_elem.attrib['type']
+if 'branch' in source_elem.attrib:
+_branch = source_elem.attrib['branch']
+
 try:
 _class = OVERLAY_TYPES[_type]
 except KeyError:
 raise Exception('Overlay from_xml(), ' + self.name + \
 'Unknown overlay type %s!' % _type)
+
 _location = encode(strip_text(source_elem))
+
+self.branch = _branch
+
 return _class(parent=self, config=self.config,
 _location=_location, ignore=ignore)
 
@@ -240,9 +248,9 @@ class Overlay(object):
 
 
 def from_dict(self, overlay, ignore):
-Process an xml overlay definition
+Process an overlay dictionary definition
 
-self.output.debug(Overlay from_dict(); overlay + str(overlay))
+self.output.debug(Overlay from_dict(); overlay + str(overlay), 6)
 _name = overlay['name']
 if _name != None:
 self.name = encode(_name)
@@ -264,19 +272,25 @@ class Overlay(object):
 raise Exception('Overlay from_dict(), ' + self.name +
 'Unknown overlay type %s!' % _type)
 _location = encode(_src)
+if _sub:
+self.branch = encode(_sub)
+else:
+self.branch = None
+
 return _class(parent=self, config=self.config,
 _location=_location, ignore=ignore)
 
 self.sources = [create_dict_overlay_source(e) for e in _sources]
 
-_owner = overlay['owner_name']
-if _owner == None:
-self.owner_name = None
-_email = None
-else:
+if 'owner_name' in overlay:
+_owner = overlay['owner_name']
 self.owner_name = encode(_owner)
 _email = overlay['owner_email']
-if _email != None:
+else:
+self.owner_name = None
+
+if 'owner_email' in overlay:
+_email = overlay['owner_email']
 self.owner_email = encode(_email)
 else:
 self.owner_email = None
@@ -287,8 +301,8 @@ class Overlay(object):
 self.output.warn('Overlay from_dict(), ' + self.name +
 ' is missing an owner.email entry!', 4)
 
-_desc = overlay['description']
-if _desc != None:
+if 'description' in overlay:
+_desc = overlay['description']
 d = WHITESPACE_REGEX.sub(' ', _desc)
 self.description = encode(d)
 del d
@@ -301,39 +315,39 @@ class Overlay(object):
 self.output.warn('Overlay from_dict(), ' + self.name +
 ' is missing a description entry!', 4)
 
-if overlay['status']:
+if 'status' in overlay:
 self.status = encode(overlay['status'])
 else:
 self.status = None
 
 self.quality = 'experimental'
-if len(overlay['quality']):
+if 'quality' in overlay:
 if overlay['quality'] in set(QUALITY_LEVELS):
 self.quality = encode(overlay['quality'])
 
-if overlay['priority']:
+if 'priority' in overlay:
 self.priority = int(overlay['priority'])
 else:
 self.priority = 50
 
-h = overlay['homepage']
-if h != None:
-self.homepage = encode(h)
+if 'homepage' in overlay:
+self.homepage = encode(overlay['homepage'])
 else:
 self.homepage = None
 
-self.feeds = [encode(e) \
-for e in overlay['feeds']]
+if 'feed' in overlay:
+self.feeds = [encode(e) \
+for e in overlay['feeds']]
+else:
+self.feeds = None
 
-_irc = overlay['irc']
-if _irc != None:
-self.irc = encode(_irc)
+if 'irc' in overlay:
+self.irc = encode(overlay['irc'])
 else:
 self.irc = None
 
-_branch = overlay['branch']
-if _branch != None:
-self.branch = encode(_branch)
+if 'branch' in 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/, layman/tests/

2014-06-15 Thread Brian Dolbec
commit: b47238ef6ef407c7c07a94b885b7243a089c797f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu Jun 12 21:17:02 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sun Jun 15 00:36:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b47238ef

Implements the with syntax to open files

---
 layman/dbbase.py | 10 +-
 layman/makeconf.py   | 16 +---
 layman/overlays/tar.py   |  9 +
 layman/remotedb.py   | 14 ++
 layman/reposconf.py  |  6 --
 layman/tests/external.py |  5 ++---
 6 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 92d5cf9..e17e8f3 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -131,8 +131,8 @@ class DbBase(object):
 '''Read the overlay definition file.'''
 
 try:
-df = fileopen(path, 'r')
-document = df.read()
+with fileopen(path, 'r') as df:
+document = df.read()
 
 except Exception as error:
 if not self.ignore_init_read_errors:
@@ -235,9 +235,9 @@ class DbBase(object):
 indent(tree)
 tree = ET.ElementTree(tree)
 try:
-f = fileopen(path, 'w')
-tree.write(f, encoding=_UNICODE)
-f.close()
+with fileopen(path, 'w') as f:
+ tree.write(f, encoding=_UNICODE)
+
 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 f1eba09..15ad537 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -22,7 +22,7 @@ import codecs
 import re
 
 from layman.utils import path
-from layman.compatibility import cmp_to_key
+from layman.compatibility import cmp_to_key, fileopen
 
 
#===
 #
@@ -276,11 +276,8 @@ class ConfigHandler:
 return False
 
 try:
-make_conf = codecs.open(self.path, 'w', 'utf-8')
-
-make_conf.write(content)
-
-make_conf.close()
+ with fileopen(self.path, 'w') as make_conf:
+make_conf.write(content)
 
 except Exception as error:
 self.output.error('MakeConf: ConfigHandler.write(); Failed to 
write '\
@@ -293,11 +290,8 @@ class ConfigHandler:
 Returns the content of the /var/lib/layman/make.conf file.
 '''
 try:
-make_conf = codecs.open(self.path, 'r', 'utf-8')
-
-self.data = make_conf.read()
-
-make_conf.close()
+with fileopen(self.path, 'r') as make_conf:
+self.data = make_conf.read()
 
 except Exception as error:
 self.output.error('ConfigHandler: content(); Failed to read '\

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index acbeece..fc15c56 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -34,8 +34,9 @@ import tempfile
 
 import xml.etree.ElementTree as ET # Python 2.5
 
-from   layman.utils import path
+from   layman.compatibility import fileopen
 from   layman.overlays.source   import OverlaySource, require_supported
+from   layman.utils import path
 from   layman.version   import VERSION
 from   sslfetch.connections import Connector
 
@@ -120,9 +121,9 @@ class TarOverlay(OverlaySource):
 pkg = path([base, self.parent.name + ext])
 
 try:
-out_file = open(pkg, 'w+b')
-out_file.write(tar)
-out_file.close()
+with fileopen(pkg, 'w+b') as out_file:
+out_file.write(tar)
+
 except Exception as error:
 raise Exception('Failed to store tar package in '
 + pkg + '\nError was:' + str(error))

diff --git a/layman/remotedb.py b/layman/remotedb.py
index f883799..79f4ec6 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -17,7 +17,6 @@
 '''Handles different storage files.'''
 
 from __future__ import unicode_literals
-from __future__ import with_statement
 
 __version__ = $Id: db.py 309 2007-04-09 16:23:38Z wrobel $
 
@@ -261,8 +260,9 @@ class RemoteDB(DbBase):
 if url_timestamp != timestamp:
 self.output.debug('RemoteDB._fetch_file() opening file', 2)
 # Fetch the remote list
-with open(filepath) as connection:
+with fileopen(filepath) as connection:
 olist = connection.read()
+
 else:
 self.output.info('Remote list already up to date: %s'
 % url, 4)
@@ -324,14 +324,12 @@ class RemoteDB(DbBase):
 def write_cache(olist, mpath, tpath=None, timestamp=None):
 has_updates = False
 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-06-15 Thread Brian Dolbec
commit: e5aeb45de0db5912b57f1574562fc7d474afaa67
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri Jun  6 21:18:14 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sat Jun 14 22:07:34 2014 +
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 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: b5e16c46fd286a3df26923366dd2c4b0a4acaa9f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed Jun 11 18:43:08 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sun Jun 15 00:36:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b5e16c46

{cvs, tar}.py: Fixes assignment for self.branch

Fixes commit: fix undefined 'subpath', update tests
SHA:0fde69e7ef993c3e5cca925cef35c8c895cfd834
Author: dol-sen brian.dolbec AT gmail.com
Date: Sat 23 Jul 2011 02:44:26 AM EDT

Fixes commit: removal of xml from the vcs class parameters.
SHA: ba5f0cd5c948bb7a65ab21008c940caf0fbe38e7
Author: Brian Dolbec brian.dolbec AT gmail.com
Date: Thu 24 Feb 2011 01:49:58 AM EST

---
 layman/overlays/cvs.py | 2 +-
 layman/overlays/tar.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index a8c6abb..70638e3 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -47,7 +47,7 @@ class CvsOverlay(OverlaySource):
 def __init__(self, parent, config, _location, ignore = 0):
 
 super(CvsOverlay, self).__init__(parent, config, _location, ignore)
-self.branch = None
+self.branch = self.parent.branch
 
 
 def add(self, base):

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 884d527..acbeece 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -93,7 +93,7 @@ class TarOverlay(OverlaySource):
 
 self.output = config['output']
 self.proxies = config.proxies
-self.branch = None
+self.branch = self.parent.branch
 
 
 def _extract(self, base, tar_url, dest_dir):



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: 2c8417794872d797ef816760d5d9161c90f449fc
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri May 30 01:19:52 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:49 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2c841779

mercurial.py: Adds update() function

Also adds _fix_mercurial_source() function to be used by add() and update().

---
 layman/overlays/mercurial.py | 40 
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index c188381..74f1934 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -27,6 +27,7 @@ __version__ = $Id: mercurial.py 236 2006-09-05 20:39:37Z 
wrobel $
 #
 
#---
 
+import re
 from   layman.utils import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -49,6 +50,16 @@ class MercurialOverlay(OverlaySource):
 config, _location, ignore)
 self.subpath = None
 
+def _fix_mercurial_source(self, source):
+'''
+Adds trailing slash to source URL if needed.
+
+@params source: source URL, string.
+'''
+if source.endswith(/):
+return source
+return source + '/'
+
 def add(self, base):
 '''Add overlay.'''
 
@@ -58,10 +69,7 @@ class MercurialOverlay(OverlaySource):
 cfg_opts = self.config[mercurial_addopts]
 target = path([base, self.parent.name])
 
-if self.src.endswith(/):
-src = self.src
-else:
-src = self.src + '/'
+src = self._fix_mercurial_source(self.src)
 
 # hg clone SOURCE TARGET
 if len(cfg_opts):
@@ -73,6 +81,30 @@ class MercurialOverlay(OverlaySource):
 self.run_command(self.command(), args, cmd=self.type),
 cwd=target)
 
+def update(self, base, src):
+'''
+Updates overlay src-url.
+
+@params base: base location where all overlays are installed.
+@params src: source URL.
+'''
+
+if not self.supported():
+return 1
+
+target = path([base, self.parent.name])
+hgrc = .hg/hgrc
+
+old_src = re.sub('/', '\/', self._fix_mercurial_source(self.src))
+new_src = re.sub('/', '\/', self._fix_mercurial_source(src))
+expression = s/ + old_src + / + new_src + /
+
+# sed -i 's/oldurl/newurl/' target/.hg/hgrc
+args = ['-i', expression, hgrc]
+
+# Run sed.
+return self.run_command('sed', args, cmd='sed', cwd=target)
+
 def sync(self, base):
 '''Sync overlay.'''
 



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-06-15 Thread Brian Dolbec
commit: 0764934ac9670197a051af437f586d5594235c80
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri May 23 21:25:08 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:49 2014 +
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



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: a189742b6940cf15e078fd952c1fd9daa61951b0
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu Jun 12 21:42:20 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sun Jun 15 00:36:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a189742b

tar.py: Adds file:// support for tar overlays

---
 layman/overlays/tar.py | 40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index fc15c56..e5d10b6 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -99,6 +99,7 @@ class TarOverlay(OverlaySource):
 
 def _extract(self, base, tar_url, dest_dir):
 ext = '.tar.noidea'
+clean_tar = True
 for i in [('tar.%s' % e) for e in ('bz2', 'gz', 'lzma', 'xz', 'Z')] \
 + ['tgz', 'tbz', 'taz', 'tlz', 'txz']:
 candidate_ext = '.%s' % i
@@ -106,33 +107,38 @@ class TarOverlay(OverlaySource):
 ext = candidate_ext
 break
 
-# setup the ssl-fetch output map
-connector_output = {
-'info':  self.output.debug,
-'error': self.output.error,
-'kwargs-info': {'level': 2},
-'kwargs-error':{'level': None},
-}
+if 'file://' not in tar_url:
+# setup the ssl-fetch output map
+connector_output = {
+'info':  self.output.debug,
+'error': self.output.error,
+'kwargs-info': {'level': 2},
+'kwargs-error':{'level': None},
+}
 
-fetcher = Connector(connector_output, self.proxies, USERAGENT)
+fetcher = Connector(connector_output, self.proxies, USERAGENT)
 
-success, tar, timestamp = fetcher.fetch_content(tar_url)
+success, tar, timestamp = fetcher.fetch_content(tar_url)
 
-pkg = path([base, self.parent.name + ext])
+pkg = path([base, self.parent.name + ext])
 
-try:
-with fileopen(pkg, 'w+b') as out_file:
-out_file.write(tar)
+try:
+with fileopen(pkg, 'w+b') as out_file:
+out_file.write(tar)
 
-except Exception as error:
-raise Exception('Failed to store tar package in '
-+ pkg + '\nError was:' + str(error))
+except Exception as error:
+raise Exception('Failed to store tar package in '
++ pkg + '\nError was:' + str(error))
+else:
+clean_tar = False
+pkg = tar_url.replace('file://', '')
 
 # tar -v -x -f SOURCE -C TARGET
 args = ['-v', '-x', '-f', pkg, '-C', dest_dir]
 result = self.run_command(self.command(), args, cmd=self.type)
 
-os.unlink(pkg)
+if clean_tar:
+os.unlink(pkg)
 return result
 
 def _add_unchecked(self, base):



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: 10881a57c8b438b4b4e984ebdb375d14fb63d474
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed Jun 11 05:22:51 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sun Jun 15 00:36:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=10881a57

mercurial.py: Adds module branch support

---
 layman/overlays/mercurial.py | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 7a5fe08..a1b7846 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -28,6 +28,8 @@ __version__ = $Id: mercurial.py 236 2006-09-05 20:39:37Z 
wrobel $
 
#---
 
 import re
+import xml.etree.ElementTree as ET
+
 from   layman.utils import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -48,7 +50,8 @@ class MercurialOverlay(OverlaySource):
 
 super(MercurialOverlay, self).__init__(parent,
 config, _location, ignore)
-self.branch = None
+self.branch = self.parent.branch
+
 
 def _fix_mercurial_source(self, source):
 '''
@@ -77,6 +80,10 @@ class MercurialOverlay(OverlaySource):
 else:
 args = ['clone', src, target]
 
+if self.branch:
+args.append('-r')
+args.append(self.branch)
+
 return self.postsync(
 self.run_command(self.command(), args, cmd=self.type),
 cwd=target)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: 323362ad64d9b0477a662c0d58eeec89e7e3948e
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu May 29 23:12:58 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:49 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=323362ad

bzr.py: Adds update() function

Also adds _fix_brz_source() function to be used by add() and update().

---
 layman/overlays/bzr.py | 36 
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 9cfa8b5..20d2491 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -49,6 +49,16 @@ class BzrOverlay(OverlaySource):
 config, _location, ignore)
 self.subpath = None
 
+def _fix_bzr_source(self, source):
+'''
+Adds trailing slash to source URL if needed.
+
+@params source: source URL, string.
+'''
+if source.endswith(/):
+return source
+return source + '/'
+
 def add(self, base):
 '''Add overlay.'''
 
@@ -58,10 +68,7 @@ class BzrOverlay(OverlaySource):
 cfg_opts = self.config[bzr_addopts]
 target = path([base, self.parent.name])
 
-if self.src.endswith(/):
-src = self.src
-else:
-src = self.src + '/'
+src = self._fix_bzr_source(self.src)
 
 # bzr get SOURCE TARGET
 if len(cfg_opts):
@@ -73,6 +80,27 @@ class BzrOverlay(OverlaySource):
 self.run_command(self.command(), args, cmd=self.type),
 cwd=target)
 
+def update(self, base, src):
+'''
+Updates overlay src-url.
+
+@params base: base location where all overlays are installed.
+@params src: source URL.
+'''
+
+if not self.supported():
+return 1
+
+target = path([base, self.parent.name])
+
+# bzr bind SOURCE
+args = ['bind', self._fix_bzr_source(src)]
+if self.config['quiet']:
+args.append('--quiet')
+return self.postsync(
+self.run_command(self.command(), args, cmd=self.type),
+cwd=target)
+
 def sync(self, base):
 '''Sync overlay.'''
 



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: 70e221ba1921d2275bbd415e20a5d9923d329b44
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Tue Jun 10 22:18:23 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sun Jun 15 00:36:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=70e221ba

git.py: Adds module branch support

---
 layman/overlays/git.py | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 2f4bd61..f3ada66 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -26,6 +26,8 @@ __version__ = $Id: git.py 146 2006-05-27 09:52:36Z wrobel $
 #
 
#---
 
+import xml.etree.ElementTree as ET
+
 from   layman.utils import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -44,7 +46,7 @@ class GitOverlay(OverlaySource):
 def __init__(self, parent, config, _location, ignore = 0):
 super(GitOverlay, self).__init__(parent, config,
 _location, ignore)
-self.branch = None
+self.branch = self.parent.branch
 
 
 def _fix_git_source(self, source):
@@ -76,6 +78,10 @@ class GitOverlay(OverlaySource):
 args.append(cfg_opts)
 args.append(self._fix_git_source(self.src))
 args.append(target)
+
+if self.branch:
+args.append('-b')
+args.append(self.branch)
 success = False
 # adding cwd=base due to a new git bug in selinux due to
 # not having user_home_dir_t and portage_fetch_t permissions



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-06-15 Thread Brian Dolbec
commit: fda51375fed8b54e264e4577fb3d72385bbffa17
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri May 23 18:37:51 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:50 2014 +
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)]
 



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: e44f6726b5162cbc3026e9047878e2def78a562a
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri May 30 20:54:12 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:49 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e44f6726

cvs.py: Adds update() function

---
 layman/overlays/cvs.py | 37 +
 1 file changed, 37 insertions(+)

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index b166dc8..bf54921 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -27,6 +27,7 @@ __version__ = $Id$
 
#---
 
 import xml.etree.ElementTree as ET # Python 2.5
+import re
 
 from   layman.utils import path
 from   layman.overlays.source   import OverlaySource, require_supported
@@ -90,6 +91,42 @@ class CvsOverlay(OverlaySource):
 env=dict(CVSROOT=self.src), cmd=self.type),
 cwd=target)
 
+def update(self, base, src):
+'''
+Updates overlay src-url.
+
+@params base: base location where all overlays are installed.
+@params src: source URL.
+'''
+
+if not self.supported():
+return 1
+
+target = path([base, self.parent.name])
+
+# First echo the new repository to CVS/Root
+args = [src, '', '/CVS/Root']
+result = self.run_command('echo', args, cmd='echo', cwd=target)
+
+if result == 0:
+location = src.split(':')[3]
+old_location = self.src.split(':/')[3]
+
+# Check if the repository location needs to be updated too.
+if not location == old_location:
+location = re.sub('/', '\/', location)
+old_location = re.sub('/', '\/', old_location)
+
+expression = 's/' + old_location + '/' + location + '/'
+
+# sed -i 's/old_location/new_location/ 
target/CVS/Repository
+args = ['-i', expression, '/CVS/Repository']
+
+return self.run_command('sed', args, cmd='sed', cwd=target)
+
+return result
+
+
 def sync(self, base):
 '''Sync overlay.'''
 



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: a4ce4f5a312c08eb90ccb741f673780b8559d0c4
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Fri May 23 21:33:47 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:49 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a4ce4f5a

git.py: adds update() function

Moves the fix_git_source() function to allow both add() and update()
to make use of it. While the update() function calls git remote
set-url, replacing the old url with the new url provided by
overlay.update().

---
 layman/overlays/git.py | 38 --
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index f3790ca..ee8c53b 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -46,21 +46,24 @@ class GitOverlay(OverlaySource):
 _location, ignore)
 self.subpath = None
 
+def _fix_git_source(self, source):
+'''
+Adds trailing slash to http sources
+
+@param source: source URL, string.
+'''
+# http:// should get trailing slash, other protocols shouldn't
+if source.split(':')[:1] == 'http':
+if not source.endswith('/'):
+return source + '/'
+return source
+
 def add(self, base):
 '''Add overlay.'''
 
 if not self.supported():
 return 1
 
-def fix_git_source(source):
-# http:// should get trailing slash, other protocols shouldn't
-if source.split(':')[0] == 'http':
-if source.endswith('/'):
-return source
-else:
-return source + '/'
-return source
-
 cfg_opts = self.config[git_addopts]
 target = path([base, self.parent.name])
 
@@ -70,7 +73,7 @@ class GitOverlay(OverlaySource):
 args.append('-q')
 if len(cfg_opts):
 args.append(cfg_opts)
-args.append(fix_git_source(self.src))
+args.append(self._fix_git_source(self.src))
 args.append(target)
 success = False
 # adding cwd=base due to a new git bug in selinux due to
@@ -95,6 +98,21 @@ class GitOverlay(OverlaySource):
 self.output.debug(set git user info...args=%s % ' '.join(args), 8)
 return self.run_command(self.command(), args, cmd=self.type, 
cwd=target)
 
+def update(self, base, src):
+'''
+Update overlay src-url
+
+@params base: base location where all overlays are installed.
+@params src:  source URL.
+'''
+self.output.debug(git.update(); starting...%s % self.parent.name, 6)
+target = path([base, self.parent.name])
+
+# git remote set-url name newurl oldurl
+args = ['remote', 'set-url', 'origin', self._fix_git_source(src), 
self._fix_git_source(self.src)]
+
+return self.run_command(self.command(), args, cmd=self.type, 
cwd=target)
+
 def sync(self, base):
 '''Sync overlay.'''
 



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/, doc/

2014-06-15 Thread Brian Dolbec
commit: 8f39978eb3940a96413b8405ae2dc199507e329d
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Sat Jun 14 21:59:14 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Sun Jun 15 00:36:41 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=8f39978e

Adds clean_tar configuration option

---
 doc/layman.8.txt   | 6 ++
 layman/config.py   | 3 ++-
 layman/overlays/tar.py | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/layman.8.txt b/doc/layman.8.txt
index 0819570..3918d37 100644
--- a/doc/layman.8.txt
+++ b/doc/layman.8.txt
@@ -240,6 +240,12 @@ nocheck::
 Set to yes if *layman* should stop worrying about overlays
 with missing a contact address or the description.
 
+clean_tar::
+Set to yes if *layman* will delete tar files downloaded
+when installing tar overlays. 'Note':: This option is only
+applicable to remote tar overlays. *layman* will leave the
+reponsibility of deleting local tar files up to the user.
+By default, *layman* will delete downloaded tar files.
 
 Per repository type Add, Sync options.
 

diff --git a/layman/config.py b/layman/config.py
index 31dc0ac..761dd57 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -107,6 +107,7 @@ class BareConfig(object):
 'auto_sync': 'No',
 'conf_type': 'make.conf',
 'require_repoconfig': 'Yes',
+'clean_tar': 'yes',
 'make_conf' : '%(storage)s/make.conf',
 'repos_conf': '/etc/portage/repos.conf/layman.conf',
 'conf_module': ['make_conf', 'repos_conf'],
@@ -132,7 +133,7 @@ class BareConfig(object):
 'rsync_command': path([self.root, EPREFIX,'/usr/bin/rsync']),
 'svn_command': path([self.root, EPREFIX,'/usr/bin/svn']),
 'tar_command': path([self.root, EPREFIX,'/bin/tar']),
-'t/f_options': ['nocheck', 'require_repoconfig'],
+'t/f_options': ['clean_tar', 'nocheck', 'require_repoconfig'],
 'bzr_addopts' : '',
 'bzr_syncopts' : '',
 'cvs_addopts' : '',

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index e5d10b6..4999e20 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -99,7 +99,7 @@ class TarOverlay(OverlaySource):
 
 def _extract(self, base, tar_url, dest_dir):
 ext = '.tar.noidea'
-clean_tar = True
+clean_tar = self.config['clean_tar']
 for i in [('tar.%s' % e) for e in ('bz2', 'gz', 'lzma', 'xz', 'Z')] \
 + ['tgz', 'tbz', 'taz', 'tlz', 'txz']:
 candidate_ext = '.%s' % i



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-06-15 Thread Brian Dolbec
commit: ef6f5893a333684f3b73e04e486b02b60559c512
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Mon May 26 22:22:33 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Thu Jun 12 21:11:49 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ef6f5893

svn.py: Adds update() function

Adds _fix_svn_source() function to correct the source url in
order to run the svn switch --relocate command.

---
 layman/overlays/svn.py | 37 -
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 0244dd4..f494eba 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -53,6 +53,18 @@ class SvnOverlay(OverlaySource):
 parent, config, _location, ignore)
 self.subpath = None
 
+def _fix_svn_source(self, source):
+'''
+Adds @ to all sources that don't already include it.
+
+@params source: source URL, string.
+'''
+if source.endswith(/):
+source = source + '@'
+else:
+source = source +'/@'
+return source
+
 def add(self, base):
 '''Add overlay.'''
 
@@ -70,11 +82,7 @@ class SvnOverlay(OverlaySource):
 if len(cfg_opts):
 args.append(cfg_opts)
 
-if self.src.endswith(/):
-src = self.src + '@'
-else:
-src = self.src + '/@'
-
+src = self._fix_svn_source(self.src)
 args.append(src)
 args.append(self.target)
 
@@ -82,6 +90,25 @@ class SvnOverlay(OverlaySource):
 self.run_command(self.command(), args, cmd=self.type),
 cwd=self.target)
 
+def update(self, base, src):
+'''
+Update overlay src-url
+
+@params base: base location where all overlays are installed.
+@params src: source URL.
+'''
+
+self.output.debug(svn.update(); starting...%s % self.parent.name, 6)
+target = path([base, self.parent.name])
+
+# svn switch --relocate oldurl newurl
+args = ['switch', '--relocate', self._fix_svn_source(self.src), 
self._fix_svn_source(src)]
+
+return self.postsync(
+ self.run_command(self.command(), args, cmd=self.type),
+ cwd=target)
+
+
 def sync(self, base):
 '''Sync overlay.'''
 



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-15 Thread Devan Franchini
commit: 07dcf53ca7717085af91bc391b08074a2cd88a8f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu May 15 20:25:37 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu May 15 20:25:37 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=07dcf53c

output.py: Migrates output mappings.

remotedb.py, tar.py: Removes output mappings necessary for ssl-fetch
usage in favor of mapping them in output.py to avoid mapping the
functions in more than one place.

---
 layman/output.py   | 11 +++
 layman/overlays/tar.py |  4 ++--
 layman/remotedb.py |  4 ++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ef348f5..0c19ab9 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -124,6 +124,11 @@ class Message(MessageBase):
 
 MessageBase.__init__(self, out, err, info_level, warn_level,
 note_level, col, error_callback)
+
+# Maps output functions for compatibility with ssl-fetch
+# output calls.
+self.output.write = self.output.info
+self.output.print_err = self.output.error
 
 
 ## Output Functions
@@ -161,6 +166,9 @@ class Message(MessageBase):
 for i in info.split('\n'):
 print( %s %s % (self.color_func('green', '*'),i), 
file=self.std_out)
 
+# Maps info function to write function
+# for ssl-fetch usage.
+write = info
 
 def status (self, message, status, info = 'ignored'):
 
@@ -218,6 +226,9 @@ class Message(MessageBase):
 self.std_out.flush()
 self.do_error_callback(error)
 
+# Maps error function with print_err function
+# for ssl-fetch usage.
+print_err = error
 
 def die (self, error):
 

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 94fefb1..8574f1a 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -126,8 +126,8 @@ class TarOverlay(OverlaySource):
 
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 success, tar, timestamp = fetcher.fetch_content(tar_url)
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 24ee8b8..959b090 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -150,8 +150,8 @@ class RemoteDB(DbBase):
 fetcher = Connector(self.output, self.proxies, USERAGENT)
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 for index in range(0, 3):
 self.output.debug(RemoteDB.cache() index = %s %str(index), 2)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-15 Thread Devan Franchini
commit: 9b206b1c201d8c36f503e64588a431411270c1d7
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu May 15 20:25:37 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu May 15 20:35:49 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=9b206b1c

output.py: Migrates output mappings

remotedb.py, tar.py: Removes output mappings necessary for ssl-fetch
usage in favor of mapping them in output.py to avoid mapping the
functions in more than one place.

---
 layman/output.py   | 9 +++--
 layman/overlays/tar.py | 4 ++--
 layman/remotedb.py | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ef348f5..a6c2c20 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -124,8 +124,7 @@ class Message(MessageBase):
 
 MessageBase.__init__(self, out, err, info_level, warn_level,
 note_level, col, error_callback)
-
-
+
 ## Output Functions
 
 def debug(self, info, level = OFF):
@@ -161,6 +160,9 @@ class Message(MessageBase):
 for i in info.split('\n'):
 print( %s %s % (self.color_func('green', '*'),i), 
file=self.std_out)
 
+# Maps info function to write function
+# for ssl-fetch usage.
+write = info
 
 def status (self, message, status, info = 'ignored'):
 
@@ -218,6 +220,9 @@ class Message(MessageBase):
 self.std_out.flush()
 self.do_error_callback(error)
 
+# Maps error function with print_err function
+# for ssl-fetch usage.
+print_err = error
 
 def die (self, error):
 

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 94fefb1..8574f1a 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -126,8 +126,8 @@ class TarOverlay(OverlaySource):
 
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 success, tar, timestamp = fetcher.fetch_content(tar_url)
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 24ee8b8..959b090 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -150,8 +150,8 @@ class RemoteDB(DbBase):
 fetcher = Connector(self.output, self.proxies, USERAGENT)
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 for index in range(0, 3):
 self.output.debug(RemoteDB.cache() index = %s %str(index), 2)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-15 Thread Devan Franchini
commit: bf10389bf1c5e767ce66f34d38aefdb53b6a966c
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu May 15 20:25:37 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Thu May 15 20:45:50 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=bf10389b

output.py: Migrates output mappings

remotedb.py, tar.py: Removes output mappings necessary for ssl-fetch
usage in favor of mapping them in output.py to avoid mapping the
functions in more than one place.

---
 layman/output.py   | 9 +++--
 layman/overlays/tar.py | 4 ++--
 layman/remotedb.py | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ef348f5..a6c2c20 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -124,8 +124,7 @@ class Message(MessageBase):
 
 MessageBase.__init__(self, out, err, info_level, warn_level,
 note_level, col, error_callback)
-
-
+
 ## Output Functions
 
 def debug(self, info, level = OFF):
@@ -161,6 +160,9 @@ class Message(MessageBase):
 for i in info.split('\n'):
 print( %s %s % (self.color_func('green', '*'),i), 
file=self.std_out)
 
+# Maps info function to write function
+# for ssl-fetch usage.
+write = info
 
 def status (self, message, status, info = 'ignored'):
 
@@ -218,6 +220,9 @@ class Message(MessageBase):
 self.std_out.flush()
 self.do_error_callback(error)
 
+# Maps error function with print_err function
+# for ssl-fetch usage.
+print_err = error
 
 def die (self, error):
 

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 94fefb1..8574f1a 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -126,8 +126,8 @@ class TarOverlay(OverlaySource):
 
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 success, tar, timestamp = fetcher.fetch_content(tar_url)
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 24ee8b8..959b090 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -150,8 +150,8 @@ class RemoteDB(DbBase):
 fetcher = Connector(self.output, self.proxies, USERAGENT)
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 for index in range(0, 3):
 self.output.debug(RemoteDB.cache() index = %s %str(index), 2)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-15 Thread Devan Franchini
commit: f4f4defbcd5365ae362675805faad4df4d642c3f
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu May 15 20:25:37 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri May 16 00:58:20 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f4f4defb

output.py: Migrates output mappings

remotedb.py, tar.py: Removes output mappings necessary for ssl-fetch
usage in favor of mapping them in output.py to avoid mapping the
functions in more than one place.

---
 layman/output.py   | 9 +++--
 layman/overlays/tar.py | 4 ++--
 layman/remotedb.py | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ef348f5..a6c2c20 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -124,8 +124,7 @@ class Message(MessageBase):
 
 MessageBase.__init__(self, out, err, info_level, warn_level,
 note_level, col, error_callback)
-
-
+
 ## Output Functions
 
 def debug(self, info, level = OFF):
@@ -161,6 +160,9 @@ class Message(MessageBase):
 for i in info.split('\n'):
 print( %s %s % (self.color_func('green', '*'),i), 
file=self.std_out)
 
+# Maps info function to write function
+# for ssl-fetch usage.
+write = info
 
 def status (self, message, status, info = 'ignored'):
 
@@ -218,6 +220,9 @@ class Message(MessageBase):
 self.std_out.flush()
 self.do_error_callback(error)
 
+# Maps error function with print_err function
+# for ssl-fetch usage.
+print_err = error
 
 def die (self, error):
 

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 94fefb1..8574f1a 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -126,8 +126,8 @@ class TarOverlay(OverlaySource):
 
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 success, tar, timestamp = fetcher.fetch_content(tar_url)
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 24ee8b8..959b090 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -150,8 +150,8 @@ class RemoteDB(DbBase):
 fetcher = Connector(self.output, self.proxies, USERAGENT)
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 for index in range(0, 3):
 self.output.debug(RemoteDB.cache() index = %s %str(index), 2)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-15 Thread Devan Franchini
commit: d827daeb694f4d91fdeff15143b738438c1ce415
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 23:07:30 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri May 16 01:06:46 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d827daeb

remotedb.py, tar.py: Implements ssl-fetch code

Migrate to using ssl-fetch (urllib3 based) for downloading files.

---
 layman/overlays/tar.py |  30 ++
 layman/remotedb.py | 108 +++--
 2 files changed, 37 insertions(+), 101 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 9cb65a2..94fefb1 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -24,12 +24,16 @@ __version__ = $Id: tar.py 310 2007-04-09 16:30:40Z wrobel 
$
 #
 
#---
 
-import os, os.path, sys, urllib2, shutil, tempfile
+import os, os.path, sys, shutil
+
 import xml.etree.ElementTree as ET # Python 2.5
 
 from   layman.utils import path
-#from   layman.debug import OUT
 from   layman.overlays.source   import OverlaySource, require_supported
+from   layman.version   import VERSION
+from   sslfetch.connections import Connector
+
+USERAGENT = Layman + VERSION
 
 
#===
 #
@@ -78,6 +82,15 @@ 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)
 
@@ -109,11 +122,14 @@ class TarOverlay(OverlaySource):
 ext = candidate_ext
 break
 
-try:
-tar = urllib2.urlopen(tar_url).read()
-except Exception as error:
-raise Exception('Failed to fetch the tar package from: '
-+ self.src + '\nError was:' + str(error))
+fetcher = Connector(self.output, self.proxies, USERAGENT)
+
+# Maps output functions for compatibility with ssl-fetch
+# output calls.
+self.output.write = self.output.info
+self.output.print_err = self.output.error
+
+success, tar, timestamp = fetcher.fetch_content(tar_url)
 
 pkg = path([base, self.parent.name + ext])
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index b010e51..24ee8b8 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -17,6 +17,7 @@
 '''Handles different storage files.'''
 
 from __future__ import with_statement
+from __future__ import unicode_literals
 
 __version__ = $Id: db.py 309 2007-04-09 16:23:38Z wrobel $
 
@@ -30,28 +31,6 @@ import os, os.path
 import sys
 import hashlib
 
-import requests
-from requests.exceptions import SSLError
-
-VERIFY_SSL = False
-# py3.2
-if sys.hexversion = 0x30200f0:
-VERIFY_SSL = True
-else:
-try: # import and enable SNI support for py2
-from requests.packages.urllib3.contrib import pyopenssl
-pyopenssl.inject_into_urllib3()
-VERIFY_SSL = True
-VERIFY_MSGS = [Successfully enabled ssl certificate verification.]
-except ImportError as e:
-VERIFY_MSGS = [
-Failed to import and inject pyopenssl/SNI support into urllib3,
-Disabling certificate verification,
-Error was: + e
-]
-VERIFY_SSL = False
-
-
 GPG_ENABLED = False
 try:
 from pygpg.config import GPGConfig
@@ -64,8 +43,10 @@ except ImportError:
 from   layman.utils import encoder
 from   layman.dbbaseimport DbBase
 from   layman.version   import VERSION
-from layman.compatibility   import fileopen
+from   layman.compatibility import fileopen
+from   sslfetch.connections import Connector  
 
+USERAGENT = Layman- + VERSION
 
 class RemoteDB(DbBase):
 '''Handles fetching the remote overlay list.'''
@@ -88,10 +69,6 @@ class RemoteDB(DbBase):
 self.urls  = [i.strip()
 for i in config['overlays'].split('\n') if len(i)]
 
-if VERIFY_MSGS:
-for msg in VERIFY_MSGS:
-self.output.debug(msg, 2)
-
 if GPG_ENABLED:
 self.get_gpg_urls()
 else:
@@ -113,7 +90,6 @@ class RemoteDB(DbBase):
 
 self.output.debug('RemoteDB.__init__(), paths to load = %s' 
%str(paths),
 2)
-
 if config['nocheck']:
 ignore = 2
 else:
@@ -171,6 +147,12 @@ class RemoteDB(DbBase):
 succeeded = True
 url_lists = [self.urls, self.detached_urls, self.signed_urls]
 need_gpg 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-15 Thread Devan Franchini
commit: 4ea75fa8beb75e7e9be74b2dc4bebca0a808ad37
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Thu May 15 20:25:37 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Fri May 16 01:06:46 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4ea75fa8

output.py: Migrates output mappings

remotedb.py, tar.py: Removes output mappings necessary for ssl-fetch
usage in favor of mapping them in output.py to avoid mapping the
functions in more than one place.

---
 layman/output.py   | 9 +++--
 layman/overlays/tar.py | 4 ++--
 layman/remotedb.py | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ef348f5..a6c2c20 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -124,8 +124,7 @@ class Message(MessageBase):
 
 MessageBase.__init__(self, out, err, info_level, warn_level,
 note_level, col, error_callback)
-
-
+
 ## Output Functions
 
 def debug(self, info, level = OFF):
@@ -161,6 +160,9 @@ class Message(MessageBase):
 for i in info.split('\n'):
 print( %s %s % (self.color_func('green', '*'),i), 
file=self.std_out)
 
+# Maps info function to write function
+# for ssl-fetch usage.
+write = info
 
 def status (self, message, status, info = 'ignored'):
 
@@ -218,6 +220,9 @@ class Message(MessageBase):
 self.std_out.flush()
 self.do_error_callback(error)
 
+# Maps error function with print_err function
+# for ssl-fetch usage.
+print_err = error
 
 def die (self, error):
 

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 94fefb1..8574f1a 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -126,8 +126,8 @@ class TarOverlay(OverlaySource):
 
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 success, tar, timestamp = fetcher.fetch_content(tar_url)
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 24ee8b8..959b090 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -150,8 +150,8 @@ class RemoteDB(DbBase):
 fetcher = Connector(self.output, self.proxies, USERAGENT)
 # Maps output functions for compatibility with ssl-fetch
 # output calls.
-self.output.write = self.output.info
-self.output.print_err = self.output.error
+#self.output.write = self.output.info
+#self.output.print_err = self.output.error
 
 for index in range(0, 3):
 self.output.debug(RemoteDB.cache() index = %s %str(index), 2)



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: 6d1c59d9c9da4d975019f6bc0a243361c8987e76
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 03:56:31 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 17:31:29 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6d1c59d9

Adds unicode string compatibility support.

This commit allows string compatibility between py2 and py3 as well as
ensuring that the necessary strings that need to be unicode, stay
unicode in both py2 and py3 when running layman.

---
 layman/api.py  | 20 ---
 layman/db.py   | 10 
 layman/dbbase.py   |  8 +++---
 layman/makeconf.py | 22 
 layman/overlays/overlay.py | 62 --
 layman/remotedb.py |  2 +-
 layman/utils.py|  4 ++-
 7 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 475691b..cbf3f76 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -13,6 +13,8 @@
 #  Brian Dolbec dol-...@sourceforge.net
 #
 
+from __future__ import print_function
+
 import os
 
 from layman.config import BareConfig
@@ -428,21 +430,21 @@ class LaymanAPI(object):
  b.close()
 
  api.get_available()
-[u'wrobel', u'wrobel-stable']
- all = api.get_all_info(u'wrobel')
+['wrobel', 'wrobel-stable']
+ all = api.get_all_info('wrobel')
  info = all['wrobel']
  info['status']
-u'official'
+'official'
  info['description']
-u'Test'
+'Test'
  info['sources']
-[(u'https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
+[('https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
 
-#{u'wrobel': {'status': u'official',
-#'owner_name': None, 'description': u'Test',
+#{'wrobel': {'status': 'official',
+#'owner_name': None, 'description': 'Test',
 #'src_uris': generator object source_uris at 0x167c3c0,
-#'owner_email': u'nob...@gentoo.org',
-#'quality': u'experimental', 'name': u'wrobel', 'supported': True,
+#'owner_email': 'nob...@gentoo.org',
+#'quality': 'experimental', 'name': 'wrobel', 'supported': True,
 #'src_types': generator object source_types at 0x167c370,
 #'official': True,
 #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}}

diff --git a/layman/db.py b/layman/db.py
index 6530147..ce03e13 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -111,11 +111,11 @@ class DB(DbBase):
 # * Running command /usr/bin/rsync -rlptDvz --progress --delete 
--delete-after --timeout=180 --exclude=distfiles/* --exclude=local/* 
--exclude=packages/* rsync://gunnarwrobel.de/wrobel-stable/* 
/tmp/file.../wrobel-stable...
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  m = MakeConf(config, b.overlays)
 #  [i.name for i in m.overlays] #doctest: +ELLIPSIS
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  os.unlink(write)
  os.unlink(write2)
@@ -195,16 +195,16 @@ class DB(DbBase):
 # * Running command /usr/bin/svn co 
https://overlays.gentoo.org/svn/dev/wrobel/; /tmp/file.../wrobel...
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel', u'wrobel-stable']
+# ['wrobel', 'wrobel-stable']
 
 #  b.delete(b.select('wrobel'))
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  m = MakeConf(config, b.overlays)
 #  [i.name for i in m.overlays] #doctest: +ELLIPSIS
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  os.unlink(write)
  os.unlink(write2)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 475ce44..8fa3ba8 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -149,10 +149,10 @@ class DbBase(object):
  config = {'output': output, 'svn_command': '/usr/bin/svn', 
'rsync_command':'/usr/bin/rsync'}
  a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', 
])
  a.overlays.keys()
-[u'wrobel', u'wrobel-stable']
+['wrobel', 'wrobel-stable']
 
  list(a.overlays['wrobel-stable'].source_uris())
-[u'rsync://gunnarwrobel.de/wrobel-stable']
+['rsync://gunnarwrobel.de/wrobel-stable']
 '''
 try:
 document = ET.fromstring(text)
@@ -214,7 +214,7 @@ class DbBase(object):
  b.write(write)
  c = DbBase({output: Message() }, [write,])
  c.overlays.keys()
-[u'wrobel-stable']
+['wrobel-stable']
 
  os.unlink(write)
  os.rmdir(tmpdir)
@@ -245,7 +245,7 @@ class DbBase(object):
  config = {'output': 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: 134801fe7e132ca667d8a74161f850a01cceeaa8
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 00:35:07 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 17:27:29 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=134801fe

layman/{*.py, /overlays/*.py}: Exception, error to Exception as error

This changes the all instances of the phrase Exception, error to
Exception as error to allow py2/py3 compatibility.

---
 layman/api.py  | 16 
 layman/cli.py  |  2 +-
 layman/dbbase.py   |  4 ++--
 layman/makeconf.py |  4 ++--
 layman/overlays/overlay.py |  2 +-
 layman/overlays/source.py  |  2 +-
 layman/overlays/tar.py | 10 +-
 layman/remotedb.py | 10 +-
 layman/updater.py  |  2 +-
 layman/utils.py|  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 11534fd..475691b 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -113,7 +113,7 @@ class LaymanAPI(object):
 try:
 self._get_installed_db().delete(
 self._get_installed_db().select(ovl))
-except Exception, e:
+except Exception as e:
 self._error(
 Exception caught disabling repository '+ovl+
 ':\n+str(e))
@@ -147,7 +147,7 @@ class LaymanAPI(object):
 try:
 success = self._get_installed_db().add(
 self._get_remote_db().select(ovl))
-except Exception, e:
+except Exception as e:
 self._error(Exception caught enabling repository '+ovl+
 ' : +str(e))
 results.append(success)
@@ -201,7 +201,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:
@@ -255,7 +255,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)
@@ -311,7 +311,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, error:
+except UnknownOverlayException as error:
 #self.output.debug(API.sync(); UnknownOverlayException 
selecting %s %ovl, 5)
 #self._error(str(error))
 fatals.append((ovl,
@@ -364,7 +364,7 @@ class LaymanAPI(object):
 self.output.debug(API.sync(); starting db.sync(ovl), 5)
 db.sync(ovl)
 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)))
@@ -457,7 +457,7 @@ class LaymanAPI(object):
 self.output.debug(
 'LaymanAPI.fetch_remote_list(); cache updated = %s'
 % str(dbreload),8)
-except Exception, error:
+except Exception as error:
 self.output.error('Failed to fetch overlay list!\n Original Error 
was: '
 + str(error))
 return False
@@ -585,7 +585,7 @@ class LaymanAPI(object):
 elif self.config['news_reporter'] == 'pkgcore':
 # pkgcore is not yet capable
 return
-except Exception, err:
+except Exception as err:
 msg = update_news() failed running %s news reporter function\n +\
   Error was; %s
 self._error(msg % (self.config['news_reporter'], err))

diff --git a/layman/cli.py b/layman/cli.py
index a5d2799..258e3b9 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -173,7 +173,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))
 

diff --git a/layman/dbbase.py b/layman/dbbase.py
index e5c0fd9..8d57a9f 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -124,7 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-05-14 Thread Devan Franchini
commit: da99dbd4942bfbaabffc7d0b0cc4565267ec0358
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 01:13:31 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 17:31:29 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=da99dbd4

overlays/tar.py: Changes permissions integer to octal.

---
 layman/overlays/tar.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index e57096d..9cb65a2 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -169,7 +169,7 @@ class TarOverlay(OverlaySource):
 raise Exception('Failed to rename tar subdirectory ' +
 source + ' to ' + final_path +
 '\nError was:' + str(error))
-os.chmod(final_path, 0755)
+os.chmod(final_path, 0o755)
 else:
 raise Exception('Given subpath ' + source + ' does not exist 
'
 ' in the tar package!')



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: 6fb6999fce0f2257ea54a4e385100c00e286d11d
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 23:07:30 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 23:07:30 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6fb6999f

layman/{remotedb, overlays/tar}.py: Implements ssl-fetch code.

To clean up no longer necessary functions and ensure py2/py3
compatibility, functions from ssh-fetch were implemented throughout
both remotedb.py and overlays/tar.py.

---
 layman/overlays/tar.py |  30 ++
 layman/remotedb.py | 108 +++--
 2 files changed, 37 insertions(+), 101 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 9cb65a2..94fefb1 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -24,12 +24,16 @@ __version__ = $Id: tar.py 310 2007-04-09 16:30:40Z wrobel 
$
 #
 
#---
 
-import os, os.path, sys, urllib2, shutil, tempfile
+import os, os.path, sys, shutil
+
 import xml.etree.ElementTree as ET # Python 2.5
 
 from   layman.utils import path
-#from   layman.debug import OUT
 from   layman.overlays.source   import OverlaySource, require_supported
+from   layman.version   import VERSION
+from   sslfetch.connections import Connector
+
+USERAGENT = Layman + VERSION
 
 
#===
 #
@@ -78,6 +82,15 @@ 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)
 
@@ -109,11 +122,14 @@ class TarOverlay(OverlaySource):
 ext = candidate_ext
 break
 
-try:
-tar = urllib2.urlopen(tar_url).read()
-except Exception as error:
-raise Exception('Failed to fetch the tar package from: '
-+ self.src + '\nError was:' + str(error))
+fetcher = Connector(self.output, self.proxies, USERAGENT)
+
+# Maps output functions for compatibility with ssl-fetch
+# output calls.
+self.output.write = self.output.info
+self.output.print_err = self.output.error
+
+success, tar, timestamp = fetcher.fetch_content(tar_url)
 
 pkg = path([base, self.parent.name + ext])
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index b010e51..24ee8b8 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -17,6 +17,7 @@
 '''Handles different storage files.'''
 
 from __future__ import with_statement
+from __future__ import unicode_literals
 
 __version__ = $Id: db.py 309 2007-04-09 16:23:38Z wrobel $
 
@@ -30,28 +31,6 @@ import os, os.path
 import sys
 import hashlib
 
-import requests
-from requests.exceptions import SSLError
-
-VERIFY_SSL = False
-# py3.2
-if sys.hexversion = 0x30200f0:
-VERIFY_SSL = True
-else:
-try: # import and enable SNI support for py2
-from requests.packages.urllib3.contrib import pyopenssl
-pyopenssl.inject_into_urllib3()
-VERIFY_SSL = True
-VERIFY_MSGS = [Successfully enabled ssl certificate verification.]
-except ImportError as e:
-VERIFY_MSGS = [
-Failed to import and inject pyopenssl/SNI support into urllib3,
-Disabling certificate verification,
-Error was: + e
-]
-VERIFY_SSL = False
-
-
 GPG_ENABLED = False
 try:
 from pygpg.config import GPGConfig
@@ -64,8 +43,10 @@ except ImportError:
 from   layman.utils import encoder
 from   layman.dbbaseimport DbBase
 from   layman.version   import VERSION
-from layman.compatibility   import fileopen
+from   layman.compatibility import fileopen
+from   sslfetch.connections import Connector  
 
+USERAGENT = Layman- + VERSION
 
 class RemoteDB(DbBase):
 '''Handles fetching the remote overlay list.'''
@@ -88,10 +69,6 @@ class RemoteDB(DbBase):
 self.urls  = [i.strip()
 for i in config['overlays'].split('\n') if len(i)]
 
-if VERIFY_MSGS:
-for msg in VERIFY_MSGS:
-self.output.debug(msg, 2)
-
 if GPG_ENABLED:
 self.get_gpg_urls()
 else:
@@ -113,7 +90,6 @@ class RemoteDB(DbBase):
 
 self.output.debug('RemoteDB.__init__(), paths to load = %s' 
%str(paths),
 2)
-
 if config['nocheck']:
 ignore = 2
 else:
@@ -171,6 +147,12 @@ class 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: 807f7afc4398d84692a0e5f738b35b463b435dda
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 23:07:30 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 23:33:25 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=807f7afc

remotedb.py, tar.py: Implements ssl-fetch code.

Migrate to using ssl-fetch (urllib3 based) for downloading files.

---
 layman/overlays/tar.py |  30 ++
 layman/remotedb.py | 108 +++--
 2 files changed, 37 insertions(+), 101 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 9cb65a2..94fefb1 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -24,12 +24,16 @@ __version__ = $Id: tar.py 310 2007-04-09 16:30:40Z wrobel 
$
 #
 
#---
 
-import os, os.path, sys, urllib2, shutil, tempfile
+import os, os.path, sys, shutil
+
 import xml.etree.ElementTree as ET # Python 2.5
 
 from   layman.utils import path
-#from   layman.debug import OUT
 from   layman.overlays.source   import OverlaySource, require_supported
+from   layman.version   import VERSION
+from   sslfetch.connections import Connector
+
+USERAGENT = Layman + VERSION
 
 
#===
 #
@@ -78,6 +82,15 @@ 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)
 
@@ -109,11 +122,14 @@ class TarOverlay(OverlaySource):
 ext = candidate_ext
 break
 
-try:
-tar = urllib2.urlopen(tar_url).read()
-except Exception as error:
-raise Exception('Failed to fetch the tar package from: '
-+ self.src + '\nError was:' + str(error))
+fetcher = Connector(self.output, self.proxies, USERAGENT)
+
+# Maps output functions for compatibility with ssl-fetch
+# output calls.
+self.output.write = self.output.info
+self.output.print_err = self.output.error
+
+success, tar, timestamp = fetcher.fetch_content(tar_url)
 
 pkg = path([base, self.parent.name + ext])
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index b010e51..24ee8b8 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -17,6 +17,7 @@
 '''Handles different storage files.'''
 
 from __future__ import with_statement
+from __future__ import unicode_literals
 
 __version__ = $Id: db.py 309 2007-04-09 16:23:38Z wrobel $
 
@@ -30,28 +31,6 @@ import os, os.path
 import sys
 import hashlib
 
-import requests
-from requests.exceptions import SSLError
-
-VERIFY_SSL = False
-# py3.2
-if sys.hexversion = 0x30200f0:
-VERIFY_SSL = True
-else:
-try: # import and enable SNI support for py2
-from requests.packages.urllib3.contrib import pyopenssl
-pyopenssl.inject_into_urllib3()
-VERIFY_SSL = True
-VERIFY_MSGS = [Successfully enabled ssl certificate verification.]
-except ImportError as e:
-VERIFY_MSGS = [
-Failed to import and inject pyopenssl/SNI support into urllib3,
-Disabling certificate verification,
-Error was: + e
-]
-VERIFY_SSL = False
-
-
 GPG_ENABLED = False
 try:
 from pygpg.config import GPGConfig
@@ -64,8 +43,10 @@ except ImportError:
 from   layman.utils import encoder
 from   layman.dbbaseimport DbBase
 from   layman.version   import VERSION
-from layman.compatibility   import fileopen
+from   layman.compatibility import fileopen
+from   sslfetch.connections import Connector  
 
+USERAGENT = Layman- + VERSION
 
 class RemoteDB(DbBase):
 '''Handles fetching the remote overlay list.'''
@@ -88,10 +69,6 @@ class RemoteDB(DbBase):
 self.urls  = [i.strip()
 for i in config['overlays'].split('\n') if len(i)]
 
-if VERIFY_MSGS:
-for msg in VERIFY_MSGS:
-self.output.debug(msg, 2)
-
 if GPG_ENABLED:
 self.get_gpg_urls()
 else:
@@ -113,7 +90,6 @@ class RemoteDB(DbBase):
 
 self.output.debug('RemoteDB.__init__(), paths to load = %s' 
%str(paths),
 2)
-
 if config['nocheck']:
 ignore = 2
 else:
@@ -171,6 +147,12 @@ class RemoteDB(DbBase):
 succeeded = True
 url_lists = [self.urls, self.detached_urls, self.signed_urls]
 need_gpg 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: 16687673a416f392347d1665dad61b0dd8c5aab3
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 00:35:07 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 23:44:30 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=16687673

Alters Exception, error to Exception as error

This changes the all instances of the phrase Exception, error to
Exception as error to allow py2/py3 compatibility.

---
 layman/api.py  | 16 
 layman/cli.py  |  2 +-
 layman/dbbase.py   |  4 ++--
 layman/makeconf.py |  4 ++--
 layman/overlays/overlay.py |  2 +-
 layman/overlays/source.py  |  2 +-
 layman/overlays/tar.py | 10 +-
 layman/remotedb.py | 10 +-
 layman/updater.py  |  2 +-
 layman/utils.py|  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 11534fd..475691b 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -113,7 +113,7 @@ class LaymanAPI(object):
 try:
 self._get_installed_db().delete(
 self._get_installed_db().select(ovl))
-except Exception, e:
+except Exception as e:
 self._error(
 Exception caught disabling repository '+ovl+
 ':\n+str(e))
@@ -147,7 +147,7 @@ class LaymanAPI(object):
 try:
 success = self._get_installed_db().add(
 self._get_remote_db().select(ovl))
-except Exception, e:
+except Exception as e:
 self._error(Exception caught enabling repository '+ovl+
 ' : +str(e))
 results.append(success)
@@ -201,7 +201,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:
@@ -255,7 +255,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)
@@ -311,7 +311,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, error:
+except UnknownOverlayException as error:
 #self.output.debug(API.sync(); UnknownOverlayException 
selecting %s %ovl, 5)
 #self._error(str(error))
 fatals.append((ovl,
@@ -364,7 +364,7 @@ class LaymanAPI(object):
 self.output.debug(API.sync(); starting db.sync(ovl), 5)
 db.sync(ovl)
 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)))
@@ -457,7 +457,7 @@ class LaymanAPI(object):
 self.output.debug(
 'LaymanAPI.fetch_remote_list(); cache updated = %s'
 % str(dbreload),8)
-except Exception, error:
+except Exception as error:
 self.output.error('Failed to fetch overlay list!\n Original Error 
was: '
 + str(error))
 return False
@@ -585,7 +585,7 @@ class LaymanAPI(object):
 elif self.config['news_reporter'] == 'pkgcore':
 # pkgcore is not yet capable
 return
-except Exception, err:
+except Exception as err:
 msg = update_news() failed running %s news reporter function\n +\
   Error was; %s
 self._error(msg % (self.config['news_reporter'], err))

diff --git a/layman/cli.py b/layman/cli.py
index a5d2799..258e3b9 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -173,7 +173,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))
 

diff --git a/layman/dbbase.py b/layman/dbbase.py
index e5c0fd9..8d57a9f 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -124,7 +124,7 @@ class 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-05-14 Thread Devan Franchini
commit: 1b84dd4870f4db0c836006b891f4bb0c3170777c
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 01:13:31 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 23:45:56 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=1b84dd48

overlays/tar.py: Changes permissions integer to octal

---
 layman/overlays/tar.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index e57096d..9cb65a2 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -169,7 +169,7 @@ class TarOverlay(OverlaySource):
 raise Exception('Failed to rename tar subdirectory ' +
 source + ' to ' + final_path +
 '\nError was:' + str(error))
-os.chmod(final_path, 0755)
+os.chmod(final_path, 0o755)
 else:
 raise Exception('Given subpath ' + source + ' does not exist 
'
 ' in the tar package!')



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: c5e2e8c437b0bb06b74cf8a0881508f4e47bf321
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 03:56:31 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 23:46:30 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c5e2e8c4

Adds unicode string compatibility support

Ensures that the necessary strings that need to be unicode, stay
unicode in both py2 and py3 when running layman.

---
 layman/api.py  | 20 ---
 layman/db.py   | 10 
 layman/dbbase.py   |  8 +++---
 layman/makeconf.py | 22 
 layman/overlays/overlay.py | 62 --
 layman/remotedb.py |  2 +-
 layman/utils.py|  4 ++-
 7 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 475691b..cbf3f76 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -13,6 +13,8 @@
 #  Brian Dolbec dol-...@sourceforge.net
 #
 
+from __future__ import print_function
+
 import os
 
 from layman.config import BareConfig
@@ -428,21 +430,21 @@ class LaymanAPI(object):
  b.close()
 
  api.get_available()
-[u'wrobel', u'wrobel-stable']
- all = api.get_all_info(u'wrobel')
+['wrobel', 'wrobel-stable']
+ all = api.get_all_info('wrobel')
  info = all['wrobel']
  info['status']
-u'official'
+'official'
  info['description']
-u'Test'
+'Test'
  info['sources']
-[(u'https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
+[('https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
 
-#{u'wrobel': {'status': u'official',
-#'owner_name': None, 'description': u'Test',
+#{'wrobel': {'status': 'official',
+#'owner_name': None, 'description': 'Test',
 #'src_uris': generator object source_uris at 0x167c3c0,
-#'owner_email': u'nob...@gentoo.org',
-#'quality': u'experimental', 'name': u'wrobel', 'supported': True,
+#'owner_email': 'nob...@gentoo.org',
+#'quality': 'experimental', 'name': 'wrobel', 'supported': True,
 #'src_types': generator object source_types at 0x167c370,
 #'official': True,
 #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}}

diff --git a/layman/db.py b/layman/db.py
index 6530147..ce03e13 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -111,11 +111,11 @@ class DB(DbBase):
 # * Running command /usr/bin/rsync -rlptDvz --progress --delete 
--delete-after --timeout=180 --exclude=distfiles/* --exclude=local/* 
--exclude=packages/* rsync://gunnarwrobel.de/wrobel-stable/* 
/tmp/file.../wrobel-stable...
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  m = MakeConf(config, b.overlays)
 #  [i.name for i in m.overlays] #doctest: +ELLIPSIS
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  os.unlink(write)
  os.unlink(write2)
@@ -195,16 +195,16 @@ class DB(DbBase):
 # * Running command /usr/bin/svn co 
https://overlays.gentoo.org/svn/dev/wrobel/; /tmp/file.../wrobel...
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel', u'wrobel-stable']
+# ['wrobel', 'wrobel-stable']
 
 #  b.delete(b.select('wrobel'))
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  m = MakeConf(config, b.overlays)
 #  [i.name for i in m.overlays] #doctest: +ELLIPSIS
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  os.unlink(write)
  os.unlink(write2)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 475ce44..8fa3ba8 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -149,10 +149,10 @@ class DbBase(object):
  config = {'output': output, 'svn_command': '/usr/bin/svn', 
'rsync_command':'/usr/bin/rsync'}
  a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', 
])
  a.overlays.keys()
-[u'wrobel', u'wrobel-stable']
+['wrobel', 'wrobel-stable']
 
  list(a.overlays['wrobel-stable'].source_uris())
-[u'rsync://gunnarwrobel.de/wrobel-stable']
+['rsync://gunnarwrobel.de/wrobel-stable']
 '''
 try:
 document = ET.fromstring(text)
@@ -214,7 +214,7 @@ class DbBase(object):
  b.write(write)
  c = DbBase({output: Message() }, [write,])
  c.overlays.keys()
-[u'wrobel-stable']
+['wrobel-stable']
 
  os.unlink(write)
  os.rmdir(tmpdir)
@@ -245,7 +245,7 @@ class DbBase(object):
  config = {'output': output, 'svn_command': '/usr/bin/svn', 
'rsync_command':'/usr/bin/rsync'}
  

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-14 Thread Devan Franchini
commit: 846c2efd8958bc0b5ac26dc1bf597912c04fae87
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 23:07:30 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 23:49:28 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=846c2efd

remotedb.py, tar.py: Implements ssl-fetch code

Migrate to using ssl-fetch (urllib3 based) for downloading files.

---
 layman/overlays/tar.py |  30 ++
 layman/remotedb.py | 108 +++--
 2 files changed, 37 insertions(+), 101 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 9cb65a2..94fefb1 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -24,12 +24,16 @@ __version__ = $Id: tar.py 310 2007-04-09 16:30:40Z wrobel 
$
 #
 
#---
 
-import os, os.path, sys, urllib2, shutil, tempfile
+import os, os.path, sys, shutil
+
 import xml.etree.ElementTree as ET # Python 2.5
 
 from   layman.utils import path
-#from   layman.debug import OUT
 from   layman.overlays.source   import OverlaySource, require_supported
+from   layman.version   import VERSION
+from   sslfetch.connections import Connector
+
+USERAGENT = Layman + VERSION
 
 
#===
 #
@@ -78,6 +82,15 @@ 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)
 
@@ -109,11 +122,14 @@ class TarOverlay(OverlaySource):
 ext = candidate_ext
 break
 
-try:
-tar = urllib2.urlopen(tar_url).read()
-except Exception as error:
-raise Exception('Failed to fetch the tar package from: '
-+ self.src + '\nError was:' + str(error))
+fetcher = Connector(self.output, self.proxies, USERAGENT)
+
+# Maps output functions for compatibility with ssl-fetch
+# output calls.
+self.output.write = self.output.info
+self.output.print_err = self.output.error
+
+success, tar, timestamp = fetcher.fetch_content(tar_url)
 
 pkg = path([base, self.parent.name + ext])
 

diff --git a/layman/remotedb.py b/layman/remotedb.py
index b010e51..24ee8b8 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -17,6 +17,7 @@
 '''Handles different storage files.'''
 
 from __future__ import with_statement
+from __future__ import unicode_literals
 
 __version__ = $Id: db.py 309 2007-04-09 16:23:38Z wrobel $
 
@@ -30,28 +31,6 @@ import os, os.path
 import sys
 import hashlib
 
-import requests
-from requests.exceptions import SSLError
-
-VERIFY_SSL = False
-# py3.2
-if sys.hexversion = 0x30200f0:
-VERIFY_SSL = True
-else:
-try: # import and enable SNI support for py2
-from requests.packages.urllib3.contrib import pyopenssl
-pyopenssl.inject_into_urllib3()
-VERIFY_SSL = True
-VERIFY_MSGS = [Successfully enabled ssl certificate verification.]
-except ImportError as e:
-VERIFY_MSGS = [
-Failed to import and inject pyopenssl/SNI support into urllib3,
-Disabling certificate verification,
-Error was: + e
-]
-VERIFY_SSL = False
-
-
 GPG_ENABLED = False
 try:
 from pygpg.config import GPGConfig
@@ -64,8 +43,10 @@ except ImportError:
 from   layman.utils import encoder
 from   layman.dbbaseimport DbBase
 from   layman.version   import VERSION
-from layman.compatibility   import fileopen
+from   layman.compatibility import fileopen
+from   sslfetch.connections import Connector  
 
+USERAGENT = Layman- + VERSION
 
 class RemoteDB(DbBase):
 '''Handles fetching the remote overlay list.'''
@@ -88,10 +69,6 @@ class RemoteDB(DbBase):
 self.urls  = [i.strip()
 for i in config['overlays'].split('\n') if len(i)]
 
-if VERIFY_MSGS:
-for msg in VERIFY_MSGS:
-self.output.debug(msg, 2)
-
 if GPG_ENABLED:
 self.get_gpg_urls()
 else:
@@ -113,7 +90,6 @@ class RemoteDB(DbBase):
 
 self.output.debug('RemoteDB.__init__(), paths to load = %s' 
%str(paths),
 2)
-
 if config['nocheck']:
 ignore = 2
 else:
@@ -171,6 +147,12 @@ class RemoteDB(DbBase):
 succeeded = True
 url_lists = [self.urls, self.detached_urls, self.signed_urls]
 need_gpg 

[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-05-13 Thread Devan Franchini
commit: 08762b404c86856d4794def0e3b4a1d68a1c424d
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 00:41:21 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 00:41:21 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=08762b40

Changes Exception, error to Exception as error, part 2.

These compatibility changes were overlooked in the overlay/
directory and are applied in this commit.

---
 layman/overlays/overlay.py |  2 +-
 layman/overlays/source.py  |  2 +-
 layman/overlays/tar.py | 10 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 65c148b..0c2d042 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -414,7 +414,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/source.py b/layman/overlays/source.py
index 2b79f2c..69c59bb 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, err:
+except Exception as err:
 self.output.error(
 'Unknown exception running command: %s' % command_repr)
 self.output.error('Original error was: %s' % str(err))

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index c6f2443..e57096d 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, error:
+except Exception as 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+b')
 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))
 
@@ -140,7 +140,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))
 
@@ -149,7 +149,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
 
@@ -165,7 +165,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))



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/

2014-05-13 Thread Devan Franchini
commit: 0018a1dfc141166842f6859eff88ff30f9c41981
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 01:13:31 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 01:13:31 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0018a1df

overlays/tar.py: Changes permissions integer to octal.

---
 layman/overlays/tar.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index e57096d..9cb65a2 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -169,7 +169,7 @@ class TarOverlay(OverlaySource):
 raise Exception('Failed to rename tar subdirectory ' +
 source + ' to ' + final_path +
 '\nError was:' + str(error))
-os.chmod(final_path, 0755)
+os.chmod(final_path, 0o755)
 else:
 raise Exception('Given subpath ' + source + ' does not exist 
'
 ' in the tar package!')



[gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/

2014-05-13 Thread Devan Franchini
commit: 3796605e387a22caf80af7c81b5bc74152744fa4
Author: Devan Franchini twitch153 AT gentoo DOT org
AuthorDate: Wed May 14 03:56:31 2014 +
Commit: Devan Franchini twitch153 AT gentoo DOT org
CommitDate: Wed May 14 03:56:31 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=3796605e

Adds unicode string compatibility support.

This commit allows string compatibility between py2 and py3 as well as
ensuring that the necessary strings that need to be unicode, stay
unicode in both py2 and py3 when running layman.

---
 layman/api.py  | 20 ---
 layman/db.py   | 10 
 layman/dbbase.py   |  8 +++---
 layman/makeconf.py | 22 
 layman/overlays/overlay.py | 62 --
 layman/remotedb.py |  2 +-
 layman/utils.py|  4 ++-
 7 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 475691b..cbf3f76 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -13,6 +13,8 @@
 #  Brian Dolbec dol-...@sourceforge.net
 #
 
+from __future__ import print_function
+
 import os
 
 from layman.config import BareConfig
@@ -428,21 +430,21 @@ class LaymanAPI(object):
  b.close()
 
  api.get_available()
-[u'wrobel', u'wrobel-stable']
- all = api.get_all_info(u'wrobel')
+['wrobel', 'wrobel-stable']
+ all = api.get_all_info('wrobel')
  info = all['wrobel']
  info['status']
-u'official'
+'official'
  info['description']
-u'Test'
+'Test'
  info['sources']
-[(u'https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
+[('https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
 
-#{u'wrobel': {'status': u'official',
-#'owner_name': None, 'description': u'Test',
+#{'wrobel': {'status': 'official',
+#'owner_name': None, 'description': 'Test',
 #'src_uris': generator object source_uris at 0x167c3c0,
-#'owner_email': u'nob...@gentoo.org',
-#'quality': u'experimental', 'name': u'wrobel', 'supported': True,
+#'owner_email': 'nob...@gentoo.org',
+#'quality': 'experimental', 'name': 'wrobel', 'supported': True,
 #'src_types': generator object source_types at 0x167c370,
 #'official': True,
 #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}}

diff --git a/layman/db.py b/layman/db.py
index 6530147..ce03e13 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -111,11 +111,11 @@ class DB(DbBase):
 # * Running command /usr/bin/rsync -rlptDvz --progress --delete 
--delete-after --timeout=180 --exclude=distfiles/* --exclude=local/* 
--exclude=packages/* rsync://gunnarwrobel.de/wrobel-stable/* 
/tmp/file.../wrobel-stable...
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  m = MakeConf(config, b.overlays)
 #  [i.name for i in m.overlays] #doctest: +ELLIPSIS
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  os.unlink(write)
  os.unlink(write2)
@@ -195,16 +195,16 @@ class DB(DbBase):
 # * Running command /usr/bin/svn co 
https://overlays.gentoo.org/svn/dev/wrobel/; /tmp/file.../wrobel...
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel', u'wrobel-stable']
+# ['wrobel', 'wrobel-stable']
 
 #  b.delete(b.select('wrobel'))
 #  c = DbBase([write, ], dict())
 #  c.overlays.keys()
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  m = MakeConf(config, b.overlays)
 #  [i.name for i in m.overlays] #doctest: +ELLIPSIS
-# [u'wrobel-stable']
+# ['wrobel-stable']
 
 #  os.unlink(write)
  os.unlink(write2)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 475ce44..8fa3ba8 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -149,10 +149,10 @@ class DbBase(object):
  config = {'output': output, 'svn_command': '/usr/bin/svn', 
'rsync_command':'/usr/bin/rsync'}
  a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', 
])
  a.overlays.keys()
-[u'wrobel', u'wrobel-stable']
+['wrobel', 'wrobel-stable']
 
  list(a.overlays['wrobel-stable'].source_uris())
-[u'rsync://gunnarwrobel.de/wrobel-stable']
+['rsync://gunnarwrobel.de/wrobel-stable']
 '''
 try:
 document = ET.fromstring(text)
@@ -214,7 +214,7 @@ class DbBase(object):
  b.write(write)
  c = DbBase({output: Message() }, [write,])
  c.overlays.keys()
-[u'wrobel-stable']
+['wrobel-stable']
 
  os.unlink(write)
  os.rmdir(tmpdir)
@@ -245,7 +245,7 @@ class DbBase(object):
  config = {'output':