[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/, 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/, 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/, 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/, 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/, 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/, 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/, 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/, 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/, 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/, 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/, 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':