* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/sync/
@ 2014-06-27 4:07 Devan Franchini
0 siblings, 0 replies; 5+ messages in thread
From: Devan Franchini @ 2014-06-27 4:07 UTC (permalink / raw
To: gentoo-commits
commit: bc820e2c9e37ea3e6f15575dc41ce29870511cf5
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 03:07:26 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=bc820e2c
sync/__init__.py: Adds description for "new" action
---
layman/sync/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/layman/sync/__init__.py b/layman/sync/__init__.py
index 303f996..2282f51 100644
--- a/layman/sync/__init__.py
+++ b/layman/sync/__init__.py
@@ -18,7 +18,7 @@ options = {'1': 'Layman', '2': 'PyLayman'}
config_class = DEFAULT_CLASS
try:
test_param = os.environ["TESTIT"]
- if test_param in options:
+ if str(test_param) in options:
config_class = options[test_param]
except KeyError:
pass
@@ -35,7 +35,7 @@ module_spec = {
'functions': ['sync', 'new', 'exists'],
'func_desc': {
'sync': 'Performs a layman sync of the specified overlay',
- 'new': 'Currently does nothing',
+ 'new': 'Performs a layman add of the specified overlay',
'exists': 'Returns a boolean of whether the specified dir ' +
'exists and is a valid repository',
},
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/sync/
@ 2014-06-27 4:07 Devan Franchini
0 siblings, 0 replies; 5+ messages in thread
From: Devan Franchini @ 2014-06-27 4:07 UTC (permalink / raw
To: gentoo-commits
commit: fba46d15a846255fcbb675013e7695210fcbce20
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 03:28:43 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fba46d15
layman.py: Adds api variant of new() function
Also cleans up output messages as well as some variable
interpolation.
---
layman/sync/layman.py | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/layman/sync/layman.py b/layman/sync/layman.py
index 426c145..a480e22 100644
--- a/layman/sync/layman.py
+++ b/layman/sync/layman.py
@@ -41,7 +41,7 @@ class Layman(SyncBase):
args.append('-q')
def new(self, **kwargs):
- '''Do the initial download and install of the repository'''
+ '''Use layman to install the repository'''
if kwargs:
self._kwargs(kwargs)
emerge_config = self.options.get('emerge_config', None)
@@ -62,7 +62,7 @@ class Layman(SyncBase):
({'command': command}),
**portage._native_kwargs(self.spawn_kwargs))
if exitcode != os.EX_OK:
- msg = "!!! layman sync error in %(repo)s" % ({'repo': self.repo.name})
+ msg = "!!! layman add error in %(repo)s" % ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
return (exitcode, False)
@@ -77,7 +77,7 @@ class Layman(SyncBase):
emerge_config = self.options.get('emerge_config', None)
portdb = self.options.get('portdb', None)
args = []
- msg = '>>> Starting layman sync for %s...' % self.repo.name
+ msg = '>>> Starting layman sync for %(repo)s...' % ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + '\n')
@@ -86,15 +86,16 @@ class Layman(SyncBase):
args.append('-s')
args.append(self.repo.name)
- exitcode = portage.process.spawn_bash("%s" % \
- (' '.join(args)),
+ command = ' '.join(args)
+ exitcode = portage.process.spawn_bash("%(command)s" % \
+ ({'command': command}),
**portage._native_kwargs(self.spawn_kwargs))
if exitcode != os.EX_OK:
- msg = "!!! layman sync error in %s" % self.repo.name
+ msg = "!!! layman sync error in %(repo)s" % ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
return (exitcode, False)
- msg = ">>> layman sync succeeded: %s" % self.repo.name
+ msg = ">>> layman sync succeeded: %(repo)s" % ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n")
@@ -141,8 +142,24 @@ class PyLayman(SyncBase):
def new(self, **kwargs):
'''Do the initial download and install of the repository'''
- pass
+ layman_inst = self._get_layman_api()
+
+ emerge_config = self.options.get('emerge_config', None)
+ portdb = self.options.get('portdb', None)
+ msg = '>>> Starting to add new layman overlay %(repo)s' % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + '\n')
+
+ exitcode = layman_inst.add_repos(self.repo.name)
+ if exitcode != os.EX_OK:
+ msg = "!!! layman add error in %(repo)s" % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+ return (exitcode, False)
+ msg = ">>> Addition of layman repo succeeded: %(repo)s" % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + '\n')
def _sync(self):
''' Update existing repository'''
@@ -160,8 +177,8 @@ class PyLayman(SyncBase):
msg = "!!! layman sync error in %(repo)s" % ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
- return(exitcode, False)
- msg = ">>> layman sync succeeded: %s" % self.repo.name
+ return (exitcode, False)
+ msg = ">>> layman sync succeeded: %(repo)s" % ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n")
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/sync/
@ 2014-06-27 4:07 Devan Franchini
0 siblings, 0 replies; 5+ messages in thread
From: Devan Franchini @ 2014-06-27 4:07 UTC (permalink / raw
To: gentoo-commits
commit: 3443dc9032f5ae4aeeeca78e358cef948f90d71a
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 03:19:28 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=3443dc90
layman.py: Adds fully functional api sync
---
layman/sync/layman.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/layman/sync/layman.py b/layman/sync/layman.py
index dac9569..426c145 100644
--- a/layman/sync/layman.py
+++ b/layman/sync/layman.py
@@ -147,3 +147,22 @@ class PyLayman(SyncBase):
def _sync(self):
''' Update existing repository'''
layman_inst = self._get_layman_api()
+
+ emerge_config = self.options.get('emerge_config', None)
+ portdb = self.options.get('portdb', None)
+
+ msg = '>>> Starting layman sync for %(repo)s...' % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + '\n')
+
+ exitcode = layman_inst.sync(self.repo.name)
+ if exitcode != os.EX_OK:
+ msg = "!!! layman sync error in %(repo)s" % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+ return(exitcode, False)
+ msg = ">>> layman sync succeeded: %s" % self.repo.name
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n")
+
+ return(exitcode, True)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/sync/
@ 2014-06-27 4:07 Devan Franchini
0 siblings, 0 replies; 5+ messages in thread
From: Devan Franchini @ 2014-06-27 4:07 UTC (permalink / raw
To: gentoo-commits
commit: f6ed5510885847653473190d59d32e8159a3f1c2
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 01:21:57 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f6ed5510
Adds initial files for layman sync plugin
---
layman/sync/__init__.py | 45 +++++++++++++++++++
layman/sync/layman.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 161 insertions(+)
diff --git a/layman/sync/__init__.py b/layman/sync/__init__.py
new file mode 100644
index 0000000..303f996
--- /dev/null
+++ b/layman/sync/__init__.py
@@ -0,0 +1,45 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+'''Layman plug-in module for portage.
+Performs layman sync actions for layman overlays.
+'''
+
+import os
+
+from portage.sync.config_checks import CheckSyncConfig
+
+
+DEFAULT_CLASS = 'Layman'
+AVAILABLE_CLASSES = [ 'Layman', 'PyLayman']
+options = {'1': 'Layman', '2': 'PyLayman'}
+
+
+config_class = DEFAULT_CLASS
+try:
+ test_param = os.environ["TESTIT"]
+ if test_param in options:
+ config_class = options[test_param]
+except KeyError:
+ pass
+
+
+module_spec = {
+ 'name': 'layman',
+ 'description': __doc__,
+ 'provides':{
+ 'layman-module': {
+ 'name': 'layman',
+ 'class': config_class,
+ 'description': __doc__,
+ 'functions': ['sync', 'new', 'exists'],
+ 'func_desc': {
+ 'sync': 'Performs a layman sync of the specified overlay',
+ 'new': 'Currently does nothing',
+ 'exists': 'Returns a boolean of whether the specified dir ' +
+ 'exists and is a valid repository',
+ },
+ 'validate_config': CheckSyncConfig,
+ },
+ }
+}
diff --git a/layman/sync/layman.py b/layman/sync/layman.py
new file mode 100644
index 0000000..7adf8c6
--- /dev/null
+++ b/layman/sync/layman.py
@@ -0,0 +1,116 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+'''Layman module for portage'''
+
+import logging
+
+from layman.api import LaymanAPI
+from layman.config import BareConfig, OptionConfig
+from layman.output import Message
+
+import portage
+from portage import os
+from portage.util import writemsg_level
+from portage.output import create_color_func
+good = create_color_func("GOOD")
+bad = create_color_func("BAD")
+warn = create_color_func("WARN")
+from portage.sync.syncbase import SyncBase
+
+import sys
+
+class Layman(SyncBase):
+ '''Layman sync class'''
+
+ short_desc = "Perform sync operations on webrsync based repositories"
+
+ @staticmethod
+ def name():
+ return "Layman"
+
+
+ def __init__(self):
+ SyncBase.__init__(self, 'layman', 'app-portage/layman')
+
+
+ def new(self, **kwargs):
+ '''Do the initial download and install of the repository'''
+ pass
+
+
+ def _sync(self):
+ ''' Update existing repository'''
+ emerge_config = self.options.get('emerge_config', None)
+ portdb = self.options.get('portdb', None)
+ args = []
+ msg = '>>> Starting layman sync for %s...' % self.repo.location
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + '\n')
+ args.append('layman -n')
+
+ if self.settings:
+ if self.settings.get('NOCOLOR'):
+ args.append('-N')
+ if self.settings.get('PORTAGE_QUIET'):
+ args.append('-q')
+
+ args.append('-s')
+ args.append(self.repo.name)
+ exitcode = portage.process.spawn_bash("%s" % \
+ (' '.join(args)),
+ **portage._native_kwargs(self.spawn_kwargs))
+ if exitcode != os.EX_OK:
+ msg = "!!! layman sync error in %s" % self.repo.name
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+ return (exitcode, False)
+ msg = ">>> layman sync succeeded: %s" % self.repo.name
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n")
+
+ return (exitcode, True)
+
+
+class PyLayman(SyncBase):
+ '''Layman sync class'''
+
+ short_desc = "Perform sync operations on webrsync based repositories"
+
+ @staticmethod
+ def name():
+ return "Layman"
+
+ def __init__(self):
+
+ SyncBase.__init__(self, '', 'app-portage/layman')
+
+ config = BareConfig()
+ self.message = Message(out=sys.stdout, err=sys.stderr)
+
+ options = {
+ 'config': config.get_option('config'),
+ 'quiet': portage.settings.get('PORTAGE_QUIET'),
+ 'quietness': config.get_option('quietness'),
+ 'output': self.message,
+ 'nocolor': portage.settings.get('NOCOLOR'),
+ 'root': portage.settings.get('EROOT'),
+ 'verbose': portage.settings.get('PORTAGE_VERBOSE'),
+ 'width': portage.settings.get('COLUMNWIDTH'),
+
+ }
+
+ self.config = OptionConfig(options=options)
+
+ LaymanAPI.__init__(self, self.config,
+ report_errors=True,
+ output=self.config['output']
+ )
+
+ def new(self, **kwargs):
+ '''Do the initial download and install of the repository'''
+ pass
+
+
+ def _sync(self):
+ ''' Update existing repository'''
+ pass
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/sync/
@ 2014-06-27 4:07 Devan Franchini
0 siblings, 0 replies; 5+ messages in thread
From: Devan Franchini @ 2014-06-27 4:07 UTC (permalink / raw
To: gentoo-commits
commit: 87eefca1205a1952abedba2ab8c8b0cbe7b35842
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 03:08:29 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=87eefca1
layman.py: Moves API initialization to separate function
Also adds new() function for subprocess variant of layman plugin
module.
---
layman/sync/layman.py | 77 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 55 insertions(+), 22 deletions(-)
diff --git a/layman/sync/layman.py b/layman/sync/layman.py
index 7adf8c6..dac9569 100644
--- a/layman/sync/layman.py
+++ b/layman/sync/layman.py
@@ -33,29 +33,59 @@ class Layman(SyncBase):
SyncBase.__init__(self, 'layman', 'app-portage/layman')
+ def _get_optargs(self, args):
+ if self.settings:
+ if self.settings.get('NOCOLOR'):
+ args.append('-N')
+ if self.settings.get('PORTAGE_QUIET'):
+ args.append('-q')
+
def new(self, **kwargs):
'''Do the initial download and install of the repository'''
- pass
+ if kwargs:
+ self._kwargs(kwargs)
+ emerge_config = self.options.get('emerge_config', None)
+ portdb = self.options.get('portdb', None)
+ args = []
+ msg = '>>> Starting to add new layman overlay %(repo)s' % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + '\n')
+ args.append('layman -n')
+ self._get_optargs(args)
+ args.append('-a')
+ args.append(self.repo.name)
+
+ command = ' '.join(args)
+
+ exitcode = portage.process.spawn_bash("%(command)s" % \
+ ({'command': command}),
+ **portage._native_kwargs(self.spawn_kwargs))
+ if exitcode != os.EX_OK:
+ msg = "!!! layman sync error in %(repo)s" % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+ return (exitcode, False)
+ msg = ">>> Addition of layman repo succeeded: %(repo)s" % ({'repo': self.repo.name})
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n")
+
+ return (exitcode, True)
def _sync(self):
''' Update existing repository'''
emerge_config = self.options.get('emerge_config', None)
portdb = self.options.get('portdb', None)
args = []
- msg = '>>> Starting layman sync for %s...' % self.repo.location
+ msg = '>>> Starting layman sync for %s...' % self.repo.name
self.logger(self.xterm_titles, msg)
writemsg_level(msg + '\n')
- args.append('layman -n')
-
- if self.settings:
- if self.settings.get('NOCOLOR'):
- args.append('-N')
- if self.settings.get('PORTAGE_QUIET'):
- args.append('-q')
+ args.append('layman -n')
+ self._get_optargs(args)
args.append('-s')
args.append(self.repo.name)
+
exitcode = portage.process.spawn_bash("%s" % \
(' '.join(args)),
**portage._native_kwargs(self.spawn_kwargs))
@@ -81,30 +111,33 @@ class PyLayman(SyncBase):
return "Layman"
def __init__(self):
+ SyncBase.__init__(self, 'layman', 'app-portage/layman')
- SyncBase.__init__(self, '', 'app-portage/layman')
+
+ def _get_layman_api(self):
config = BareConfig()
self.message = Message(out=sys.stdout, err=sys.stderr)
-
+
options = {
'config': config.get_option('config'),
- 'quiet': portage.settings.get('PORTAGE_QUIET'),
+ 'quiet': self.settings.get('PORTAGE_QUIET'),
'quietness': config.get_option('quietness'),
'output': self.message,
- 'nocolor': portage.settings.get('NOCOLOR'),
- 'root': portage.settings.get('EROOT'),
- 'verbose': portage.settings.get('PORTAGE_VERBOSE'),
- 'width': portage.settings.get('COLUMNWIDTH'),
+ 'nocolor': self.settings.get('NOCOLOR'),
+ 'root': self.settings.get('EROOT'),
+ 'verbose': self.settings.get('PORTAGE_VERBOSE'),
+ 'width': self.settings.get('COLUMNWIDTH'),
}
self.config = OptionConfig(options=options)
-
- LaymanAPI.__init__(self, self.config,
- report_errors=True,
- output=self.config['output']
- )
+
+ layman_api = LaymanAPI(self.config,
+ report_errors=True,
+ output=self.config['output']
+ )
+ return layman_api
def new(self, **kwargs):
'''Do the initial download and install of the repository'''
@@ -113,4 +146,4 @@ class PyLayman(SyncBase):
def _sync(self):
''' Update existing repository'''
- pass
+ layman_inst = self._get_layman_api()
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-27 4:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-27 4:07 [gentoo-commits] proj/layman:gsoc2014 commit in: layman/sync/ Devan Franchini
-- strict thread matches above, loose matches on Subject: below --
2014-06-27 4:07 Devan Franchini
2014-06-27 4:07 Devan Franchini
2014-06-27 4:07 Devan Franchini
2014-06-27 4:07 Devan Franchini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox