public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-09-23  1:13 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-09-23  1:13 UTC (permalink / raw
  To: gentoo-commits

commit:     5d9af29bb87182d5e0ca30b87e33396bb9d00138
Author:     Devan Franchini <twitch153 <AT> hotmail <DOT> com>
AuthorDate: Mon Sep 23 01:08:18 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 01:08:18 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=5d9af29b

WebappConfig/content.py: Adds use of create_md5() function.

This update adds the use of compat.py into content.py and makes use of
the create_md5() function.

---
 WebappConfig/content.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/WebappConfig/content.py b/WebappConfig/content.py
index 966a9cd..7eff223 100644
--- a/WebappConfig/content.py
+++ b/WebappConfig/content.py
@@ -26,7 +26,7 @@ import hashlib, re, os, os.path
 
 from WebappConfig.debug       import OUT
 from WebappConfig.permissions import PermissionMap
-
+from WebappConfig.compat      import create_md5
 # ========================================================================
 # Content handler
 # ------------------------------------------------------------------------
@@ -531,7 +531,7 @@ class Contents:
 
     def file_md5(self, filename):
         ''' Return the md5 hash for the file content.'''
-        return str(hashlib.md5(open(filename).read()).hexdigest())
+	create_md5(filename)
 
     def file_time(self, filename):
         ''' Return the last modification time.'''


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     f1a1642864ac0ec8576b908cf36aa3a44b995051
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 02:10:54 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=f1a16428

{config, db}.py: Adds proper support for list-installs command

The webapp-config man page says that the --list-installs flag
can be the package name, and/or version, or "*". So changes
needed to be made to allow for this functionality.

 WebappConfig/config.py | 43 +++++++++++++++++++++++++++----------------
 WebappConfig/db.py     |  2 +-
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index c87b93b..2c14baa 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -579,7 +579,7 @@ class Config:
 
         info_opts.add_argument('-li',
                                '--list-installs',
-                               nargs = 2,
+                               nargs = '*',
                                help = 'List all current virtual installs for <a'
                                'pplication>. Use * for the package name and/or '
                                'version number to list more than one package / '
@@ -972,32 +972,43 @@ class Config:
 
         OUT.debug('Checking command line arguments', 1)
 
-        if self.work in ['install', 'clean', 'query', 'show_postinst',
-                         'show_postupgrade', 'upgrade']:
+        if self.work in ['install', 'clean', 'query', 'list_installs',
+                         'show_postinst', 'show_postupgrade', 'upgrade']:
             # get cat / pn
             args = options[self.work]
+            m    = args[0].split('/')
+
+            if self.work == 'list_installs' and len(args) > 2:
+                msg = os.path.basename(sys.argv[0]) + ': error: argument -li/'\
+                      '--list-installs: expected up to 2 arguments'
 
-            m = args[0].split('/')
+                self.parser.print_usage()
+                print(msg)
+                sys.exit()
 
             if len(m) == 1:
-                self.config.set('USER', 'pn',  m[0])
+                if '*' not in m:
+                    self.config.set('USER', 'pn',  m[0])
             elif len(m) == 2:
                 self.config.set('USER', 'cat', m[0])
-                self.config.set('USER', 'pn',  m[1])
+                if '*' not in m:
+                    self.config.set('USER', 'pn',  m[1])
             else:
                 OUT.die('Invalid package name')
 
-            argsvr = args[1].split('.')
-            if len(argsvr) == 1:
-                OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+            if len(args) > 1:
+                argsvr = args[1].split('.')
+                if len(argsvr) == 1:
+                    OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+
+                pvr = ''
+                for i in range(0, len(argsvr)):
+                    if not i == len(argsvr) - 1:
+                        pvr += argsvr[i] + '.'
+                    else:
+                        pvr += argsvr[i]
+                self.config.set('USER', 'pvr', pvr)
 
-            pvr = ''
-            for i in range(0, len(argsvr)):
-                if not i == len(argsvr) - 1:
-                    pvr += argsvr[i] + '.'
-                else:
-                    pvr += argsvr[i]
-            self.config.set('USER', 'pvr', pvr)
 
     # --------------------------------------------------------------------
     # Helper functions

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 0fbd34a..06d9e04 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -403,7 +403,7 @@ class WebappDB(AppHierarchy):
                     OUT.info('  ' + i[3].strip(), 1)
                 else:
                     # This is a simplified form for the webapp.eclass
-                    print(i[3].strip())
+                    OUT.info(i[3].strip(), 1)
 
 # ========================================================================
 # Handler for /usr/share/webapps


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     eda081b7836aed44ec52f8033c84814e58fc069e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:51:31 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=eda081b7

config.py: Message clean ups

 WebappConfig/config.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 37c2982..8d6a0ae 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -1001,7 +1001,8 @@ class Config:
                 if len(args) > 1:
                     argsvr = args[1].split('.')
                     if len(argsvr) == 1:
-                        OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+                        OUT.die('Invalid package version: %(pvr)s'
+                                % {'pvr': args[1]})
 
                     pvr = ''
                     for i in range(0, len(argsvr)):
@@ -1384,17 +1385,15 @@ class Config:
             # upgrade
 
             # okay - what do we have?
-
-            OUT.info('Removing '
-                     + old['WEB_CATEGORY'] + '/'
-                     + old['WEB_PN'] + '-'
-                     + old['WEB_PVR'] + ' from '
-                     + self.installdir() + '\n'
-                     + '  Installed by '
-                     + old['WEB_INSTALLEDBY'] + ' on '
-                     + old['WEB_INSTALLEDDATE'] + '\n'
-                     +'  Config files owned by '
-                     + old['WEB_INSTALLEDFOR'], 1)
+            msg = 'Removing '
+            if old['WEB_CATEGORY']:
+                msg += old['WEB_CATEGORY'] + '/'
+            msg += old['WEB_PN'] + '-' + old['WEB_PVR'] + ' from '\
+                   + self.installdir() + '\n  Installed by '\
+                   + old['WEB_INSTALLEDBY'] + ' on ' + old['WEB_INSTALLEDDATE']\
+                   + '\n  Config files owned by ' + old['WEB_INSTALLEDFOR']
+
+            OUT.info(msg, 1)
 
             content = self.create_content(old['WEB_CATEGORY'], old['WEB_PN'], old['WEB_PVR'])
             content.read()


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     643dcb1df9f4392ed40a83b146858aa5d59f6193
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 00:38:26 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=643dcb1d

config.py: Removes unnecessary .keys() call for option_to_config dict

 WebappConfig/config.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 2c14baa..06dfc4c 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -904,15 +904,15 @@ class Config:
                             'verbose'      : 'g_verbose',
                             'bug_report'   : 'g_bugreport'}
 
-        for i in list(option_to_config.keys()):
-            if i in options and options[i]:
+        for key in option_to_config:
+            if key in options and options[key]:
                 # If it's a list, we're expecting only one value in the list.
-                if isinstance(options[i], list):
-                    self.config.set('USER', option_to_config[i],
-                                    str(options[i][0]))
+                if isinstance(options[key], list):
+                    self.config.set('USER', option_to_config[key],
+                                    str(options[key][0]))
                 else:
-                    self.config.set('USER', option_to_config[i],
-                                    str(options[i]))
+                    self.config.set('USER', option_to_config[key],
+                                    str(options[key]))
 
         # handle verbosity
         if ('pretend' in options


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     42c1aa3e416fda7f052c23195ad124ee7732dac4
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 03:19:16 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=42c1aa3e

config.py: Readds the "dir" key to the option_to_config term

 WebappConfig/config.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 8d6a0ae..ab19ee3 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -892,6 +892,7 @@ class Config:
 
         # Map command line options into the configuration
         option_to_config = {'host'         : 'vhost_hostname',
+                            'dir'          : 'g_installdir',
                             'server'       : 'vhost_server',
                             'secure'       : 'g_secure',
                             'user'         : 'vhost_config_uid',


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     5b02eb87259576506857f099706071b266d753fd
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:26:44 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=5b02eb87

config.py: Adds optionality to --dir flag

If the --dir flag is not specified with actions that require
the dir flag then webapp-config will default to the name of the
package as the installation directory.

 WebappConfig/config.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 06dfc4c..c9c0baf 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -429,8 +429,9 @@ class Config:
                                '--dir',
                                nargs = 1,
                                help = 'Install <application> into DIR under the'
-                               ' htdocs dir. The default is '
-                               + self.config.get('USER', 'g_installdir'))
+                               ' htdocs dir. Not specifying using this flag'
+                               ' will result in defaulting to the package '
+                               ' name.')
 
         inst_locs.add_argument('-h',
                                '--host',
@@ -891,7 +892,6 @@ class Config:
 
         # Map command line options into the configuration
         option_to_config = {'host'         : 'vhost_hostname',
-                            'dir'          : 'g_installdir',
                             'server'       : 'vhost_server',
                             'secure'       : 'g_secure',
                             'user'         : 'vhost_config_uid',
@@ -1009,6 +1009,15 @@ class Config:
                         pvr += argsvr[i]
                 self.config.set('USER', 'pvr', pvr)
 
+            if not options['dir'] and self.work != 'list_installs':
+                pn  = self.config.get('USER', 'pn')
+                msg = 'Install dir flag not supplied, defaulting to '\
+                      '"%(pn)s".' % {'pn': pn}
+
+                OUT.warn(msg)
+                self.config.set('USER', 'g_installdir', pn)
+                self.flag_dir = True
+
 
     # --------------------------------------------------------------------
     # Helper functions


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     2bb44c4c0ba8fffb1ff5b66ce121d32cda6bd2cc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 03:54:16 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=2bb44c4c

config.py: Suppresses warning message for lack of -d flag for --query

 WebappConfig/config.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index ab19ee3..cb9d552 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -1013,7 +1013,8 @@ class Config:
                             pvr += argsvr[i]
                     self.config.set('USER', 'pvr', pvr)
 
-                if not options['dir'] and self.work != 'list_installs':
+                if (not options['dir'] and
+                    self.work not in ('list_installs', 'query')):
                     pn  = self.config.get('USER', 'pn')
                     msg = 'Install dir flag not supplied, defaulting to '\
                           '"%(pn)s".' % {'pn': pn}


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     b4d7183d79204d998acd0c7442d17484435d0861
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:40:12 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=b4d7183d

config.py: Allows for -lui to not have any arguments passed

Other command line flags such as -I, -C, or -U will always expect
2 command line args. If they are not properly supplied then that
is handled by argparse. This commit allows for the -lui flag that
can have 0 up to 2 optional flags passed to have that 0 flags passed.

 WebappConfig/config.py | 84 ++++++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 41 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index c9c0baf..37c2982 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -976,47 +976,49 @@ class Config:
                          'show_postinst', 'show_postupgrade', 'upgrade']:
             # get cat / pn
             args = options[self.work]
-            m    = args[0].split('/')
-
-            if self.work == 'list_installs' and len(args) > 2:
-                msg = os.path.basename(sys.argv[0]) + ': error: argument -li/'\
-                      '--list-installs: expected up to 2 arguments'
-
-                self.parser.print_usage()
-                print(msg)
-                sys.exit()
-
-            if len(m) == 1:
-                if '*' not in m:
-                    self.config.set('USER', 'pn',  m[0])
-            elif len(m) == 2:
-                self.config.set('USER', 'cat', m[0])
-                if '*' not in m:
-                    self.config.set('USER', 'pn',  m[1])
-            else:
-                OUT.die('Invalid package name')
-
-            if len(args) > 1:
-                argsvr = args[1].split('.')
-                if len(argsvr) == 1:
-                    OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
-
-                pvr = ''
-                for i in range(0, len(argsvr)):
-                    if not i == len(argsvr) - 1:
-                        pvr += argsvr[i] + '.'
-                    else:
-                        pvr += argsvr[i]
-                self.config.set('USER', 'pvr', pvr)
-
-            if not options['dir'] and self.work != 'list_installs':
-                pn  = self.config.get('USER', 'pn')
-                msg = 'Install dir flag not supplied, defaulting to '\
-                      '"%(pn)s".' % {'pn': pn}
-
-                OUT.warn(msg)
-                self.config.set('USER', 'g_installdir', pn)
-                self.flag_dir = True
+
+            if len(args):
+                m    = args[0].split('/')
+
+                if self.work == 'list_installs' and len(args) > 2:
+                    msg = os.path.basename(sys.argv[0]) + ': error: argument '\
+                          '-li/--list-installs: expected up to 2 arguments'
+
+                    self.parser.print_usage()
+                    print(msg)
+                    sys.exit()
+
+                if len(m) == 1:
+                    if '*' not in m:
+                        self.config.set('USER', 'pn',  m[0])
+                elif len(m) == 2:
+                    self.config.set('USER', 'cat', m[0])
+                    if '*' not in m:
+                        self.config.set('USER', 'pn',  m[1])
+                else:
+                    OUT.die('Invalid package name')
+
+                if len(args) > 1:
+                    argsvr = args[1].split('.')
+                    if len(argsvr) == 1:
+                        OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+
+                    pvr = ''
+                    for i in range(0, len(argsvr)):
+                        if not i == len(argsvr) - 1:
+                            pvr += argsvr[i] + '.'
+                        else:
+                            pvr += argsvr[i]
+                    self.config.set('USER', 'pvr', pvr)
+
+                if not options['dir'] and self.work != 'list_installs':
+                    pn  = self.config.get('USER', 'pn')
+                    msg = 'Install dir flag not supplied, defaulting to '\
+                          '"%(pn)s".' % {'pn': pn}
+
+                    OUT.warn(msg)
+                    self.config.set('USER', 'g_installdir', pn)
+                    self.flag_dir = True
 
 
     # --------------------------------------------------------------------


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     d2331c1873d7beb5f72aad381d3ab4f5b65b0008
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 03:44:03 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=d2331c18

db.py: Reverts OUT.info() call to print() in listinstalls()

 WebappConfig/db.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 06d9e04..0fbd34a 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -403,7 +403,7 @@ class WebappDB(AppHierarchy):
                     OUT.info('  ' + i[3].strip(), 1)
                 else:
                     # This is a simplified form for the webapp.eclass
-                    OUT.info(i[3].strip(), 1)
+                    print(i[3].strip())
 
 # ========================================================================
 # Handler for /usr/share/webapps


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     07b997df2833c7fd038e029e97d44cacc55c2d0d
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 14 01:06:26 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=07b997df

config.py: Modifies import strategy for config parser

On systems which had dev-python/configparser installed (a package
to add support for the py3.x configparser class in py2.x)
webapp-config would make use of that class instead of py2.x's built
in ConfigParser class. This would lead to improper interpolation of
configuration variables that follow the syntax "${<var>}". This
dangerous behavior could (and has) lead to webapp-config installing
a webapp to the root filesystem of a host. This danger has been
avoided by modifying the import strategy for the config parser we're
using so that we force import the ConfigParser class if using py2.x.

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

 WebappConfig/config.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index cdae149..c87b93b 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -21,15 +21,12 @@
 
 import sys, os, os.path, re, socket, time
 
-try:
+if sys.hexversion >= 0x3000000:
     # Python 3
     import configparser
-    if sys.version_info >= (3, 2):
-        from configparser import ConfigParser as configparser_ConfigParser
-        from configparser import ExtendedInterpolation
-    else:
-        from configparser import SafeConfigParser as configparser_ConfigParser
-except ImportError:
+    from configparser import ConfigParser as configparser_ConfigParser
+    from configparser import ExtendedInterpolation
+else:
     # Python 2
     import ConfigParser as configparser
     from ConfigParser import SafeConfigParser as configparser_ConfigParser


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     c3bd6d243ead957e0b6bd2c7d5114392e75b3289
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 16 19:16:58 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:14 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=c3bd6d24

config.py: Improves package version checking

With the previous method of setting the package version you were
unable to pass the package version to webapp-config if it had more
than one decimal point (ex: 1.0.1 wouldn't work), this commit attempts
to fix that issue.

 WebappConfig/config.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 10a6f26..5eb4584 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -990,11 +990,18 @@ class Config:
             else:
                 OUT.die('Invalid package name')
 
-            try:
-                self.config.set('USER', 'pvr', str(float(args[1])))
-            except ValueError:
+            argsvr = args[1].split('.')
+            if len(argsvr) == 1:
                 OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
 
+            pvr = ''
+            for i in range(0, len(argsvr)):
+                if not i == len(argsvr) - 1:
+                    pvr += argsvr[i] + '.'
+                else:
+                    pvr += argsvr[i]
+            self.config.set('USER', 'pvr', pvr)
+
     # --------------------------------------------------------------------
     # Helper functions
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     2b7bd1bfbed79353cd139aeb016e022ac0cd937f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:30:40 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:14 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=2b7bd1bf

config.py: Modifies --list_unused_installed to nargs = "*"

In order to allow the nature of --list_unused_installed to remain true
to the nature of the command line arg, the nargs has been changed to
"*". This allows --list_unused_installed to be called with 0 or more
args via the argparse python class.

 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 99ccedd..10a6f26 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -598,7 +598,7 @@ class Config:
 
         info_opts.add_argument('-lui',
                                '--list-unused-installs',
-                               action='store_true',
+                               nargs = '*',
                                help = 'List all master images which currently a'
                                're not used. Optionally, provide a package and/'
                                'or version number as arguments to restrict the '


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     f07dcde9c03cb0b6a2ab4f0bbc723582c491f771
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:26:36 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:14 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=f07dcde9

config.py: Adds more thorough checking for setting self.work

 WebappConfig/config.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index acf7b7a..99ccedd 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -582,7 +582,7 @@ class Config:
 
         info_opts.add_argument('-li',
                                '--list-installs',
-                               action='store_true',
+                               nargs = 2,
                                help = 'List all current virtual installs for <a'
                                'pplication>. Use * for the package name and/or '
                                'version number to list more than one package / '
@@ -966,7 +966,7 @@ class Config:
             sys.exit()
 
         for i in work:
-            if options.get(i):
+            if options.get(i) != None and options.get(i) != False:
                 self.work = i
                 break
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-06-19 19:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-06-19 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     f58b8a92cbeb98a0360085090815d1e118ad1c13
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:15:27 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:19:14 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=f58b8a92

config.py: Changes --query nargs to 2

 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 84840bb..acf7b7a 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -633,7 +633,7 @@ class Config:
                                'instructions when they were shown to you ;-)')
 
         info_opts.add_argument('--query',
-                               action='store_true')
+                               nargs=2)
 
         #-----------------------------------------------------------------
         # Other Options


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  3:54 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  3:54 UTC (permalink / raw
  To: gentoo-commits

commit:     e3c34af712148f9ef5908be8d58455425b399e28
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 03:54:16 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 03:54:16 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=e3c34af7

config.py: Suppresses warning message for lack of -d flag for --query

 WebappConfig/config.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index ab19ee3..cb9d552 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -1013,7 +1013,8 @@ class Config:
                             pvr += argsvr[i]
                     self.config.set('USER', 'pvr', pvr)
 
-                if not options['dir'] and self.work != 'list_installs':
+                if (not options['dir'] and
+                    self.work not in ('list_installs', 'query')):
                     pn  = self.config.get('USER', 'pn')
                     msg = 'Install dir flag not supplied, defaulting to '\
                           '"%(pn)s".' % {'pn': pn}


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  3:44 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  3:44 UTC (permalink / raw
  To: gentoo-commits

commit:     06ee9ed48c9c25544eb0776c5f9797c0abbb898f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 03:44:03 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 03:44:03 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=06ee9ed4

db.py: Reverts OUT.info() call to print() in listinstalls()

 WebappConfig/db.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 06d9e04..0fbd34a 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -403,7 +403,7 @@ class WebappDB(AppHierarchy):
                     OUT.info('  ' + i[3].strip(), 1)
                 else:
                     # This is a simplified form for the webapp.eclass
-                    OUT.info(i[3].strip(), 1)
+                    print(i[3].strip())
 
 # ========================================================================
 # Handler for /usr/share/webapps


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  3:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  3:19 UTC (permalink / raw
  To: gentoo-commits

commit:     0c5f5843bcbe77cabd14ccc4efb745a4fb1639ed
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 03:19:16 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 03:19:18 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=0c5f5843

config.py: Readds the "dir" key to the option_to_config term

 WebappConfig/config.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 8d6a0ae..ab19ee3 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -892,6 +892,7 @@ class Config:
 
         # Map command line options into the configuration
         option_to_config = {'host'         : 'vhost_hostname',
+                            'dir'          : 'g_installdir',
                             'server'       : 'vhost_server',
                             'secure'       : 'g_secure',
                             'user'         : 'vhost_config_uid',


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  2:51 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  2:51 UTC (permalink / raw
  To: gentoo-commits

commit:     2fd12eb88ac1066ba296fff6b91c1a685ad41b8a
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:51:31 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 02:51:31 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=2fd12eb8

config.py: Message clean ups

 WebappConfig/config.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 37c2982..8d6a0ae 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -1001,7 +1001,8 @@ class Config:
                 if len(args) > 1:
                     argsvr = args[1].split('.')
                     if len(argsvr) == 1:
-                        OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+                        OUT.die('Invalid package version: %(pvr)s'
+                                % {'pvr': args[1]})
 
                     pvr = ''
                     for i in range(0, len(argsvr)):
@@ -1384,17 +1385,15 @@ class Config:
             # upgrade
 
             # okay - what do we have?
-
-            OUT.info('Removing '
-                     + old['WEB_CATEGORY'] + '/'
-                     + old['WEB_PN'] + '-'
-                     + old['WEB_PVR'] + ' from '
-                     + self.installdir() + '\n'
-                     + '  Installed by '
-                     + old['WEB_INSTALLEDBY'] + ' on '
-                     + old['WEB_INSTALLEDDATE'] + '\n'
-                     +'  Config files owned by '
-                     + old['WEB_INSTALLEDFOR'], 1)
+            msg = 'Removing '
+            if old['WEB_CATEGORY']:
+                msg += old['WEB_CATEGORY'] + '/'
+            msg += old['WEB_PN'] + '-' + old['WEB_PVR'] + ' from '\
+                   + self.installdir() + '\n  Installed by '\
+                   + old['WEB_INSTALLEDBY'] + ' on ' + old['WEB_INSTALLEDDATE']\
+                   + '\n  Config files owned by ' + old['WEB_INSTALLEDFOR']
+
+            OUT.info(msg, 1)
 
             content = self.create_content(old['WEB_CATEGORY'], old['WEB_PN'], old['WEB_PVR'])
             content.read()


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  2:42 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  2:42 UTC (permalink / raw
  To: gentoo-commits

commit:     057acc70d1b05474cf0569d35bb8c68ec250add0
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:40:12 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 02:40:16 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=057acc70

config.py: Allows for -lui to not have any arguments passed

Other command line flags such as -I, -C, or -U will always expect
2 command line args. If they are not properly supplied then that
is handled by argparse. This commit allows for the -lui flag that
can have 0 up to 2 optional flags passed to have that 0 flags passed.

 WebappConfig/config.py | 84 ++++++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 41 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index c9c0baf..37c2982 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -976,47 +976,49 @@ class Config:
                          'show_postinst', 'show_postupgrade', 'upgrade']:
             # get cat / pn
             args = options[self.work]
-            m    = args[0].split('/')
-
-            if self.work == 'list_installs' and len(args) > 2:
-                msg = os.path.basename(sys.argv[0]) + ': error: argument -li/'\
-                      '--list-installs: expected up to 2 arguments'
-
-                self.parser.print_usage()
-                print(msg)
-                sys.exit()
-
-            if len(m) == 1:
-                if '*' not in m:
-                    self.config.set('USER', 'pn',  m[0])
-            elif len(m) == 2:
-                self.config.set('USER', 'cat', m[0])
-                if '*' not in m:
-                    self.config.set('USER', 'pn',  m[1])
-            else:
-                OUT.die('Invalid package name')
-
-            if len(args) > 1:
-                argsvr = args[1].split('.')
-                if len(argsvr) == 1:
-                    OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
-
-                pvr = ''
-                for i in range(0, len(argsvr)):
-                    if not i == len(argsvr) - 1:
-                        pvr += argsvr[i] + '.'
-                    else:
-                        pvr += argsvr[i]
-                self.config.set('USER', 'pvr', pvr)
-
-            if not options['dir'] and self.work != 'list_installs':
-                pn  = self.config.get('USER', 'pn')
-                msg = 'Install dir flag not supplied, defaulting to '\
-                      '"%(pn)s".' % {'pn': pn}
-
-                OUT.warn(msg)
-                self.config.set('USER', 'g_installdir', pn)
-                self.flag_dir = True
+
+            if len(args):
+                m    = args[0].split('/')
+
+                if self.work == 'list_installs' and len(args) > 2:
+                    msg = os.path.basename(sys.argv[0]) + ': error: argument '\
+                          '-li/--list-installs: expected up to 2 arguments'
+
+                    self.parser.print_usage()
+                    print(msg)
+                    sys.exit()
+
+                if len(m) == 1:
+                    if '*' not in m:
+                        self.config.set('USER', 'pn',  m[0])
+                elif len(m) == 2:
+                    self.config.set('USER', 'cat', m[0])
+                    if '*' not in m:
+                        self.config.set('USER', 'pn',  m[1])
+                else:
+                    OUT.die('Invalid package name')
+
+                if len(args) > 1:
+                    argsvr = args[1].split('.')
+                    if len(argsvr) == 1:
+                        OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+
+                    pvr = ''
+                    for i in range(0, len(argsvr)):
+                        if not i == len(argsvr) - 1:
+                            pvr += argsvr[i] + '.'
+                        else:
+                            pvr += argsvr[i]
+                    self.config.set('USER', 'pvr', pvr)
+
+                if not options['dir'] and self.work != 'list_installs':
+                    pn  = self.config.get('USER', 'pn')
+                    msg = 'Install dir flag not supplied, defaulting to '\
+                          '"%(pn)s".' % {'pn': pn}
+
+                    OUT.warn(msg)
+                    self.config.set('USER', 'g_installdir', pn)
+                    self.flag_dir = True
 
 
     # --------------------------------------------------------------------


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  2:28 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  2:28 UTC (permalink / raw
  To: gentoo-commits

commit:     bfbfdd01c9d143015c5f08fb29410d980f498594
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:26:44 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 02:26:47 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=bfbfdd01

config.py: Adds optionality to --dir flag

If the --dir flag is not specified with actions that require
the dir flag then webapp-config will default to the name of the
package as the installation directory.

 WebappConfig/config.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 06dfc4c..c9c0baf 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -429,8 +429,9 @@ class Config:
                                '--dir',
                                nargs = 1,
                                help = 'Install <application> into DIR under the'
-                               ' htdocs dir. The default is '
-                               + self.config.get('USER', 'g_installdir'))
+                               ' htdocs dir. Not specifying using this flag'
+                               ' will result in defaulting to the package '
+                               ' name.')
 
         inst_locs.add_argument('-h',
                                '--host',
@@ -891,7 +892,6 @@ class Config:
 
         # Map command line options into the configuration
         option_to_config = {'host'         : 'vhost_hostname',
-                            'dir'          : 'g_installdir',
                             'server'       : 'vhost_server',
                             'secure'       : 'g_secure',
                             'user'         : 'vhost_config_uid',
@@ -1009,6 +1009,15 @@ class Config:
                         pvr += argsvr[i]
                 self.config.set('USER', 'pvr', pvr)
 
+            if not options['dir'] and self.work != 'list_installs':
+                pn  = self.config.get('USER', 'pn')
+                msg = 'Install dir flag not supplied, defaulting to '\
+                      '"%(pn)s".' % {'pn': pn}
+
+                OUT.warn(msg)
+                self.config.set('USER', 'g_installdir', pn)
+                self.flag_dir = True
+
 
     # --------------------------------------------------------------------
     # Helper functions


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-17  0:38 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-17  0:38 UTC (permalink / raw
  To: gentoo-commits

commit:     169d2a845e27f960db82b5cfff9b59710c2975db
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 00:38:26 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun May 17 00:38:26 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=169d2a84

config.py: Removes unnecessary .keys() call for option_to_config dict

 WebappConfig/config.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 2c14baa..06dfc4c 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -904,15 +904,15 @@ class Config:
                             'verbose'      : 'g_verbose',
                             'bug_report'   : 'g_bugreport'}
 
-        for i in list(option_to_config.keys()):
-            if i in options and options[i]:
+        for key in option_to_config:
+            if key in options and options[key]:
                 # If it's a list, we're expecting only one value in the list.
-                if isinstance(options[i], list):
-                    self.config.set('USER', option_to_config[i],
-                                    str(options[i][0]))
+                if isinstance(options[key], list):
+                    self.config.set('USER', option_to_config[key],
+                                    str(options[key][0]))
                 else:
-                    self.config.set('USER', option_to_config[i],
-                                    str(options[i]))
+                    self.config.set('USER', option_to_config[key],
+                                    str(options[key]))
 
         # handle verbosity
         if ('pretend' in options


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2015-05-16  2:16 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2015-05-16  2:16 UTC (permalink / raw
  To: gentoo-commits

commit:     ff6001dfb23b82ae9c24a571f5ad1346f2b19210
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 02:10:54 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sat May 16 02:10:57 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=ff6001df

{config, db}.py: Adds proper support for list-installs command

The webapp-config man page says that the --list-installs flag
can be the package name, and/or version, or "*". So changes
needed to be made to allow for this functionality.

 WebappConfig/config.py | 43 +++++++++++++++++++++++++++----------------
 WebappConfig/db.py     |  2 +-
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index c87b93b..2c14baa 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -579,7 +579,7 @@ class Config:
 
         info_opts.add_argument('-li',
                                '--list-installs',
-                               nargs = 2,
+                               nargs = '*',
                                help = 'List all current virtual installs for <a'
                                'pplication>. Use * for the package name and/or '
                                'version number to list more than one package / '
@@ -972,32 +972,43 @@ class Config:
 
         OUT.debug('Checking command line arguments', 1)
 
-        if self.work in ['install', 'clean', 'query', 'show_postinst',
-                         'show_postupgrade', 'upgrade']:
+        if self.work in ['install', 'clean', 'query', 'list_installs',
+                         'show_postinst', 'show_postupgrade', 'upgrade']:
             # get cat / pn
             args = options[self.work]
+            m    = args[0].split('/')
+
+            if self.work == 'list_installs' and len(args) > 2:
+                msg = os.path.basename(sys.argv[0]) + ': error: argument -li/'\
+                      '--list-installs: expected up to 2 arguments'
 
-            m = args[0].split('/')
+                self.parser.print_usage()
+                print(msg)
+                sys.exit()
 
             if len(m) == 1:
-                self.config.set('USER', 'pn',  m[0])
+                if '*' not in m:
+                    self.config.set('USER', 'pn',  m[0])
             elif len(m) == 2:
                 self.config.set('USER', 'cat', m[0])
-                self.config.set('USER', 'pn',  m[1])
+                if '*' not in m:
+                    self.config.set('USER', 'pn',  m[1])
             else:
                 OUT.die('Invalid package name')
 
-            argsvr = args[1].split('.')
-            if len(argsvr) == 1:
-                OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+            if len(args) > 1:
+                argsvr = args[1].split('.')
+                if len(argsvr) == 1:
+                    OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
+
+                pvr = ''
+                for i in range(0, len(argsvr)):
+                    if not i == len(argsvr) - 1:
+                        pvr += argsvr[i] + '.'
+                    else:
+                        pvr += argsvr[i]
+                self.config.set('USER', 'pvr', pvr)
 
-            pvr = ''
-            for i in range(0, len(argsvr)):
-                if not i == len(argsvr) - 1:
-                    pvr += argsvr[i] + '.'
-                else:
-                    pvr += argsvr[i]
-            self.config.set('USER', 'pvr', pvr)
 
     # --------------------------------------------------------------------
     # Helper functions

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 0fbd34a..06d9e04 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -403,7 +403,7 @@ class WebappDB(AppHierarchy):
                     OUT.info('  ' + i[3].strip(), 1)
                 else:
                     # This is a simplified form for the webapp.eclass
-                    print(i[3].strip())
+                    OUT.info(i[3].strip(), 1)
 
 # ========================================================================
 # Handler for /usr/share/webapps


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-11-18  0:03 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-11-18  0:03 UTC (permalink / raw
  To: gentoo-commits

commit:     bb32ea1330beb131b4c7924247fa677e5e5099eb
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 14 01:06:26 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Nov 18 00:03:29 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=bb32ea13

config.py: Modifies import strategy for config parser

On systems which had dev-python/configparser installed (a package
to add support for the py3.x configparser class in py2.x)
webapp-config would make use of that class instead of py2.x's built
in ConfigParser class. This would lead to improper interpolation of
configuration variables that follow the syntax "${<var>}". This
dangerous behavior could (and has) lead to webapp-config installing
a webapp to the root filesystem of a host. This danger has been
avoided by modifying the import strategy for the config parser we're
using so that we force import the ConfigParser class if using py2.x.

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

---
 WebappConfig/config.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index cdae149..c87b93b 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -21,15 +21,12 @@
 
 import sys, os, os.path, re, socket, time
 
-try:
+if sys.hexversion >= 0x3000000:
     # Python 3
     import configparser
-    if sys.version_info >= (3, 2):
-        from configparser import ConfigParser as configparser_ConfigParser
-        from configparser import ExtendedInterpolation
-    else:
-        from configparser import SafeConfigParser as configparser_ConfigParser
-except ImportError:
+    from configparser import ConfigParser as configparser_ConfigParser
+    from configparser import ExtendedInterpolation
+else:
     # Python 2
     import ConfigParser as configparser
     from ConfigParser import SafeConfigParser as configparser_ConfigParser


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-11-17 23:58 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-11-17 23:58 UTC (permalink / raw
  To: gentoo-commits

commit:     297bd8868b4a73ee89721345ca21302891a6ef75
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 14 01:06:26 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 17 23:57:55 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=297bd886

config.py: Modifies import strategy for config parser

On systems which had dev-python/configparser installed (a package
to add support for the py3.x configparser class in py2.x)
webapp-config would make use of that class instead of py2.x's built
in ConfigParser class. This would lead to improper interpolation of
configuration variables that follow the syntax "${<var>}". This
dangerous behavior could (and has) lead to webapp-config installing
a webapp to the root filesystem of a host. This danger has been
avoided by modifying the import strategy for the config parser we're
using so that we force import the ConfigParser class if using py2.x.

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

---
 WebappConfig/config.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index cdae149..c87b93b 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -21,15 +21,12 @@
 
 import sys, os, os.path, re, socket, time
 
-try:
+if sys.hexversion >= 0x3000000:
     # Python 3
     import configparser
-    if sys.version_info >= (3, 2):
-        from configparser import ConfigParser as configparser_ConfigParser
-        from configparser import ExtendedInterpolation
-    else:
-        from configparser import SafeConfigParser as configparser_ConfigParser
-except ImportError:
+    from configparser import ConfigParser as configparser_ConfigParser
+    from configparser import ExtendedInterpolation
+else:
     # Python 2
     import ConfigParser as configparser
     from ConfigParser import SafeConfigParser as configparser_ConfigParser


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-11-17 23:42 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-11-17 23:42 UTC (permalink / raw
  To: gentoo-commits

commit:     695ce56acb34f80ac4788c845b85131896f4731f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 14 01:06:26 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 17 23:42:41 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=695ce56a

config.py: Modifies import strategy for config parser

On systems which had dev-python/configparser installed (a package
to add support for the py3.x configparser class in py2.x)
webapp-config would make use of that class instead of py2.x's built
in ConfigParser class. This would lead to improper interpolation of
configuration variables that follow the syntax "${<var>}". This
dangerous behavior could (and has) lead to webapp-config installing
a webapp to the root filesystem of a host. This danger has been
avoided by modifying the import strategy for the config parser we're
using so that we force import the ConfigParser class if using py2.x.

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

---
 WebappConfig/config.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index cdae149..c87b93b 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -21,15 +21,12 @@
 
 import sys, os, os.path, re, socket, time
 
-try:
+if sys.hexversion >= 0x3000000:
     # Python 3
     import configparser
-    if sys.version_info >= (3, 2):
-        from configparser import ConfigParser as configparser_ConfigParser
-        from configparser import ExtendedInterpolation
-    else:
-        from configparser import SafeConfigParser as configparser_ConfigParser
-except ImportError:
+    from configparser import ConfigParser as configparser_ConfigParser
+    from configparser import ExtendedInterpolation
+else:
     # Python 2
     import ConfigParser as configparser
     from ConfigParser import SafeConfigParser as configparser_ConfigParser


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-11-14  1:14 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-11-14  1:14 UTC (permalink / raw
  To: gentoo-commits

commit:     8a807c9d67ba7eadfb4695cdfbb8d7687dd2d26f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 14 01:06:26 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Nov 14 01:13:49 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=8a807c9d

config.py: Modifies import strategy for config parser

On systems which had dev-python/configparser installed (a package
to add support for the py3.x configparser class in py2.x)
webapp-config would make use of that class instead of py2.x's built
in ConfigParser class. This would lead to improper interpolation of
configuration variables that follow the syntax "${<var>}". This
dangerous behavior could (and has) lead to webapp-config installing
a webapp to the root filesystem of a host. This danger has been
avoided by modifying the import strategy for the config parser we're
using so that we force import the ConfigParser class if using py2.x.

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

---
 WebappConfig/config.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index cdae149..c87b93b 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -21,15 +21,12 @@
 
 import sys, os, os.path, re, socket, time
 
-try:
+if sys.hexversion >= 0x3000000:
     # Python 3
     import configparser
-    if sys.version_info >= (3, 2):
-        from configparser import ConfigParser as configparser_ConfigParser
-        from configparser import ExtendedInterpolation
-    else:
-        from configparser import SafeConfigParser as configparser_ConfigParser
-except ImportError:
+    from configparser import ConfigParser as configparser_ConfigParser
+    from configparser import ExtendedInterpolation
+else:
     # Python 2
     import ConfigParser as configparser
     from ConfigParser import SafeConfigParser as configparser_ConfigParser


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-16 19:18 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-16 19:18 UTC (permalink / raw
  To: gentoo-commits

commit:     bb1475714fd961943c83d57a54531a6fdab5b7fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 16 19:16:58 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 16 19:17:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=bb147571

config.py: Improves package version checking

With the previous method of setting the package version you were
unable to pass the package version to webapp-config if it had more
than one decimal point (ex: 1.0.1 wouldn't work), this commit attempts
to fix that issue.

---
 WebappConfig/config.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 10a6f26..5eb4584 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -990,11 +990,18 @@ class Config:
             else:
                 OUT.die('Invalid package name')
 
-            try:
-                self.config.set('USER', 'pvr', str(float(args[1])))
-            except ValueError:
+            argsvr = args[1].split('.')
+            if len(argsvr) == 1:
                 OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
 
+            pvr = ''
+            for i in range(0, len(argsvr)):
+                if not i == len(argsvr) - 1:
+                    pvr += argsvr[i] + '.'
+                else:
+                    pvr += argsvr[i]
+            self.config.set('USER', 'pvr', pvr)
+
     # --------------------------------------------------------------------
     # Helper functions
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-15 13:27 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-15 13:27 UTC (permalink / raw
  To: gentoo-commits

commit:     2ebf3e51d46a11c879f18ac8340743a355a630a8
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:30:40 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 15 13:25:25 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=2ebf3e51

config.py: Modifies --list_unused_installed to nargs = "*"

In order to allow the nature of --list_unused_installed to remain true
to the nature of the command line arg, the nargs has been changed to
"*". This allows --list_unused_installed to be called with 0 or more
args via the argparse python class.

---
 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 99ccedd..10a6f26 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -598,7 +598,7 @@ class Config:
 
         info_opts.add_argument('-lui',
                                '--list-unused-installs',
-                               action='store_true',
+                               nargs = '*',
                                help = 'List all master images which currently a'
                                're not used. Optionally, provide a package and/'
                                'or version number as arguments to restrict the '


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-15 13:27 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-15 13:27 UTC (permalink / raw
  To: gentoo-commits

commit:     d62c08a0cee1409e8e1206bf67e1703e19e1b6b8
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:26:36 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Oct 14 19:32:20 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=d62c08a0

config.py: Adds more thorough checking for setting self.work

---
 WebappConfig/config.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index acf7b7a..99ccedd 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -582,7 +582,7 @@ class Config:
 
         info_opts.add_argument('-li',
                                '--list-installs',
-                               action='store_true',
+                               nargs = 2,
                                help = 'List all current virtual installs for <a'
                                'pplication>. Use * for the package name and/or '
                                'version number to list more than one package / '
@@ -966,7 +966,7 @@ class Config:
             sys.exit()
 
         for i in work:
-            if options.get(i):
+            if options.get(i) != None and options.get(i) != False:
                 self.work = i
                 break
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-15 13:27 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-15 13:27 UTC (permalink / raw
  To: gentoo-commits

commit:     4da9492e716c4650bd1eec3e67668bf6f10b4f05
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:15:27 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Oct 14 19:32:19 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=4da9492e

config.py: Changes --query nargs to 2

---
 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 84840bb..acf7b7a 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -633,7 +633,7 @@ class Config:
                                'instructions when they were shown to you ;-)')
 
         info_opts.add_argument('--query',
-                               action='store_true')
+                               nargs=2)
 
         #-----------------------------------------------------------------
         # Other Options


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-14 19:13 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-14 19:13 UTC (permalink / raw
  To: gentoo-commits

commit:     ac7279ee82cc27440a19675ffec36a16a1aaa9f2
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 19:12:31 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Oct 14 19:12:36 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=ac7279ee

config.py: Adds "query" to list of actions to get pn and pvr

---
 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 7ea194f..84840bb 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -975,7 +975,7 @@ class Config:
 
         OUT.debug('Checking command line arguments', 1)
 
-        if self.work in ['install', 'clean', 'show_postinst',
+        if self.work in ['install', 'clean', 'query', 'show_postinst',
                          'show_postupgrade', 'upgrade']:
             # get cat / pn
             args = options[self.work]


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-14 17:14 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-14 17:14 UTC (permalink / raw
  To: gentoo-commits

commit:     0345016f5b5c44848a97637a4c6e6b9be28e6d7e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 14 17:14:32 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Oct 14 17:14:32 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=0345016f

config.py: Fixes list-installs help message

---
 WebappConfig/config.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 1b9ebde..7ea194f 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -585,10 +585,10 @@ class Config:
                                action='store_true',
                                help = 'List all current virtual installs for <a'
                                'pplication>. Use * for the package name and/or '
-                               'version number to list more thanone package / v'
-                               'ersion of a package.  Remember to include the *'
-                               ' in single quotes to stop your shell from expan'
-                               'ding it first!!')
+                               'version number to list more than one package / '
+                               'version of a package.  Remember to include the '
+                               '* in single quotes to stop your shell from expa'
+                               'nding it first!!')
 
         info_opts.add_argument('-ls',
                                '--list-servers',


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-09 18:02 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-09 18:02 UTC (permalink / raw
  To: gentoo-commits

commit:     a6f5f233863e55488bd1aa96853cf71b3ba9415e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  9 18:01:52 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct  9 18:01:56 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=a6f5f233

version.py: Updates version to reflect being on git

To show users that they are running a live version of webapp-config
the version has been changed to reflect that.

---
 WebappConfig/version.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/version.py b/WebappConfig/version.py
index 4d5931b..76448f2 100644
--- a/WebappConfig/version.py
+++ b/WebappConfig/version.py
@@ -13,7 +13,7 @@
 #
 # ========================================================================
 
-WCVERSION = '1.51'
+WCVERSION = '1.53-git'
 
 if __name__ == '__main__':
     print(WCVERSION)


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-09 17:58 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-09 17:58 UTC (permalink / raw
  To: gentoo-commits

commit:     2b265fb79f78542af6d01aec4f79947a1416af30
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  9 17:54:43 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct  9 17:54:43 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=2b265fb7

config.py: Adds exception handling for setting env vars

In some cases when setting environment variables you can encounter
an issue where you are trying to set a config value based on the
the environment variable and you run into a runtime error. One
notable situation is when you try to run webapp-config --envall
while running py2.7, you will run into an interpolation issue if
one of your environment variables includes a sort of interpolation
syntax such as: %s.

---
 WebappConfig/config.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index b708ee0..1b9ebde 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -873,9 +873,12 @@ class Config:
 
                     OUT.debug('Adding environment variable', 8)
 
-                    self.config.set('USER',
-                                    key.lower(),
-                                    value)
+                    try:
+                        self.config.set('USER',
+                                        key.lower(),
+                                        value)
+                    except ValueError:
+                        pass
 
         if ('define' in options and
               options['define']):


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-10-09 17:52 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-10-09 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     6fc3c7770b5aa64c1aa19a7523ca038df392fbae
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  9 17:50:01 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct  9 17:50:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=6fc3c777

{config, debug}.py: Migrates from optparse to argparse

This migration includes changes to how args are handled, along with
the semi-alphabetization of the command line args as well as all
necessary changes to have webapp-config properly work with argparse
in both py2.7 and py3.x.

---
 WebappConfig/config.py | 583 ++++++++++++++++++++++++++-----------------------
 WebappConfig/debug.py  | 130 ++++++-----
 2 files changed, 368 insertions(+), 345 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 5a04fb5..b708ee0 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -38,7 +38,7 @@ import WebappConfig.server
 import WebappConfig.permissions as Perm
 import WebappConfig.wrapper as wrapper
 
-from optparse             import OptionParser, OptionGroup
+from argparse             import ArgumentParser
 from WebappConfig.debug   import OUT
 from WebappConfig.version import WCVERSION
 
@@ -305,7 +305,7 @@ class Config:
         # Setup the command line parser
         self.setup_parser()
 
-        self.work = 'help'
+        self.work = ''
 
         self.flag_dir = False
 
@@ -379,291 +379,301 @@ class Config:
 
     def setup_parser(self):
 
-        self.parser = OptionParser(
-            usage   = '%prog [-ICU] [-dghus] <APPLICATION VERSION>',
-            version = self.config.get('USER', 'my_version'),
-            add_help_option = False)
+        self.parser  = ArgumentParser(
+            usage    = '%(prog)s [-ICU] [-dghus] <APPLICATION VERSION>',
+            add_help = False)
 
+        self.parser.add_argument('-v',
+                                 '--version',
+                                 action = 'version',
+                                 version = self.config.get('USER',
+                                 'my_version'))
         #-----------------------------------------------------------------
         # Usage
 
-        group = OptionGroup(self.parser, 'APPLICATION VERSION',
-                            'The name and version number of the web appli'
-                            'cation to install e.g. phpmyadmin 2.5.4. The '
-                            'APPLICATION must have already been installed'
-                            ' into the '
-                            + self.config.get('USER', 'my_approot') +
-                            ' directory tree using emerge')
-
-        self.parser.add_option_group(group)
+        app_ver = self.parser.add_argument_group('APPLICATION VERSION',
+                                                 'The name and version number '
+                                                 'of the web application to '
+                                                 'install. e.g. phpmyadmin 2.'
+                                                 '5.4. The APPLICATION must '
+                                                 'have already been installed '
+                                                 'into the %(approot)s direct'
+                                                 'ory tree using emerge'
+                                                 % {'approot':
+                                                    self.config.get('USER',
+                                                    'my_approot')})
 
         #-----------------------------------------------------------------
         # Main Options
 
-        group = OptionGroup(self.parser, '<Main Options>')
-
-        group.add_option('-I',
-                         '--install',
-                         action = 'store_true',
-                         help   = 'Install a web application')
+        main_opts = self.parser.add_argument_group('<Main Options>')
 
-        group.add_option('-C',
-                         '--clean',
-                         action = 'store_true',
-                         help   = 'Remove a web application')
+        main_opts.add_argument('-I',
+                               '--install',
+                               nargs = 2,
+                               help   = 'Install a web application')
 
-        group.add_option('-U',
-                         '--upgrade',
-                         action = 'store_true',
-                         help   = 'Upgrade a web application')
+        main_opts.add_argument('-C',
+                               '--clean',
+                               nargs = 2,
+                               help   = 'Remove a web application')
 
-        self.parser.add_option_group(group)
+        main_opts.add_argument('-U',
+                               '--upgrade',
+                               nargs = 2,
+                               help   = 'Upgrade a web application')
 
         #-----------------------------------------------------------------
         # Path Options
 
-        group = OptionGroup(self.parser, '<Installation Location>')
-
-        group.add_option('-h',
-                         '--host',
-                         help = 'The hostname to configure this applicati'
-                         'on to serve.  Also affects where some files go.'
-                         ' If you get this setting wrong, you may need to'
-                         ' re-install the application to correct the pro'
-                         'blem! Default is HOST = '
-                         + self.config.get('USER', 'vhost_hostname') +
-                         '. To change the default, change the value of "v'
-                         'host_hostname" in '
-                         + self.config.get('USER', 'my_etcconfig') +
-                         ' <NOTE>: if the default value is currently "loc'
-                         'alhost", that probably means that this computer'
-                         '\'s /etc/hosts file is not correctly configured'
-                         )
-
-        group.add_option('-d', '--dir',
-                         help = 'Install <application> into DIR under the'
-                         ' htdocs dir. The default is '
-                         + self.config.get('USER', 'g_installdir'))
-
-        group.add_option('-s', '--server',
-                         help = 'Specify which web SERVER to install the '
-                         'application to run under. Use webapp-config --l'
-                         'ist-servers to see supported web servers. The d'
-                         'efault is -s '
-                         + self.config.get('USER', 'vhost_server') +
-                         '. To change the default, change the value of VH'
-                         'OST_SERVER in '
-                         + self.config.get('USER', 'my_etcconfig'))
-
-        group.add_option('--secure', action='store_true',
-                         help = 'Install, upgrade, or clean files in htdo'
-                         'cs-secure rather than in the htdocs directory.')
-
-        self.parser.add_option_group(group)
+        inst_locs = self.parser.add_argument_group('<Installation Location>')
+
+        inst_locs.add_argument('-d',
+                               '--dir',
+                               nargs = 1,
+                               help = 'Install <application> into DIR under the'
+                               ' htdocs dir. The default is '
+                               + self.config.get('USER', 'g_installdir'))
+
+        inst_locs.add_argument('-h',
+                               '--host',
+                               nargs = 1,
+                               help = 'The hostname to configure this applicati'
+                               'on to serve.  Also affects where some files go.'
+                               ' If you get this setting wrong, you may need to'
+                               ' re-install the application to correct the pro'
+                               'blem! Default is HOST = '
+                               + self.config.get('USER', 'vhost_hostname') +
+                               '. To change the default, change the value of "v'
+                               'host_hostname" in '
+                               + self.config.get('USER', 'my_etcconfig') +
+                               ' <NOTE>: if the default value is currently "loc'
+                               'alhost", that probably means that this computer'
+                               '\'s /etc/hosts file is not correctly configured'
+                              )
+
+        inst_locs.add_argument('-S',
+                               '--secure', action='store_true',
+                               help = 'Install, upgrade, or clean files in htdo'
+                               'cs-secure rather than in the htdocs directory.')
+
+        inst_locs.add_argument('-s',
+                               '--server',
+                               nargs = 1,
+                               help = 'Specify which web SERVER to install the '
+                               'application to run under. Use webapp-config --l'
+                               'ist-servers to see supported web servers. The d'
+                               'efault is -s '
+                               + self.config.get('USER', 'vhost_server') +
+                               '. To change the default, change the value of VH'
+                               'OST_SERVER in '
+                               + self.config.get('USER', 'my_etcconfig'))
+
 
         #-----------------------------------------------------------------
         # Installation Options
 
-        group = OptionGroup(self.parser, '<Installation Options>')
-
-        group.add_option('-u',
-                         '--user',
-                         help = 'Install config files so that they can be'
-                         ' edited by USER. USER can be a username.Numeric'
-                         'al user ids are NOT supported. Default is USER '
-                         '= '
-                         + self.config.get('USER', 'vhost_config_uid') +
-                         ' To change the default, change the value of VHO'
-                         'ST_CONFIG_UID in '
-                         + self.config.get('USER', 'my_etcconfig'))
-
-        group.add_option('-g',
-                         '--group',
-                         help = 'Install config files so that they can be'
-                         ' edited by GROUP. GROUP can be a group name. Nu'
-                         'merical group ids are NOT supported.Default is '
-                         'GROUP = '
-                         + self.config.get('USER', 'vhost_config_gid') +
-                         'To change the default, change the value of VHOS'
-                         'T_CONFIG_GID in '
-                         + self.config.get('USER', 'my_etcconfig'))
-
-        group.add_option('--soft',
-                         action='store_true',
-                         help = 'Use symbolic links instead of hard links'
-                         ' when creating virtual files. <NOTE>: some pack'
-                         'ages will not work if you use this option')
-
-        group.add_option('--copy',
-                         action='store_true',
-                         help = 'Directly copy the webapp files from'
-             ' the /usr/share/webapps/ directory when installing'
-             ' the webapp.')
-
-        group.add_option('--virtual-files',
-                         '--vf',
-                         type = 'choice',
-                         choices = ['server-owned',
-                                    'config-owned',
-                                    'virtual'],
-                         help = 'Decide what happens when we\'re installi'
-                         'ng a file that could be shared (ie, one we woul'
-                         'dn\'t normally create a local copy of). VIRTUAL'
-                         '_FILES must be one of: "server-owned" [files ar'
-                         'e owned by the user and group thatthe web-serve'
-                         'r runs under], "config-owned" [files are owned '
-                         'by the user and group specified by the -u and -'
-                         'g switches to this script],"virtual" [files are'
-                         ' shared; a local copy is not created]. Default '
-                         'is '
-                         + self.config.get('USER',
-                                           'vhost_config_virtual_files') +
-                         '. To change these defaults, change the value of'
-                         ' VHOST_CONFIG_VIRTUAL_FILES in '
-                         + self.config.get('USER', 'my_etcconfig') +
-                         ' <NOTE>: Some -s <server> options may not suppo'
-                         'rt all values of VIRTUAL_FILES and will report '
-                         'an error')
-
-        group.add_option('--default-dirs',
-                         '--dd',
-                         type = 'choice',
-                         choices = ['server-owned',
-                                    'config-owned',
-                                    'default-owned'],
-                         help = 'Decide what happens when we\'re installi'
-                         'ng a directory that could be shared (ie, one we'
-                         ' wouldn\'t normally create a local copy of). DE'
-                         'FAULT_DIRS must be one of: "server-owned" [dirs'
-                         ' are owned by the user and group thatthe web-se'
-                         'rver runs under], "config-owned" [dirs are owne'
-                         'd by the user and group specified by the -u and'
-                         ' -g switches to this script],"default-owned" [d'
-                         'irs are owned by the user specified in VHOST_DE'
-                         'FAULT_UID:VHOST_DEFAULT_GID]. Default is '
-                         + self.config.get('USER',
-                                           'vhost_config_default_dirs') +
-                         '. To change these defaults, change the value of'
-                         ' VHOST_CONFIG_DEFAULT_DIRS in '
-                         + self.config.get('USER', 'my_etcconfig') +
-                         ' <NOTE>: Some -s <server> options may not suppo'
-                         'rt all values of DEFAULT_DIRS and will report a'
-                         'n error')
-
-        self.parser.add_option_group(group)
+        inst_opts = self.parser.add_argument_group('<Installation Options>')
+
+        inst_opts.add_argument('-c',
+                               '--copy',
+                               action='store_true',
+                               help = 'Directly copy the webapp files from'
+                               ' the /usr/share/webapps/ directory when installing'
+                               ' the webapp.')
+
+        inst_opts.add_argument('-sf',
+                               '--soft',
+                               action='store_true',
+                               help = 'Use symbolic links instead of hard links'
+                               ' when creating virtual files. <NOTE>: some pack'
+                               'ages will not work if you use this option')
+
+        inst_opts.add_argument('-g',
+                               '--group',
+                               nargs = 1,
+                               help = 'Install config files so that they can be'
+                               ' edited by GROUP. GROUP can be a group name. Nu'
+                               'merical group ids are NOT supported.Default is '
+                               'GROUP = '
+                               + self.config.get('USER', 'vhost_config_gid') +
+                               'To change the default, change the value of VHOS'
+                               'T_CONFIG_GID in '
+                               + self.config.get('USER', 'my_etcconfig'))
+
+        inst_opts.add_argument('-u',
+                               '--user',
+                               nargs = 1,
+                               help = 'Install config files so that they can be'
+                               ' edited by USER. USER can be a username.Numeric'
+                               'al user ids are NOT supported. Default is USER '
+                               '= '
+                               + self.config.get('USER', 'vhost_config_uid') +
+                               ' To change the default, change the value of VHO'
+                               'ST_CONFIG_UID in '
+                               + self.config.get('USER', 'my_etcconfig'))
+
+        inst_opts.add_argument('-vf',
+                               '--virtual-files',
+                               choices = ['server-owned',
+                                          'config-owned',
+                                          'virtual'],
+                               help = 'Decide what happens when we\'re installi'
+                               'ng a file that could be shared (ie, one we woul'
+                               'dn\'t normally create a local copy of). VIRTUAL'
+                               '_FILES must be one of: "server-owned" [files ar'
+                               'e owned by the user and group thatthe web-serve'
+                               'r runs under], "config-owned" [files are owned '
+                               'by the user and group specified by the -u and -'
+                               'g switches to this script],"virtual" [files are'
+                               ' shared; a local copy is not created]. Default '
+                               'is '
+                               + self.config.get('USER',
+                                                 'vhost_config_virtual_files') +
+                               '. To change these defaults, change the value of'
+                               ' VHOST_CONFIG_VIRTUAL_FILES in '
+                               + self.config.get('USER', 'my_etcconfig') +
+                               ' <NOTE>: Some -s <server> options may not suppo'
+                               'rt all values of VIRTUAL_FILES and will report '
+                               'an error')
+
+        inst_opts.add_argument('-dd',
+                               '--default-dirs',
+                               choices = ['server-owned',
+                                          'config-owned',
+                                          'default-owned'],
+                               help = 'Decide what happens when we\'re installi'
+                              'ng a directory that could be shared (ie, one we'
+                              ' wouldn\'t normally create a local copy of). DE'
+                              'FAULT_DIRS must be one of: "server-owned" [dirs'
+                              ' are owned by the user and group thatthe web-se'
+                              'rver runs under], "config-owned" [dirs are owne'
+                              'd by the user and group specified by the -u and'
+                              ' -g switches to this script],"default-owned" [d'
+                              'irs are owned by the user specified in VHOST_DE'
+                              'FAULT_UID:VHOST_DEFAULT_GID]. Default is '
+                              + self.config.get('USER',
+                                                'vhost_config_default_dirs') +
+                              '. To change these defaults, change the value of'
+                              ' VHOST_CONFIG_DEFAULT_DIRS in '
+                              + self.config.get('USER', 'my_etcconfig') +
+                              ' <NOTE>: Some -s <server> options may not suppo'
+                              'rt all values of DEFAULT_DIRS and will report a'
+                              'n error')
+
 
         #-----------------------------------------------------------------
         # Information Options
 
-        group = OptionGroup(self.parser, '<Information Options>')
-
-        group.add_option('--pretend',
-                         action='store_true',
-                         help = 'Output information about what webapp-con'
-                         'fig would do, then quit without actually doing '
-                         'it')
-
-        group.add_option('-V',
-                         '--verbose',
-                         action='store_true',
-                         help = 'Output even more information than normal'
-                         )
-
-        group.add_option('--list-servers',
-                         '--ls',
-                         action='store_true',
-                         help = 'List all web servers currently supported'
-                         ' by webapp-config')
-
-        group.add_option('--list-installs',
-                         '--li',
-                         action='store_true',
-                         help = 'List all current virtual installs for <a'
-                         'pplication>. Use * for the package name and/or '
-                         'version number to list more thanone package / v'
-                         'ersion of a package.  Remember to include the *'
-                         ' in single quotes to stop your shell from expan'
-                         'ding it first!!')
-
-        group.add_option('--list-unused-installs',
-                         '--lui',
-                         action='store_true',
-                         help = 'List all master images which currently a'
-                         're not used. Optionally, provide a package and/'
-                         'or version number as arguments to restrict the '
-                         'listing.')
-
-        group.add_option('--prune-database',
-                         '--pd',
-                         type = 'choice',
-                         choices = ['pretend',
-                                    'clean'],
-                         help = 'This will list all outdated entries in '
-                         'the webapp-config "database".')
-
-        group.add_option('--show-installed',
-                         '--si',
-                         action='store_true',
-                         help = 'Show what application is installed in DI'
-                         'R')
-
-        group.add_option('--show-postinst',
-                         '--spi',
-                         action='store_true',
-                         help = 'Show the post-installation instructions '
-                         'for <application>. Very handy if you\'ve lost t'
-                         'he instructions when they were shown to you ;-)'
-                         )
-
-        group.add_option('--show-postupgrade',
-                         '--spu',
-                         action='store_true')
-
-        group.add_option('--query',
-                         action='store_true')
-
-        self.parser.add_option_group(group)
+        info_opts = self.parser.add_argument_group('<Information Options>')
+
+        info_opts.add_argument('-P',
+                               '--pretend',
+                               action='store_true',
+                               help = 'Output information about what webapp-con'
+                               'fig would do, then quit without actually doing '
+                               'it')
+
+        info_opts.add_argument('-V',
+                               '--verbose',
+                               action='store_true',
+                               help = 'Output even more information than normal'
+                               )
+
+        info_opts.add_argument('-li',
+                               '--list-installs',
+                               action='store_true',
+                               help = 'List all current virtual installs for <a'
+                               'pplication>. Use * for the package name and/or '
+                               'version number to list more thanone package / v'
+                               'ersion of a package.  Remember to include the *'
+                               ' in single quotes to stop your shell from expan'
+                               'ding it first!!')
+
+        info_opts.add_argument('-ls',
+                               '--list-servers',
+                               action='store_true',
+                               help = 'List all web servers currently supported'
+                               ' by webapp-config')
+
+        info_opts.add_argument('-lui',
+                               '--list-unused-installs',
+                               action='store_true',
+                               help = 'List all master images which currently a'
+                               're not used. Optionally, provide a package and/'
+                               'or version number as arguments to restrict the '
+                               'listing.')
+
+        info_opts.add_argument('-pd',
+                               '--prune-database',
+                               choices = ['pretend',
+                                          'clean'],
+                               help = 'This will list all outdated entries in '
+                               'the webapp-config "database".')
+
+        info_opts.add_argument('-si',
+                               '--show-installed',
+                               action='store_true',
+                               help = 'Show what application is installed in DI'
+                               'R')
+
+        info_opts.add_argument('-spi',
+                               '--show-postinst',
+                               nargs = 2,
+                               help = 'Show the post-installation instructions '
+                               'for <application>. Very handy if you\'ve lost t'
+                               'he instructions when they were shown to you ;-)'
+                               )
+
+        info_opts.add_argument('-spu',
+                               '--show-postupgrade',
+                               nargs = 2,
+                               help = 'Show the post-upgrade instructions for '
+                               '<application>. Very handy if you\'ve lost the '
+                               'instructions when they were shown to you ;-)')
+
+        info_opts.add_argument('--query',
+                               action='store_true')
 
         #-----------------------------------------------------------------
         # Other Options
 
-        group = OptionGroup(self.parser, '<Other Options>')
-
-        group.add_option('-D',
-                         '--define',
-                         action='append',
-                         help = 'Allows to name a <KEY>=<VALUE> pair that'
-                         'will be imported into the configuration variabl'
-                         'es of webapp-config. This allows you to provide'
-                         ' customized variables which can be used in the '
-                         'configuration file. This can also be used to te'
-                         'mporarily overwrite variables from the configur'
-                         'ation file.'
-                         )
-
-        group.add_option('-E',
-                         '--envvar',
-                         action='append',
-                         help = 'Allows to name single environment variab'
-                         'le that will be imported by webapp-config. Thi'
-                         's allows you to provide customized variables wh'
-                         'ich can be used in the configuration file. This'
-                         ' can also be used to temporarily overwrite vari'
-                         'ables from the configuration file.'
-                         )
-
-        group.add_option('--envall',
-                         action='store_true',
-                         help = 'Imports all environment variables and ov'
-                         'erwrites configurations read from the configura'
-                         'tion file. Setting this switch is not recommend'
-                         'ed since you might have environment variables s'
-                         'et to values that cannot be parsed.')
-
-        group.add_option('-?', '--help', action='help',
-                         help = 'Show this help')
-
-        self.parser.add_option_group(group)
+        alio_opts = self.parser.add_argument_group('<Other Options>')
+
+        alio_opts.add_argument('-D',
+                               '--define',
+                               action = 'append',
+                               help = 'Allows to name a <KEY>=<VALUE> pair that'
+                               'will be imported into the configuration variabl'
+                               'es of webapp-config. This allows you to provide'
+                               ' customized variables which can be used in the '
+                               'configuration file. This can also be used to te'
+                               'mporarily overwrite variables from the configur'
+                               'ation file.')
+
+        alio_opts.add_argument('--envall',
+                               action='store_true',
+                               help = 'Imports all environment variables and ov'
+                               'erwrites configurations read from the configura'
+                               'tion file. Setting this switch is not recommend'
+                               'ed since you might have environment variables s'
+                               'et to values that cannot be parsed.')
+
+        alio_opts.add_argument('-E',
+                               '--envvar',
+                               action='append',
+                               help = 'Allows to name single environment variab'
+                               'le that will be imported by webapp-config. This'
+                               ' allows you to provide customized variables whi'
+                               'ch can be used in the configuration file. This '
+                               'can also be used to temporarily overwrite varia'
+                               'bles from the configuration file.')
+
+        alio_opts.add_argument('-?',
+                               '--help',
+                               action='help',
+                               help = 'Show this help')
+
 
         #-----------------------------------------------------------------
         # Debug Options
@@ -673,19 +683,19 @@ class Config:
         #-----------------------------------------------------------------
         # Bug Options
 
-        group = OptionGroup(self.parser,
-                            '<Reporting Bugs>',
-                            'To report bugs about webapp-config, please g'
-                            'o to '
-                            + self.config.get('USER', 'my_bugsurl')
-                            + '. Include the output of webapp-config --bu'
-                            'g-report <your parameters here> to help us t'
-                            'o help you')
+        bug_opts = self.parser.add_argument_group('<Reporting Bugs>',
+                                                  'To report bugs about webapp'
+                                                  '-config, please go to '
+                                                  + self.config.get('USER',
+                                                                  'my_bugsurl')
+                                                  + '. Include the output of w'
+                                                  'ebapp-config --bug-report <'
+                                                  'your parameters here> to he'
+                                                  'lp us to help you')
 
-        group.add_option('--bug-report',
-                         action='store_true')
+        bug_opts.add_argument('--bug-report',
+                              action='store_true')
 
-        self.parser.add_option_group(group)
 
     # --------------------------------------------------------------------
     # Variable functions
@@ -834,7 +844,7 @@ class Config:
         OUT.debug('Successfully parsed configuration file options', 7)
 
         # Parse the command line
-        (options, args) = self.parser.parse_args()
+        options = vars(self.parser.parse_args())
 
         OUT.debug('Successfully parsed command line options', 7)
 
@@ -857,7 +867,7 @@ class Config:
         OUT.debug('Trying to import environment variables', 7)
 
         if envmap:
-            for (key, value) in os.environ.items():
+            for (key, value) in list(os.environ.items()):
 
                 if envmap == 'all' or key.lower() in envmap:
 
@@ -894,10 +904,15 @@ class Config:
                             'verbose'      : 'g_verbose',
                             'bug_report'   : 'g_bugreport'}
 
-        for i in option_to_config.keys():
+        for i in list(option_to_config.keys()):
             if i in options and options[i]:
-                self.config.set('USER', option_to_config[i],
-                                str(options[i]))
+                # If it's a list, we're expecting only one value in the list.
+                if isinstance(options[i], list):
+                    self.config.set('USER', option_to_config[i],
+                                    str(options[i][0]))
+                else:
+                    self.config.set('USER', option_to_config[i],
+                                    str(options[i]))
 
         # handle verbosity
         if ('pretend' in options
@@ -943,6 +958,10 @@ class Config:
                 'prune_database', 'show_installed', 'show_postinst',
                 'show_postupgrade', 'check_config', 'query']
 
+        if len(sys.argv) ==  1:
+            self.parser.print_help()
+            sys.exit()
+
         for i in work:
             if options.get(i):
                 self.work = i
@@ -953,9 +972,13 @@ class Config:
 
         OUT.debug('Checking command line arguments', 1)
 
-        if len(args) > 0:
+        if self.work in ['install', 'clean', 'show_postinst',
+                         'show_postupgrade', 'upgrade']:
             # get cat / pn
+            args = options[self.work]
+
             m = args[0].split('/')
+
             if len(m) == 1:
                 self.config.set('USER', 'pn',  m[0])
             elif len(m) == 2:
@@ -964,8 +987,10 @@ class Config:
             else:
                 OUT.die('Invalid package name')
 
-        if len(args) > 1:
-            self.config.set('USER', 'pvr', args[-1])
+            try:
+                self.config.set('USER', 'pvr', str(float(args[1])))
+            except ValueError:
+                OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]})
 
     # --------------------------------------------------------------------
     # Helper functions

diff --git a/WebappConfig/debug.py b/WebappConfig/debug.py
index 3ced649..d2e4e96 100644
--- a/WebappConfig/debug.py
+++ b/WebappConfig/debug.py
@@ -15,8 +15,6 @@ from __future__ import print_function
 
 import sys, inspect
 
-from   optparse      import OptionGroup
-
 #################################################################################
 ##
 ## Color codes (taken from portage)
@@ -103,66 +101,66 @@ class Message:
 
     def cli_opts(self, parser):
 
-        group = OptionGroup(parser,
-                            '<Debugging options>',
-                            'Control the debugging features of '
-                            + self.debug_env)
-
-        group.add_option('--debug',
-                         action = 'store_true',
-                         help = 'Activates debugging features.')
-
-        group.add_option('--debug-level',
-                         action = 'store',
-                         type = 'int',
-                         help = 'A value between 0 and 10. 0 means no debugging '
-                         'messages will be selected, 10 selects all debugging me'
-                         'ssages. Default is "4".')
-
-        group.add_option('--debug-verbose',
-                         action = 'store',
-                         type = 'int',
-                         help = 'A value between 1 and 3. Lower values yield les'
-                         's verbose debugging output. Default is "2".')
-
-        group.add_option('--debug-methods',
-                         action = 'store',
-                         help = 'Limits the methods that will return debugging o'
-                         'utput. The function name is sufficient and there is no'
-                         'difference between class methods or general functions.'
-                         ' Several methods can be specified by seperating them w'
-                         ' with a comma. Default is "*" which specifies all meth'
-                         'ods.')
-
-        group.add_option('--debug-classes',
-                         action = 'store',
-                         help = 'Limits the classes that will return debugging o'
-                         'utput. Specify only the class name not including the m'
-                         'odules in which the class is defined (e.g. MyModule.ma'
-                         'in.Main should only be represented by "Main"). Several'
-                         'classes can be specified by seperating them with a com'
-                         'ma. Default is "*" which specifies all classes.')
-
-        group.add_option('--debug-variables',
-                         action = 'store',
-                         help = 'Limits the variables that will return debugging'
-                         ' output. Several variables can be specified by seperat'
-                         'ing them with a comma. Default is "*" which specifies '
-                         'all variables.')
-
-        group.add_option('--debug-class-vars',
-                         action = 'store_true',
-                         help = 'In default mode the debugging code will only re'
-                         'turn information on the local variable which does not '
-                         'include the class variables. Use this switch to add al'
-                         'l values that are provided by "self".')
-
-        group.add_option('--debug-nocolor',
-                         action = 'store_true',
-                         help = 'Deactivates colors in the debugging output.')
-
-        parser.add_option_group(group)
-
+        debug_opts = parser.add_argument_group('<Debugging options>',
+                                               'Control the debugging features '
+                                               'of ' + self.debug_env + '.')
+
+        debug_opts.add_argument('--debug',
+                                action = 'store_true',
+                                help = 'Activates debugging features.')
+
+        debug_opts.add_argument('--debug-classes',
+                                nargs = '+',
+                                help = 'Limits the classes that will return deb'
+                                'ugging output. Specify only the class name not'
+                                'including the modules in which the class is de'
+                                'fined (e.g. MyModule.main.Main should only be '
+                                'represented by "Main"). Several classes can be'
+                                'specified by seperating them with a comma. Def'
+                                'ault is "*" which specifies all classes.')
+
+        debug_opts.add_argument('--debug-class-vars',
+                                action = 'store_true',
+                                help = 'In default mode the debugging code will'
+                                'only return information on the local variable '
+                                'which does not include the class variables. Us'
+                                'e this switch to add all values that are provi'
+                                'ded by "self".')
+
+        debug_opts.add_argument('--debug-level',
+                                action = 'store',
+                                type = int,
+                                help = 'A value between 0 and 10. 0 means no de'
+                                'bugging messages will be selected, 10 selects '
+                                'all debugging messages. Default is "4".')
+
+        debug_opts.add_argument('--debug-methods',
+                                nargs = '+',
+                                help = 'Limits the methods that will return deb'
+                                'ugging output. The function name is sufficient'
+                                ' and there is no difference between class meth'
+                                'ods or general functions. Several methods can '
+                                'be specified by seperating them with a comma. '
+                                'Default is "*" which specifies all methods.')
+
+        debug_opts.add_argument('--debug-nocolor',
+                                action = 'store_true',
+                                help = 'Deactivates colors in the debugging out'
+                                'put.')
+
+        debug_opts.add_argument('--debug-variables',
+                                nargs = '+',
+                                help = 'Limits the variables that will return d'
+                               'ebugging output. Several variables can be speci'
+                               'fied by seperating them with a comma. Default i'
+                               's "*" which specifies all variables.')
+
+        debug_opts.add_argument('--debug-verbose',
+                                action = 'store',
+                                type = int,
+                                help = 'A value between 1 and 3. Lower values y'
+                                'ield less verbose debugging output. Default is'
+                                ' "2".')
 
     #############################################################################
     # Handle command line options
@@ -395,7 +393,7 @@ class Message:
         callerlocals = inspect.getargvalues(caller[0])[3]
 
         ## Is the caller an obejct? If so he provides 'self'
-        if 'self' in callerlocals.keys():
+        if 'self' in list(callerlocals.keys()):
             callerobject = callerlocals['self']
             del callerlocals['self']
             if self.show_class_variables:
@@ -407,7 +405,7 @@ class Message:
 
         # Remove variables not requested
         if not '*' in self.debug_var:
-            callerlocals = dict([i for i in callerlocals.items()
+            callerlocals = dict([i for i in list(callerlocals.items())
                                  if i[0] in self.debug_var])
 
         ## Is the object among the list of objects to debug?
@@ -445,7 +443,7 @@ class Message:
             print('// ' + c, file=self.debug_out)
             # Selected variables follow
             if callerlocals:
-                for i,j in callerlocals.items():
+                for i,j in list(callerlocals.items()):
                     print('// '                              \
                           + self.maybe_color('turquoise', str(i)) + ':' + str(j), file=self.debug_out)
             # Finally the message
@@ -480,7 +478,7 @@ class Message:
             if self.debug_vrb == 3:
                 print(ls + '//', file=self.debug_out)
                 print(ls + '// VALUES ', file=self.debug_out)
-            for i,j in callerlocals.items():
+            for i,j in list(callerlocals.items()):
                 print(ls + '// ------------------> '         \
                       + self.maybe_color('turquoise', str(i)) + ':', file=self.debug_out)
                 breaklines(str(j))


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-09-23 17:09 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-09-23 17:09 UTC (permalink / raw
  To: gentoo-commits

commit:     a05f1ed3659699ac75d5c489049babe4b8e3fef0
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 23 16:25:30 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Sep 23 16:25:30 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=a05f1ed3

{config, debug}.py: Removes deprecated use of __dict__ invocation

---
 WebappConfig/config.py | 36 ++++++++++++++++++------------------
 WebappConfig/debug.py  | 38 +++++++++++++++++++-------------------
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 597dc18..5a04fb5 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -846,18 +846,18 @@ class Config:
         # Handle -E
         envmap = []
 
-        if ('envall' in options.__dict__ and 
-            options.__dict__['envall']):
+        if ('envall' in options and 
+            options['envall']):
             envmap = 'all'
 
-        elif ('envvar' in options.__dict__ and 
-              options.__dict__['envvar']):
-            envmap = [x.lower() for x in options.__dict__['envvar']]
+        elif ('envvar' in options and 
+              options['envvar']):
+            envmap = [x.lower() for x in options['envvar']]
 
         OUT.debug('Trying to import environment variables', 7)
 
         if envmap:
-            for (key, value) in list(os.environ.items()):
+            for (key, value) in os.environ.items():
 
                 if envmap == 'all' or key.lower() in envmap:
 
@@ -867,16 +867,16 @@ class Config:
                                     key.lower(),
                                     value)
 
-        if ('define' in options.__dict__ and
-              options.__dict__['define']):
-            for i in options.__dict__['define']:
+        if ('define' in options and
+              options['define']):
+            for i in options['define']:
                 if '=' in i:
                     self.config.set('USER', 
                                     i.split('=')[0].lower(),
                                     i.split('=')[1])
 
         # Indicate that --dir was found
-        if 'dir' in options.__dict__:
+        if 'dir' in options:
             self.flag_dir = True
 
         # Map command line options into the configuration
@@ -894,14 +894,14 @@ class Config:
                             'verbose'      : 'g_verbose',
                             'bug_report'   : 'g_bugreport'}
 
-        for i in list(option_to_config.keys()):
-            if i in options.__dict__ and options.__dict__[i]:
+        for i in option_to_config.keys():
+            if i in options and options[i]:
                 self.config.set('USER', option_to_config[i],
-                                str(options.__dict__[i]))
+                                str(options[i]))
 
         # handle verbosity
-        if ('pretend' in options.__dict__
-            and options.__dict__['pretend']):
+        if ('pretend' in options
+            and options['pretend']):
 
             self.config.set('USER', 'g_verbose', 'True')
 
@@ -944,12 +944,12 @@ class Config:
                 'show_postupgrade', 'check_config', 'query']
 
         for i in work:
-            if options.__dict__.get(i):
+            if options.get(i):
                 self.work = i
                 break
 
-        if options.__dict__.get('prune_database'):
-            self.prune_action = options.__dict__.get('prune_database')
+        if options.get('prune_database'):
+            self.prune_action = options.get('prune_database')
 
         OUT.debug('Checking command line arguments', 1)
 

diff --git a/WebappConfig/debug.py b/WebappConfig/debug.py
index 1e6bd2c..3ced649 100644
--- a/WebappConfig/debug.py
+++ b/WebappConfig/debug.py
@@ -169,37 +169,37 @@ class Message:
 
     def cli_handle(self, options):
 
-        if ('debug' in options.__dict__
-            and options.__dict__['debug']):
+        if ('debug' in options
+            and options['debug']):
             self.debug_on()
         else:
             self.debug_off()
             return
 
-        if ('debug_class_vars' in options.__dict__
-            and options.__dict__['debug_class_vars']):
+        if ('debug_class_vars' in options
+            and options['debug_class_vars']):
             self.class_variables_on()
         else:
             self.class_variables_off()
 
-        if ('debug_nocolor' in options.__dict__
-            and options.__dict__['debug_nocolor']):
+        if ('debug_nocolor' in options
+            and options['debug_nocolor']):
             self.color_off()
         else:
             self.color_on()
 
-        if ('debug_level' in options.__dict__ and
-            options.__dict__['debug_level']):
-            dbglvl = int(options.__dict__['debug_level'])
+        if ('debug_level' in options and
+            options['debug_level']):
+            dbglvl = int(options['debug_level'])
             if dbglvl < 0:
                 dbglvl = 0
             if dbglvl > 10:
                 dbglvl = 10
             self.set_debug_level(dbglvl)
 
-        if ('debug_verbose' in options.__dict__ and
-            options.__dict__['debug_verbose']):
-            dbgvrb = int(options.__dict__['debug_verbose'])
+        if ('debug_verbose' in options and
+            options['debug_verbose']):
+            dbgvrb = int(options['debug_verbose'])
             if dbgvrb < 1:
                 dbgvrb = 1
             if dbgvrb > 3:
@@ -210,9 +210,9 @@ class Message:
                   ('debug_classes',   self.set_debug_classes),
                   ('debug_variables', self.set_debug_variables),]:
 
-            if (i[0] in options.__dict__ and
-                options.__dict__[i[0]]):
-                i[1](options.__dict__[i[0]])
+            if (i[0] in options and
+                options[i[0]]):
+                i[1](options[i[0]])
 
 
     #############################################################################
@@ -395,7 +395,7 @@ class Message:
         callerlocals = inspect.getargvalues(caller[0])[3]
 
         ## Is the caller an obejct? If so he provides 'self'
-        if 'self' in list(callerlocals.keys()):
+        if 'self' in callerlocals.keys():
             callerobject = callerlocals['self']
             del callerlocals['self']
             if self.show_class_variables:
@@ -407,7 +407,7 @@ class Message:
 
         # Remove variables not requested
         if not '*' in self.debug_var:
-            callerlocals = dict([i for i in list(callerlocals.items())
+            callerlocals = dict([i for i in callerlocals.items()
                                  if i[0] in self.debug_var])
 
         ## Is the object among the list of objects to debug?
@@ -445,7 +445,7 @@ class Message:
             print('// ' + c, file=self.debug_out)
             # Selected variables follow
             if callerlocals:
-                for i,j in list(callerlocals.items()):
+                for i,j in callerlocals.items():
                     print('// '                              \
                           + self.maybe_color('turquoise', str(i)) + ':' + str(j), file=self.debug_out)
             # Finally the message
@@ -480,7 +480,7 @@ class Message:
             if self.debug_vrb == 3:
                 print(ls + '//', file=self.debug_out)
                 print(ls + '// VALUES ', file=self.debug_out)
-            for i,j in list(callerlocals.items()):
+            for i,j in callerlocals.items():
                 print(ls + '// ------------------> '         \
                       + self.maybe_color('turquoise', str(i)) + ':', file=self.debug_out)
                 breaklines(str(j))


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-04-26 19:33 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-04-26 19:33 UTC (permalink / raw
  To: gentoo-commits

commit:     b7d8fbf7ad46ba1e420956ff28eaf6a827e39f3d
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 26 19:29:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sat Apr 26 19:29:23 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=b7d8fbf7

Adds python3.x compatibility to codebase.

Although most of the codebase already has python3.x compatibility
when running 2to3 more minor changes where found. This commit
includes the changes found when running 2to3 on webapp-config's
codebase.

---
 WebappConfig/config.py    |  4 ++--
 WebappConfig/content.py   | 22 +++++++++++-----------
 WebappConfig/db.py        |  4 ++--
 WebappConfig/debug.py     |  8 ++++----
 WebappConfig/dotconfig.py |  6 +++---
 WebappConfig/ebuild.py    |  2 +-
 WebappConfig/filetype.py  |  6 +++---
 WebappConfig/sandbox.py   |  4 ++--
 8 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 1f3fab1..597dc18 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -857,7 +857,7 @@ class Config:
         OUT.debug('Trying to import environment variables', 7)
 
         if envmap:
-            for (key, value) in os.environ.items():
+            for (key, value) in list(os.environ.items()):
 
                 if envmap == 'all' or key.lower() in envmap:
 
@@ -894,7 +894,7 @@ class Config:
                             'verbose'      : 'g_verbose',
                             'bug_report'   : 'g_bugreport'}
 
-        for i in option_to_config.keys():
+        for i in list(option_to_config.keys()):
             if i in options.__dict__ and options.__dict__[i]:
                 self.config.set('USER', option_to_config[i],
                                 str(options.__dict__[i]))

diff --git a/WebappConfig/content.py b/WebappConfig/content.py
index c635f5a..e157d23 100644
--- a/WebappConfig/content.py
+++ b/WebappConfig/content.py
@@ -291,7 +291,7 @@ class Contents:
 
         self.check_installdir()
 
-        values = [' '.join(i) for i in self.__content.values()]
+        values = [' '.join(i) for i in list(self.__content.values())]
 
         if not self.__p:
             try:
@@ -481,7 +481,7 @@ class Contents:
             'sym'     : [  'sym', self.file_zero, self.file_link ],
             }
 
-        if not dsttype in allowed_types.keys():
+        if not dsttype in list(allowed_types.keys()):
             OUT.die('Oops, webapp-config bug. "dsttype" is ' + dsttype)
 
         # Generate handler for file attributes
@@ -548,7 +548,7 @@ class Contents:
         ''' Get a list of files. This is returned as a list sorted according
         to length, so that files lower in the hierarchy can be removed
         first.'''
-        installed = self.__content.keys()
+        installed = list(self.__content.keys())
         return sorted(installed, key=lambda x: (-len(x), x))
 
     def get_directories(self):
@@ -675,7 +675,7 @@ class Contents:
 
     def entry(self, entry):
         ''' Return a complete entry.'''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return ' '.join(self.__content[entry])
         else:
             raise Exception('Unknown file "' + entry + '"')
@@ -684,7 +684,7 @@ class Contents:
         '''
         Returns the entry type.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return self.__content[entry][0]
         else:
             raise Exception('Unknown file "' + entry + '"')
@@ -693,7 +693,7 @@ class Contents:
         '''
         Returns if the entry is relative or not.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return bool(int(self.__content[entry][1]))
         else:
             raise Exception('Unknown file "' + entry + '"')
@@ -702,7 +702,7 @@ class Contents:
         '''
         Returns the owner of the entry.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return self.__content[entry][2]
         else:
             raise Exception('Unknown file "' + entry + '"')
@@ -711,7 +711,7 @@ class Contents:
         '''
         Returns the (possibly relative) path of the entry.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             msg = self.__content[entry][3]
             if msg[0] == "/":
                 msg = self.__root + msg
@@ -724,7 +724,7 @@ class Contents:
         '''
         Returns the recorded modification time of the entry.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return self.__content[entry][4]
         else:
             raise Exception('Unknown file "' + entry + '"')
@@ -733,7 +733,7 @@ class Contents:
         '''
         Returns the recorded md5 hash of the entry.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return self.__content[entry][5]
         else:
             raise Exception('Unknown file "' + entry + '"')
@@ -742,7 +742,7 @@ class Contents:
         '''
         Returns the recorded target of the link.
         '''
-        if entry in self.__content.keys():
+        if entry in list(self.__content.keys()):
             return self.__content[entry][6]
         else:
             raise Exception('Unknown file "' + entry + '"')

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 2d70cb9..aa33ac5 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -405,7 +405,7 @@ class WebappDB(AppHierarchy):
 
         result = {}
 
-        for j in files.keys():
+        for j in list(files.keys()):
 
             if files[j][0]:
                 p = files[j][0] + '/' + files[j][1] + '-' + files[j][2]
@@ -452,7 +452,7 @@ class WebappDB(AppHierarchy):
                        OUT.warn('Assuming webapp is no longer installed.')
                        OUT.warn('Pruning entry from database.')
                     if action == 'clean':
-                        for installs in files.keys():
+                        for installs in list(files.keys()):
                             contents = open(installs).readlines()
                             new_entries = ''
                             for entry in contents:

diff --git a/WebappConfig/debug.py b/WebappConfig/debug.py
index 5482f43..1e6bd2c 100644
--- a/WebappConfig/debug.py
+++ b/WebappConfig/debug.py
@@ -395,7 +395,7 @@ class Message:
         callerlocals = inspect.getargvalues(caller[0])[3]
 
         ## Is the caller an obejct? If so he provides 'self'
-        if 'self' in callerlocals.keys():
+        if 'self' in list(callerlocals.keys()):
             callerobject = callerlocals['self']
             del callerlocals['self']
             if self.show_class_variables:
@@ -407,7 +407,7 @@ class Message:
 
         # Remove variables not requested
         if not '*' in self.debug_var:
-            callerlocals = dict([i for i in callerlocals.items()
+            callerlocals = dict([i for i in list(callerlocals.items())
                                  if i[0] in self.debug_var])
 
         ## Is the object among the list of objects to debug?
@@ -445,7 +445,7 @@ class Message:
             print('// ' + c, file=self.debug_out)
             # Selected variables follow
             if callerlocals:
-                for i,j in callerlocals.items():
+                for i,j in list(callerlocals.items()):
                     print('// '                              \
                           + self.maybe_color('turquoise', str(i)) + ':' + str(j), file=self.debug_out)
             # Finally the message
@@ -480,7 +480,7 @@ class Message:
             if self.debug_vrb == 3:
                 print(ls + '//', file=self.debug_out)
                 print(ls + '// VALUES ', file=self.debug_out)
-            for i,j in callerlocals.items():
+            for i,j in list(callerlocals.items()):
                 print(ls + '// ------------------> '         \
                       + self.maybe_color('turquoise', str(i)) + ':', file=self.debug_out)
                 breaklines(str(j))

diff --git a/WebappConfig/dotconfig.py b/WebappConfig/dotconfig.py
index cab0392..948fa90 100644
--- a/WebappConfig/dotconfig.py
+++ b/WebappConfig/dotconfig.py
@@ -115,7 +115,7 @@ class DotConfig:
                           'WEB_INSTALLDIR']
 
     def __getitem__(self, key):
-        if key in self.__data.keys():
+        if key in list(self.__data.keys()):
             return self.__data[key]
         # this key didn't exist in old versions, but new versions
         # expect it. fix bug 355295
@@ -180,8 +180,8 @@ class DotConfig:
 
         OUT.debug('Trying to retrieve package name', 6)
 
-        if 'WEB_PN' in self.__data.keys() and 'WEB_PVR' in self.__data.keys():
-            if 'WEB_CATEGORY' in self.__data.keys():
+        if 'WEB_PN' in list(self.__data.keys()) and 'WEB_PVR' in list(self.__data.keys()):
+            if 'WEB_CATEGORY' in list(self.__data.keys()):
                 return self.__data['WEB_CATEGORY'] + '/' + \
                     self.__data['WEB_PN'] + '-' + self.__data['WEB_PVR']
             else:

diff --git a/WebappConfig/ebuild.py b/WebappConfig/ebuild.py
index 29ec893..24ef0d6 100644
--- a/WebappConfig/ebuild.py
+++ b/WebappConfig/ebuild.py
@@ -326,7 +326,7 @@ class Ebuild:
                       'PVR': None}
 
         result = {}
-        for i in export_map.keys():
+        for i in list(export_map.keys()):
 
             value = export_map[i]
 

diff --git a/WebappConfig/filetype.py b/WebappConfig/filetype.py
index 3c5acbb..63d7e5f 100644
--- a/WebappConfig/filetype.py
+++ b/WebappConfig/filetype.py
@@ -137,7 +137,7 @@ class FileType:
 
         for i in server_owned:
 
-            if self.__fix(i) in self.__cache.keys():
+            if self.__fix(i) in list(self.__cache.keys()):
 
                 OUT.debug('Adding config-server-owned file', 8)
 
@@ -177,7 +177,7 @@ class FileType:
         filename = self.__fix(filename)
 
         # look for config-protected files in the cache
-        if filename in self.__cache.keys():
+        if filename in list(self.__cache.keys()):
             return self.__cache[filename]
 
         # unspecified file (and thus virtual)
@@ -208,7 +208,7 @@ class FileType:
         directory = self.__fix(directory)
 
         # check the cache
-        if directory in self.__cache.keys():
+        if directory in list(self.__cache.keys()):
             return self.__cache[directory]
 
         # unspecified directories are default-owned

diff --git a/WebappConfig/sandbox.py b/WebappConfig/sandbox.py
index 3a86673..0cac7e1 100644
--- a/WebappConfig/sandbox.py
+++ b/WebappConfig/sandbox.py
@@ -35,7 +35,7 @@ if os.path.isdir("/proc/%i/fd" % os.getpid()):
         return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) if fd.isdigit())
 else:
     def get_open_fds():
-        return range(max_fd_limit)
+        return list(range(max_fd_limit))
 
 
 class Sandbox:
@@ -88,7 +88,7 @@ class Sandbox:
 
         # merge full_env (w-c variables) with env (write path)
         self.env.update(full_env)
-        for a in self.env.keys():
+        for a in list(self.env.keys()):
             if not self.env[a]:
                 self.env[a] = ''
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-01-24 21:45 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-01-24 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     ff4cdefb600c0ceb834019bbcd0e1147ea744d6b
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 21:38:02 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 21:38:02 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=ff4cdefb

WebappConfig/db.py: Properly closes install file after writing.

When webapp-config cleans out a webapp installation it needs to
remove the database entry of the file from it's designated installs
file. If more than one database entry is in the installs file it
should still list the database entry for the webapp that isn't being
removed. The logic is all there in db.py but after the file has
rewritten the entries it doesn't close the file properly and causes
a failure in the check right after the write(), which then unlinks
the installs file and removes the entries from webapp-config's
database.

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

---
 WebappConfig/db.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 228b2c8..2d70cb9 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -340,6 +340,7 @@ class WebappDB(AppHierarchy):
         if not self.__p:
             installs = open(dbpath, 'w')
             installs.write('\n'.join(newentries) + '\n')
+            installs.close()
             if not self.has_installs():
                 os.unlink(dbpath)
         else:


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-01-22 15:32 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-01-22 15:32 UTC (permalink / raw
  To: gentoo-commits

commit:     a37dd17b3b4760d2ef6eff35d8a47b348d5cfc7e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 15:28:28 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 15:28:28 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=a37dd17b

WebappConfig/config.py: Fixes spacing issue in --help output.

---
 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index c0ea645..1f3fab1 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -389,7 +389,7 @@ class Config:
 
         group = OptionGroup(self.parser, 'APPLICATION VERSION',
                             'The name and version number of the web appli'
-                            'cation to install e.g. phpmyadmin 2.5.4. The'
+                            'cation to install e.g. phpmyadmin 2.5.4. The '
                             'APPLICATION must have already been installed'
                             ' into the '
                             + self.config.get('USER', 'my_approot') +


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-01-08  4:03 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-01-08  4:03 UTC (permalink / raw
  To: gentoo-commits

commit:     5fcb5709229d41b0f0dd572f61b64f16b7c9f962
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  8 03:57:01 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed Jan  8 03:57:01 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=5fcb5709

WebappConfig/db.py: Slightly alters prune_database() algorithm.

When the prune_database() function checks to see if a webapp is
installed in the directory the database says it's supposed to be
installed in it originally checked to see if a .webapp file existed
in the directory. But due to the fact that a .webapp file could exist
in a directory and not be the webapp that is listed as installed in
that directory it was decided that checking the existance of the
.webapp-<webapp>-<version> file would be better as it confirms that
a webapp exists in that directory and it is the webapp that it is
supposed to be.

---
 WebappConfig/db.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index d22020a..228b2c8 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -444,9 +444,7 @@ class WebappDB(AppHierarchy):
             for i in loc[j]:
                 appdir = i[3].strip()
                 # We check to see if the webapp is installed.
-                # TODO: Fix algorithm to see if this is an outdated
-                # entry.
-                if not os.path.exists(appdir+'/.webapp'):
+                if not os.path.exists(appdir+'/.webapp-'+j):
                     if self.__v:
                        OUT.warn('No .webapp file found in dir: ')
                        OUT.warn(appdir)


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-01-04  1:40 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-01-04  1:40 UTC (permalink / raw
  To: gentoo-commits

commit:     9e015e0404f9e71aef6779f707ac1e725d7e8474
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 01:23:29 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 01:39:53 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=9e015e04

WebappConfig/content.py: Nulls doctest code in add() function.

Due to the variable nature of the output in the add() function in
content.py it was dicussed that the best decision would be to disable
the failing doctest code and prevent it from causing failures.

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

---
 WebappConfig/content.py | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/WebappConfig/content.py b/WebappConfig/content.py
index 8fe5be9..c635f5a 100644
--- a/WebappConfig/content.py
+++ b/WebappConfig/content.py
@@ -379,71 +379,71 @@ class Contents:
                         (and this is important for md5)
           relative    - 1 for storing a relative filename, 0 otherwise
 
-        >>> OUT.color_off()
-        >>> import os.path
-        >>> here = os.path.dirname(os.path.realpath(__file__))
+        OUT.color_off()
+        import os.path
+        here = os.path.dirname(os.path.realpath(__file__))
 
         One for pretending:
 
-        >>> a = Contents(here + '/tests/testfiles/contents/app/',
+        a = Contents(here + '/tests/testfiles/contents/app/',
         ...              package = 'test', version = '1.0',
         ...              pretend = True)
 
         And this one is for real:
 
-        >>> b = Contents(here + '/tests/testfiles/contents/app/',
+        b = Contents(here + '/tests/testfiles/contents/app/',
         ...              package = 'test', version = '1.0')
 
         Pretend to add a file:
 
-        >>> a.add('file', 'config-owned',
+        a.add('file', 'config-owned',
         ...       destination = here + '/tests/testfiles/contents/app/',
         ...       path = '/test1', relative = True)
         *     pretending to add: file 1 config-owned "test1"
 
         Lets not pretend this time:
 
-        >>> b.add('file', 'config-owned',
+        b.add('file', 'config-owned',
         ...       destination = here + '/tests/testfiles/contents/app/',
         ...       path = '/test1', relative = True)
-        >>> b.entry(here + '/tests/testfiles/contents/app/test1') #doctest: +ELLIPSIS
+        b.entry(here + '/tests/testfiles/contents/app/test1') #doctest: +ELLIPSIS
         'file 1 config-owned "test1" ... d8e8fca2dc0f896fd7cb4cb0031ba249 '
 
         Lets produce an error with a file that does not exist:
 
-        >>> b.add('file', 'config-owned',
+        b.add('file', 'config-owned',
         ...       destination = here + '/tests/testfiles/contents/app/',
         ...       path = '/nothere', relative = True) #doctest: +ELLIPSIS
         * Cannot access file .../tests/testfiles/contents/app/nothere to add it as installation content. This should not happen!
 
         Other file types:
 
-        >>> b.add('hardlink', 'config-owned',
+        b.add('hardlink', 'config-owned',
         ...       destination = here + '/tests/testfiles/contents/app/',
         ...       path = '/test2', relative = True)
-        >>> b.entry(here + '/tests/testfiles/contents/app/test2') #doctest: +ELLIPSIS
+        b.entry(here + '/tests/testfiles/contents/app/test2') #doctest: +ELLIPSIS
         'file 1 config-owned "test2" ... d8e8fca2dc0f896fd7cb4cb0031ba249 '
-        >>> b.add('dir', 'default-owned',
+        b.add('dir', 'default-owned',
         ...       destination = here + '/tests/testfiles/contents/app/',
         ...       path = '/dir1', relative = True)
-        >>> b.entry(here + '/tests/testfiles/contents/app/dir1') #doctest: +ELLIPSIS
+        b.entry(here + '/tests/testfiles/contents/app/dir1') #doctest: +ELLIPSIS
         'dir 1 default-owned "dir1" ... 0 '
-        >>> b.add('dir', 'default-owned', destination = here + '/tests/testfiles/contents/app',
+        b.add('dir', 'default-owned', destination = here + '/tests/testfiles/contents/app',
         ...       path = '/dir1',
         ...       relative = False)
-        >>> b.entry(here + '/tests/testfiles/contents/app/dir1') #doctest: +ELLIPSIS
+        b.entry(here + '/tests/testfiles/contents/app/dir1') #doctest: +ELLIPSIS
         'dir 0 default-owned ".../tests/testfiles/contents/app/dir1" ... 0 '
 
         Q: Is the full link to the target what we want?
         A: Yes, since the link will still be ok even if we move the directory.
 
-        >>> b.add('sym', 'virtual',
+        b.add('sym', 'virtual',
         ...       destination = here + '/tests/testfiles/contents/app/',
         ...       path = '/test3', relative = True)
-        >>> b.entry(here + '/tests/testfiles/contents/app/test3') #doctest: +ELLIPSIS
+        b.entry(here + '/tests/testfiles/contents/app/test3') #doctest: +ELLIPSIS
         'sym 1 virtual "test3" ... 0 .../tests/testfiles/contents/app/test1'
 
-        >>> b.db_print() #doctest: +ELLIPSIS
+        b.db_print() #doctest: +ELLIPSIS
         file 1 config-owned "test1" ... d8e8fca2dc0f896fd7cb4cb0031ba249 
         file 1 config-owned "test2" ... d8e8fca2dc0f896fd7cb4cb0031ba249 
         sym 1 virtual "test3" ... 0 .../tests/testfiles/contents/app/test1


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2014-01-04  1:13 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2014-01-04  1:13 UTC (permalink / raw
  To: gentoo-commits

commit:     ec5d704204889d13ffaaa7974e32c959214dad8f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 03:43:10 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 01:12:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=ec5d7042

WebappConfig/ebuild.py: Nulls doctest code in run_var()

Due to the variable nature of the output of the run_var() function it
is unrealistic to create doctest code that will not fail a test. This
is mainly due to the fact that there are particular variables that may
never be the same on any two user's systems. It has been decided that
the best solution would be to simply "comment out" the doctest code
to prevent it from running and causing failures.

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

---
 WebappConfig/ebuild.py | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/WebappConfig/ebuild.py b/WebappConfig/ebuild.py
index 03c0c57..29ec893 100644
--- a/WebappConfig/ebuild.py
+++ b/WebappConfig/ebuild.py
@@ -201,35 +201,35 @@ class Ebuild:
         The procedure from above is repeated to set up the default
         environment:
 
-        >>> import WebappConfig.config
-        >>> config = WebappConfig.config.Config()
-        >>> config.config.set('USER', 'my_htdocsbase',  'htdocs')
-        >>> config.config.set('USER', 'pn',   'horde')
-        >>> config.config.set('USER', 'pvr',  '3.0.5')
-        >>> import os.path
-        >>> here = os.path.dirname(os.path.realpath(__file__))
-        >>> config.config.set('USER', 'my_approot', here +
-        ...                   '/tests/testfiles/share-webapps')
-        >>> my_approot = config.config.get('USER', 'my_approot')
-        >>> my_appdir = my_approot + "/horde/3.0.5"
-        >>> config.config.set('USER', 'my_appdir', my_appdir)
-        >>> config.config.set('USER', 'my_hookscriptsdir', my_appdir + '/hooks')
-        >>> config.config.set('USER', 'my_cgibinbase', 'cgi-bin')
-        >>> config.config.set('USER', 'my_errorsbase', 'error')
-        >>> config.config.set('USER', 'my_iconsbase', 'icons')
-        >>> config.config.set('USER', 'my_serverconfigdir', '/'.join([my_appdir,'conf']))
-        >>> config.config.set('USER', 'my_hostrootdir', '/'.join([my_appdir,'hostroot']))
-        >>> config.config.set('USER', 'my_htdocsdir', '/'.join([my_appdir,'htdocs']))
-        >>> config.config.set('USER', 'my_sqlscriptsdir', '/'.join([my_appdir,'sqlscripts']))
+        ">>> import WebappConfig.config"
+        ">>> config = WebappConfig.config.Config()"
+        ">>> config.config.set('USER', 'my_htdocsbase',  'htdocs')"
+        ">>> config.config.set('USER', 'pn',   'horde')"
+        ">>> config.config.set('USER', 'pvr',  '3.0.5')"
+        ">>> import os.path"
+        ">>> here = os.path.dirname(os.path.realpath(__file__))"
+        ">>> config.config.set('USER', 'my_approot', here +"
+        "...                   '/tests/testfiles/share-webapps')"
+        ">>> my_approot = config.config.get('USER', 'my_approot')"
+        ">>> my_appdir = my_approot + "/horde/3.0.5""
+        ">>> config.config.set('USER', 'my_appdir', my_appdir)"
+        ">>> config.config.set('USER', 'my_hookscriptsdir', my_appdir + '/hooks')"
+        ">>> config.config.set('USER', 'my_cgibinbase', 'cgi-bin')"
+        ">>> config.config.set('USER', 'my_errorsbase', 'error')"
+        ">>> config.config.set('USER', 'my_iconsbase', 'icons')"
+        ">>> config.config.set('USER', 'my_serverconfigdir', '/'.join([my_appdir,'conf']))"
+        ">>> config.config.set('USER', 'my_hostrootdir', '/'.join([my_appdir,'hostroot']))"
+        ">>> config.config.set('USER', 'my_htdocsdir', '/'.join([my_appdir,'htdocs']))"
+        ">>> config.config.set('USER', 'my_sqlscriptsdir', '/'.join([my_appdir,'sqlscripts']))"
 
         Time to create the ebuild handler:
 
-        >>> a = Ebuild(config)
+        ">>> a = Ebuild(config)"
 
         The dummy post-install file should display all the variables
         that are exported here:
 
-        >>> a.show_postinst() #doctest: +ELLIPSIS
+        ">>> a.show_postinst() #doctest: +ELLIPSIS
         <BLANKLINE>
         =================================================================
         POST-INSTALL INSTRUCTIONS
@@ -270,7 +270,7 @@ class Ebuild:
         PVR: 3.0.5
         <BLANKLINE>
         =================================================================
-        <BLANKLINE>        
+        <BLANKLINE>"
         '''
 
         v_root = self.get_config('vhost_root')


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-12-19  6:34 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-12-19  6:34 UTC (permalink / raw
  To: gentoo-commits

commit:     481ba08d57a1314f816ab364e34b08511a1d5a05
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 19 06:30:12 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Dec 19 06:30:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=481ba08d

WebappConfig/config.py: Uses maybe_get() function instead of get().

This changes the use of the get() function in the split_hostname()
function in favor of the maybe_get() function. This change still
allows vhost_subdomain_# variables to be set in /etc/vhosts/webapp-config
without the risk of it being overwritten except due to the use of the
maybe_get() function it will no longer give warnings to the user if
a vhost_subdomain_# variable is not found. This is ideal because
it removes the need of masking the warning in the get() function.

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

---
 WebappConfig/config.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index e251ca6..c0ea645 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -75,8 +75,6 @@ class BashConfigParser(configparser_ConfigParser):
                 'ures.'
             if self.error_action == 0:
                 OUT.die(error)
-            elif self.error_action == 1 and re.search('^vhost_subdomain_\d+', option):
-                pass
             elif self.error_action == 1:
                 OUT.warn(error)
             return ''
@@ -996,7 +994,7 @@ class Config:
 
         j = len(subdomains)
         for i in subdomains:
-            if not self.config.get('USER', 'vhost_subdomain_' + str(j)):
+            if not self.maybe_get('USER', 'vhost_subdomain_' + str(j)):
                 self.config.set('USER', 'vhost_subdomain_' + str(j), i)
 
             OUT.debug('Storing subdomain name', 8)


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-12-10  1:34 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-12-10  1:34 UTC (permalink / raw
  To: gentoo-commits

commit:     a9cfa36cae677826fe1fc1bca82a3a603d85ad91
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 10 01:27:15 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Dec 10 01:27:15 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=a9cfa36c

WebappConfig/config.py: Prevents overwriting config variables.

When setting vhost_subdomain_# variables in /etc/vhosts/webapp-config
they have a possibility of being overwritten by the split_hostname()
function. To see this happen you should set vhost_subdomain_1 to a
value and try and use it as a variable in your config file. This will
then get overwritten by your vhost_hostname. This commit will prevent
that from occuring while also having the get() method ignore the
inexistence of a vhost_subdomain_# variable in your config file,
due to the fact that if the variable does exist it will be used, and
if the variable does not exist then it will get overwritten by a
piece of vhost_hostname that is separated by the "." delimiter.

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

---
 WebappConfig/config.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 9ade0b6..e251ca6 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -75,6 +75,8 @@ class BashConfigParser(configparser_ConfigParser):
                 'ures.'
             if self.error_action == 0:
                 OUT.die(error)
+            elif self.error_action == 1 and re.search('^vhost_subdomain_\d+', option):
+                pass
             elif self.error_action == 1:
                 OUT.warn(error)
             return ''
@@ -994,7 +996,8 @@ class Config:
 
         j = len(subdomains)
         for i in subdomains:
-            self.config.set('USER', 'vhost_subdomain_' + str(j), i)
+            if not self.config.get('USER', 'vhost_subdomain_' + str(j)):
+                self.config.set('USER', 'vhost_subdomain_' + str(j), i)
 
             OUT.debug('Storing subdomain name', 8)
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-12-09  8:31 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-12-09  8:31 UTC (permalink / raw
  To: gentoo-commits

commit:     781d12c41afd1e4afe171e229af2afee04174499
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  9 08:31:16 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Dec  9 08:31:16 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=781d12c4

WebappConfig/db.py: Removes printing of 'action' when calling prune_database().

---
 WebappConfig/db.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index d0913a9..d22020a 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -432,7 +432,6 @@ class WebappDB(AppHierarchy):
 
         loc = self.read_db()
         
-        print(action)
         if not loc and self.__v:
             OUT.die('No virtual installs found!')
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-12-01  8:50 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-12-01  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     eca8521272afe917ec72b6d0469ac58419ca1e31
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  1 08:49:56 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun Dec  1 08:49:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=eca85212

WebappConfig/config.py: Cleans whitespace.

---
 WebappConfig/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 4df2f27..9ade0b6 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -565,7 +565,7 @@ class Config:
 
         group.add_option('-V',
                          '--verbose',
-			 action='store_true',
+                         action='store_true',
                          help = 'Output even more information than normal'
                          )
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-12-01  8:44 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-12-01  8:44 UTC (permalink / raw
  To: gentoo-commits

commit:     a07f5921e24e4777b03abe9dbec97ddce2015cb0
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  1 08:35:04 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun Dec  1 08:35:04 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=a07f5921

WebappConfig/{db,config}.py: Adds support for prune-database() function.

This renames the prune-db() function to prune-database() as well as
adding a command line option to call the function and implements it
in config.py.

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

---
 WebappConfig/config.py | 24 ++++++++++++++++++++++--
 WebappConfig/db.py     | 35 +++++++++++++++++++++--------------
 2 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 1c09488..4df2f27 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -565,7 +565,7 @@ class Config:
 
         group.add_option('-V',
                          '--verbose',
-                         action='store_true',
+			 action='store_true',
                          help = 'Output even more information than normal'
                          )
 
@@ -593,6 +593,14 @@ class Config:
                          'or version number as arguments to restrict the '
                          'listing.')
 
+        group.add_option('--prune-database',
+                         '--pd',
+                         type = 'choice',
+                         choices = ['pretend',
+                                    'clean'],
+                         help = 'This will list all outdated entries in '
+                         'the webapp-config "database".')
+
         group.add_option('--show-installed',
                          '--si',
                          action='store_true',
@@ -932,7 +940,7 @@ class Config:
         # set the action to be performed
         work = ['install', 'clean', 'upgrade', 'list_installs',
                 'list_servers', 'list_unused_installs',
-                'show_installed', 'show_postinst',
+                'prune_database', 'show_installed', 'show_postinst',
                 'show_postupgrade', 'check_config', 'query']
 
         for i in work:
@@ -940,6 +948,9 @@ class Config:
                 self.work = i
                 break
 
+        if options.__dict__.get('prune_database'):
+            self.prune_action = options.__dict__.get('prune_database')
+
         OUT.debug('Checking command line arguments', 1)
 
         if len(args) > 0:
@@ -1134,6 +1145,15 @@ class Config:
             self.create_webapp_db(  self.maybe_get('cat'),
                                     self.maybe_get('pn'),
                                     self.maybe_get('pvr')).listinstalls()
+        if self.work == 'prune_database':
+            # Get the handler for the virtual install db. If the action is equal
+            # to clean, then it'll simply prune the "db" of outdated entries.
+            # If it's not set to clean, then it'll list the outdated entries
+            # in the db to be cleaned out.
+            self.__r = wrapper.get_root(self)
+            self.create_webapp_db(  self.maybe_get('cat'),
+                                    self.maybe_get('pn'),
+                                    self.maybe_get('pvr')).prune_database(self.prune_action)
 
         if self.work == 'show_installed':
 

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 37bfdc9..d0913a9 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -424,42 +424,49 @@ class WebappDB(AppHierarchy):
 
         return result
 
-    def prune_db(self):
+    def prune_database(self, action):
         '''
         Prunes the installs files to ensure no webapp
         is incorrectly listed as installed.
         '''
 
         loc = self.read_db()
-
+        
+        print(action)
         if not loc and self.__v:
             OUT.die('No virtual installs found!')
 
         files = self.list_locations()
         keys = sorted(loc)
 
+        if action != 'clean':
+            OUT.warn('This is a list of all outdated entries that would be removed: ')
         for j in keys:
             for i in loc[j]:
                 appdir = i[3].strip()
                 # We check to see if the webapp is installed.
+                # TODO: Fix algorithm to see if this is an outdated
+                # entry.
                 if not os.path.exists(appdir+'/.webapp'):
                     if self.__v:
                        OUT.warn('No .webapp file found in dir: ')
                        OUT.warn(appdir)
                        OUT.warn('Assuming webapp is no longer installed.')
                        OUT.warn('Pruning entry from database.')
-
-                    for installs in files.keys():
-                        contents = open(installs).readlines()
-                        new_entries = ''
-                        for entry in contents:
-                            # Grab all the other entries but the one that
-                            # isn't installed.
-                            if not re.search('.* ' + appdir +'\\n', entry):
-                                new_entries += entry
-                        f = open(installs, 'w')
-                        f.write(new_entries)
-                        f.close()
+                    if action == 'clean':
+                        for installs in files.keys():
+                            contents = open(installs).readlines()
+                            new_entries = ''
+                            for entry in contents:
+                                # Grab all the other entries but the one that
+                                # isn't installed.
+                                if not re.search('.* ' + appdir +'\\n', entry):
+                                    new_entries += entry
+                            f = open(installs, 'w')
+                            f.write(new_entries)
+                            f.close()
+                    else:
+                        OUT.warn(appdir)
 
     def has_installs(self):
         ''' Return True in case there are any virtual install locations 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-11-05 22:17 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-11-05 22:17 UTC (permalink / raw
  To: gentoo-commits

commit:     fa4fbd3505328b6073f537fc198ee4f7fd3dd031
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Nov  5 22:11:07 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Nov  5 22:11:07 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=fa4fbd35

WebappConfig/db.py: Adds prune_db() function.

This function will check for "stray" webapp installation entries in
the installs files located in /var/db/webapps/<package name>/<version>.
This function is not implemented yet.

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

---
 WebappConfig/db.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 11e5dae..37bfdc9 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -424,6 +424,43 @@ class WebappDB(AppHierarchy):
 
         return result
 
+    def prune_db(self):
+        '''
+        Prunes the installs files to ensure no webapp
+        is incorrectly listed as installed.
+        '''
+
+        loc = self.read_db()
+
+        if not loc and self.__v:
+            OUT.die('No virtual installs found!')
+
+        files = self.list_locations()
+        keys = sorted(loc)
+
+        for j in keys:
+            for i in loc[j]:
+                appdir = i[3].strip()
+                # We check to see if the webapp is installed.
+                if not os.path.exists(appdir+'/.webapp'):
+                    if self.__v:
+                       OUT.warn('No .webapp file found in dir: ')
+                       OUT.warn(appdir)
+                       OUT.warn('Assuming webapp is no longer installed.')
+                       OUT.warn('Pruning entry from database.')
+
+                    for installs in files.keys():
+                        contents = open(installs).readlines()
+                        new_entries = ''
+                        for entry in contents:
+                            # Grab all the other entries but the one that
+                            # isn't installed.
+                            if not re.search('.* ' + appdir +'\\n', entry):
+                                new_entries += entry
+                        f = open(installs, 'w')
+                        f.write(new_entries)
+                        f.close()
+
     def has_installs(self):
         ''' Return True in case there are any virtual install locations 
         listed in the db file '''


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-11-05 22:17 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-11-05 22:17 UTC (permalink / raw
  To: gentoo-commits

commit:     cfb46b5ef039d150a6dbd4f5075d4772e6462c5f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 29 19:08:48 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Nov  5 06:06:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=cfb46b5e

WebappConfig/config.py: Modifies default interpolation style.

Due to python3.2 using one interpolation style when running ConfigParser
it was necessary to change the interpolation style to the Extended
Interpolation style which allows ConfigParser to interpolate such
variables that follow the style of ${} in config.py and the config
file in /etc/vhosts/webapp-config. For total backwards compatibility
we also needed to change the interpolation style being used in config.py
because it was using a Basic Interpolation style of %(variable)s.
This change has been tested with both python3.2 and python2.7.

---
 WebappConfig/config.py | 54 +++++++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index c4b424b..1c09488 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -26,6 +26,7 @@ try:
     import configparser
     if sys.version_info >= (3, 2):
         from configparser import ConfigParser as configparser_ConfigParser
+        from configparser import ExtendedInterpolation
     else:
         from configparser import SafeConfigParser as configparser_ConfigParser
 except ImportError:
@@ -53,7 +54,10 @@ class BashConfigParser(configparser_ConfigParser):
 
     def __init__(self, defaults=None):
         self.error_action = 1
-        configparser_ConfigParser.__init__(self, defaults)
+        if sys.hexversion >= 0x3000000:
+            configparser_ConfigParser.__init__(self, defaults, interpolation=ExtendedInterpolation())
+        else:
+            configparser_ConfigParser.__init__(self, defaults)
 
     def on_error(self, action = 0):
         self.error_action = action
@@ -244,7 +248,7 @@ class Config:
             'vhost_config_uid'             : str(os.getuid()),
             'vhost_config_virtual_files'   : 'virtual',
             'vhost_config_default_dirs'    : 'default-owned',
-            'vhost_config_dir'             : '%(vhost_root)s/conf',
+            'vhost_config_dir'             : '${vhost_root}/conf',
             'vhost_htdocs_insecure'        : 'htdocs',
             'vhost_htdocs_secure'          : 'htdocs-secure',
             'vhost_perms_serverowned_dir'  : '0775',
@@ -266,16 +270,16 @@ class Config:
             'vhost_server_gid'  : 'root',
             'my_persistroot'    : '/var/db/webapps',
             'wa_installsbase'   : 'installs',
-            'vhost_root'        : '/var/www/%(vhost_hostname)s',
-            'g_htdocsdir'       : '%(vhost_root)s/%(my_htdocsbase)s',
-            'my_appdir'         : '%(my_approot)s/%(my_appsuffix)s',
-            'my_htdocsdir'      : '%(my_appdir)s/htdocs',
-            'my_persistdir'     : '%(my_persistroot)s/%(my_appsuffix)s',
-            'my_hostrootdir'    : '%(my_appdir)s/%(my_hostrootbase)s',
-            'my_cgibindir'      : '%(my_hostrootdir)s/%(my_cgibinbase)s',
-            'my_iconsdir'       : '%(my_hostrootdir)s/%(my_iconsbase)s',
-            'my_errorsdir'      : '%(my_hostrootdir)s/%(my_errorsbase)s',
-            'g_cgibindir'      : '%(vhost_root)s/%(my_cgibinbase)s',
+            'vhost_root'        : '/var/www/${vhost_hostname}',
+            'g_htdocsdir'       : '${vhost_root}/${my_htdocsbase}',
+            'my_appdir'         : '${my_approot}/${my_appsuffix}',
+            'my_htdocsdir'      : '${my_appdir}/htdocs',
+            'my_persistdir'     : '${my_persistroot}/${my_appsuffix}',
+            'my_hostrootdir'    : '${my_appdir}/${my_hostrootbase}',
+            'my_cgibindir'      : '${my_hostrootdir}/${my_cgibinbase}',
+            'my_iconsdir'       : '${my_hostrootdir}/${my_iconsbase}',
+            'my_errorsdir'      : '${my_hostrootdir}/${my_errorsbase}',
+            'g_cgibindir'      : '${vhost_root}/${my_cgibinbase}',
             'my_approot'        : '/usr/share/webapps',
             'package_manager'   : 'portage',
             'allow_absolute'    : 'no',
@@ -283,15 +287,15 @@ class Config:
             'my_cgibinbase'     : 'cgi-bin',
             'my_iconsbase'      : 'icons',
             'my_errorsbase'     : 'error',
-            'my_sqlscriptsdir'  : '%(my_appdir)s/sqlscripts',
-            'my_hookscriptsdir' : '%(my_appdir)s/hooks',
-            'my_serverconfigdir': '%(my_appdir)s/conf',
-            'wa_configlist'     : '%(my_appdir)s/config-files',
-            'wa_solist'         : '%(my_appdir)s/server-owned-files',
-            'wa_virtuallist'    : '%(my_appdir)s/virtuals',
-            'wa_installs'       : '%(my_persistdir)s/%(wa_installsbase)s',
+            'my_sqlscriptsdir'  : '${my_appdir}/sqlscripts',
+            'my_hookscriptsdir' : '${my_appdir}/hooks',
+            'my_serverconfigdir': '${my_appdir}/conf',
+            'wa_configlist'     : '${my_appdir}/config-files',
+            'wa_solist'         : '${my_appdir}/server-owned-files',
+            'wa_virtuallist'    : '${my_appdir}/virtuals',
+            'wa_installs'       : '${my_persistdir}/${wa_installsbase}',
             'wa_postinstallinfo':
-            '%(my_appdir)s/post-install-instructions.txt',
+            '${my_appdir}/post-install-instructions.txt',
             }
 
         # Setup basic defaults
@@ -338,9 +342,9 @@ class Config:
             self.config.set('USER', 'persist_suffix', '/'.join([cat,pn,pvr]))
 
             if os.path.isdir(new_layout):
-                self.config.set('USER', 'my_appsuffix', '%(cat)s/%(pn)s/%(pvr)s')
+                self.config.set('USER', 'my_appsuffix', '${cat}/${pn}/${pvr}')
             elif os.path.isdir(old_layout):
-                self.config.set('USER', 'my_appsuffix', '%(pn)s/%(pvr)s')
+                self.config.set('USER', 'my_appsuffix', '${pn}/${pvr}')
                 self.config.set('USER', 'cat', '')
             else:
                 OUT.die('Unable to determine location of master copy')
@@ -349,7 +353,7 @@ class Config:
             OUT.debug('Checking for old layout', 7)
 
             if os.path.isdir(old_layout):
-                self.config.set('USER', 'my_appsuffix', '%(pn)s/%(pvr)s')
+                self.config.set('USER', 'my_appsuffix', '${pn}/${pvr}')
                 self.config.set('USER', 'cat', '')
                 # no category info at all is available, so drop it from persist_suffix
                 self.config.set('USER', 'persist_suffix', '/'.join([pn,pvr]))
@@ -920,10 +924,10 @@ class Config:
             if (self.config.has_option('USER', 'g_secure') and
                 self.config.getboolean('USER', 'g_secure')):
                 self.config.set('USER', 'my_htdocsbase',
-                                '%(vhost_htdocs_secure)s')
+                                '${vhost_htdocs_secure}')
             else:
                 self.config.set('USER', 'my_htdocsbase',
-                                '%(vhost_htdocs_insecure)s')
+                                '${vhost_htdocs_insecure}')
 
         # set the action to be performed
         work = ['install', 'clean', 'upgrade', 'list_installs',


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-29  2:18 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-29  2:18 UTC (permalink / raw
  To: gentoo-commits

commit:     c2efd7defba1e108d743647dab43d3d61fde96b2
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 29 02:18:37 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Oct 29 02:18:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=c2efd7de

WebappConfig/compat.py: Removes extra newline.

---
 WebappConfig/compat.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/WebappConfig/compat.py b/WebappConfig/compat.py
index f7ae89f..3e567dc 100644
--- a/WebappConfig/compat.py
+++ b/WebappConfig/compat.py
@@ -20,4 +20,3 @@ import  hashlib
 def create_md5(filename):
     with open(filename, 'rb') as f:
         return str(hashlib.md5(f.read()).hexdigest())
-


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-27 19:27 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-27 19:27 UTC (permalink / raw
  To: gentoo-commits

commit:     83e6a2ee869a788b5f44fd9bd31401cb0d3bb577
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 27 19:26:52 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 27 19:26:52 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=83e6a2ee

WebappConfig/content.py: Returns md5 hash and fixes indentation.

---
 WebappConfig/content.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/content.py b/WebappConfig/content.py
index d671ad1..8fe5be9 100644
--- a/WebappConfig/content.py
+++ b/WebappConfig/content.py
@@ -531,7 +531,7 @@ class Contents:
 
     def file_md5(self, filename):
         ''' Return the md5 hash for the file content.'''
-	create_md5(filename)
+        return create_md5(filename)
 
     def file_time(self, filename):
         ''' Return the last modification time.'''


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-27  2:26 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-27  2:26 UTC (permalink / raw
  To: gentoo-commits

commit:     2f6a29d8357a98bcadd7133671ba67c45b5cd4ea
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 27 02:17:11 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun Oct 27 02:17:11 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=2f6a29d8

WebappConfig/config.py: Corrects get() function arguments.

Adds *args, and **kwargs for the wrapper get() function in config.py
in order to add the correct arguments necessary for the get() function
in the ConfigParser class.

---
 WebappConfig/config.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 26eab59..c4b424b 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -58,9 +58,9 @@ class BashConfigParser(configparser_ConfigParser):
     def on_error(self, action = 0):
         self.error_action = action
 
-    def get(self, section, option):
+    def get(self, section, option, *args, **kwargs):
         try:
-            return configparser_ConfigParser.get(self, section, option)
+            return configparser_ConfigParser.get(self, section, option, *args, **kwargs)
         except Exception as e:
             error = '\nThere is a problem with your configuration file or' \
                 ' an environment variable.\n' \


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-19  3:34 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-19  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     04e9a552778538887a686749c2cf423493212f8c
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 19 03:24:15 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sat Oct 19 03:24:15 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=04e9a552

WebappConfig/compat.py: Revamps create_md5() function.

This second revamp changes the way in which python is opening
the file to create an md5 hash of. Upon calling the open()
function it opens the file to read it, or as a binary. This
allows for consistent behavior when trying to open either a
binary file, or a text file to hash. This method is also much
cleaner and sufficient for forward and backwards compatibility.

---
 WebappConfig/compat.py | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/WebappConfig/compat.py b/WebappConfig/compat.py
index 8d39faf..f7ae89f 100644
--- a/WebappConfig/compat.py
+++ b/WebappConfig/compat.py
@@ -15,19 +15,9 @@
 #
 # ========================================================================
 
-import  hashlib, os, os.path, sys
+import  hashlib
 
 def create_md5(filename):
-    if hex(sys.hexversion) >= '0x3020000':
-        file_type = os.popen('file -bi ' + filename, 'r')
-        file_type = file_type.read()
-        if re.search("^.*charset=binary$", file_type):
-            filename = filename.encode('utf8')
-            return str(hashlib.md5(filename).hexdigest())
-        else:
-            filename = open(filename).read()
-            filename = filename.encode('utf8')
-            return str(hashlib.md5(filename).hexdigest())
-    else:
-        return str(hashlib.md5(open(filename).read()).hexdigest())
+    with open(filename, 'rb') as f:
+        return str(hashlib.md5(f.read()).hexdigest())
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-18  3:39 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-18  3:39 UTC (permalink / raw
  To: gentoo-commits

commit:     f5855edeefb5cdb467e52ba14f1b40947a8b0bb5
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 18 03:39:05 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Oct 18 03:39:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=f5855ede

WebappConfig/db.py converts keys dictionary to sorted list.

---
 WebappConfig/db.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 3ac5f2c..11e5dae 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -441,8 +441,7 @@ class WebappDB(AppHierarchy):
         if not loc and self.__v:
             OUT.die('No virtual installs found!')
 
-        keys = list(loc.keys())
-        keys.sort()
+        keys = sorted(loc)
 
         for j in keys:
             # The verbose output is meant to be readable for the user
@@ -673,8 +672,7 @@ class WebappSource(AppHierarchy):
         if not packages:
             OUT.die('No packages found!')
 
-        keys = packages.keys()
-        keys.sort()
+        keys = sorted(packages)
 
         OUT.debug('Check for unused web applications', 7)
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-10  3:46 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-10  3:46 UTC (permalink / raw
  To: gentoo-commits

commit:     5f474e6e7c5b318d14a9081193d6459e5e366449
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 10 03:45:12 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 10 03:45:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=5f474e6e

WebappConfig/content.py: Encodes md5 content in utf-8 when writing.

---
 WebappConfig/content.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/content.py b/WebappConfig/content.py
index 7eff223..d671ad1 100644
--- a/WebappConfig/content.py
+++ b/WebappConfig/content.py
@@ -298,7 +298,7 @@ class Contents:
                 fd = os.open(self.appdb(), os.O_WRONLY | os.O_CREAT,
                              self.__perm(0o600))
 
-                os.write(fd, '\n'.join(values))
+                os.write(fd, ('\n'.join(values)).encode('utf-8'))
 
                 os.close(fd)
             except Exception as e:


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-10  3:41 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-10  3:41 UTC (permalink / raw
  To: gentoo-commits

commit:     7b154386dd77f39cf863eea63752e402094e7486
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 10 03:38:06 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 10 03:38:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=7b154386

WebappConfig/db.py: Encodes entry output for .webapp-<app>-<version>.

This encodes the variable entry in utf-8 when writing to a
.webapp-<app>-<version> file, due to previous errors where str
did not support the buffer interface.

---
 WebappConfig/db.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 8db20fc..3ac5f2c 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -385,7 +385,7 @@ class WebappDB(AppHierarchy):
         OUT.debug('New record', 7)
 
         if not self.__p:
-            os.write(fd, entry)
+            os.write(fd, (entry).encode('utf-8'))
             os.close(fd)
         else:
             OUT.info('Pretended to append installation ' + installdir)


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-10  3:36 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-10  3:36 UTC (permalink / raw
  To: gentoo-commits

commit:     187950ab21ad5001424bb5187b69363eeda8a58b
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 10 03:35:30 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 10 03:35:30 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=187950ab

WebappConfig/dotconfig.py: Encodes .webapp info in utf-8 when writing.

---
 WebappConfig/dotconfig.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/WebappConfig/dotconfig.py b/WebappConfig/dotconfig.py
index ce2845c..cab0392 100644
--- a/WebappConfig/dotconfig.py
+++ b/WebappConfig/dotconfig.py
@@ -248,7 +248,6 @@ class DotConfig:
                 '#	automatically created by Gentoo\'s webapp-config',
                 '#	do NOT edit this file by hand',
                 '',]
-
         for i in self.__tokens:
             info.append(i + '="' + self.__data[i] + '"')
 
@@ -259,7 +258,7 @@ class DotConfig:
                              os.O_WRONLY | os.O_CREAT,
                              self.__perm(0o600))
 
-                os.write(fd, '\n'.join(info))
+                os.write(fd, ('\n'.join(info)).encode('utf-8'))
                 os.close(fd)
 
             except Exception as e:


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-10-10  2:00 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-10-10  2:00 UTC (permalink / raw
  To: gentoo-commits

commit:     781df726af2e16e10b89385a8daccd940eaf508a
Author:     Devan Franchini <twitch153 <AT> hotmail <DOT> com>
AuthorDate: Thu Oct 10 01:01:19 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 10 01:01:19 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=781df726

WebappConfig/compat.py: Revamped create_md5() function for python3.2.

When creating md5 hashes for webapp files you need to encode the files
using utf-8. In order to encode these files there needs to be a
check to distinguish binary charsets from other files. Once this is
accomplished the script can correctly encode the files.

---
 WebappConfig/compat.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/compat.py b/WebappConfig/compat.py
index 536bb2a..8d39faf 100644
--- a/WebappConfig/compat.py
+++ b/WebappConfig/compat.py
@@ -19,9 +19,15 @@ import  hashlib, os, os.path, sys
 
 def create_md5(filename):
     if hex(sys.hexversion) >= '0x3020000':
-        filename = open(filename).read()
-        encoded_file = filename.encode('utf8')
-        return str(hashlib.md5(encoded_file).hexdigest())
+        file_type = os.popen('file -bi ' + filename, 'r')
+        file_type = file_type.read()
+        if re.search("^.*charset=binary$", file_type):
+            filename = filename.encode('utf8')
+            return str(hashlib.md5(filename).hexdigest())
+        else:
+            filename = open(filename).read()
+            filename = filename.encode('utf8')
+            return str(hashlib.md5(filename).hexdigest())
     else:
         return str(hashlib.md5(open(filename).read()).hexdigest())
 


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-09-23  3:51 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-09-23  3:51 UTC (permalink / raw
  To: gentoo-commits

commit:     4ef7a3a52421d128148a1714bdc5c3e7b882f7b2
Author:     Devan Franchini <twitch153 <AT> hotmail <DOT> com>
AuthorDate: Mon Sep 23 03:40:30 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 03:40:30 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=4ef7a3a5

WebappConfig/db.py: Converts dict_keys into a list to allow sorting.

When appending the --list-installs flag to webapp-config and using
python3.2+ you will receive an error declaring: "AttributeError:
'dict_keys' object has no attribute 'sort'". By setting keys as a list
you are then able to list your webapp-config installs without getting
any errors. This has also been tested on python2.7.

---
 WebappConfig/db.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/db.py b/WebappConfig/db.py
index 78597bd..8db20fc 100644
--- a/WebappConfig/db.py
+++ b/WebappConfig/db.py
@@ -441,7 +441,7 @@ class WebappDB(AppHierarchy):
         if not loc and self.__v:
             OUT.die('No virtual installs found!')
 
-        keys = loc.keys()
+        keys = list(loc.keys())
         keys.sort()
 
         for j in keys:


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-09-23  1:06 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-09-23  1:06 UTC (permalink / raw
  To: gentoo-commits

commit:     8ab980c797303dce6c0ce009d9be28d18f8c0306
Author:     Devan Franchini <twitch153 <AT> hotmail <DOT> com>
AuthorDate: Mon Sep 23 00:40:09 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 00:40:09 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=8ab980c7

WebappConfig/compat.py: Adds compatibility check for file_md5().

When the file_md5() function is called in python3.2+ a hash file is
supposed to be created, and on a if an object is unicode, it needs to be
encoded prior to hashing. In order to do this, a file called compat.py
has a function in it called create_md5(); this function checks the
hexidecimal python version and based on the version, either encodes the
file before it hashes, or simply returns the md5 hash.

---
 WebappConfig/compat.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/WebappConfig/compat.py b/WebappConfig/compat.py
new file mode 100644
index 0000000..536bb2a
--- /dev/null
+++ b/WebappConfig/compat.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python -O
+#
+# /usr/sbin/webapp-config
+#       Python script for managing the deployment of web-based
+#       applications
+#
+#       Originally written for the Gentoo Linux distribution
+#
+# Copyright (c) 1999-2007 Authors
+#       Released under v2 of the GNU GPL
+#
+# Author(s)     Stuart Herbert
+#               Renat Lumpau   <rl03@gentoo.org>
+#               Gunnar Wrobel  <wrobel@gentoo.org>
+#
+# ========================================================================
+
+import  hashlib, os, os.path, sys
+
+def create_md5(filename):
+    if hex(sys.hexversion) >= '0x3020000':
+        filename = open(filename).read()
+        encoded_file = filename.encode('utf8')
+        return str(hashlib.md5(encoded_file).hexdigest())
+    else:
+        return str(hashlib.md5(open(filename).read()).hexdigest())
+


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/
@ 2013-09-23  0:19 Devan Franchini
  0 siblings, 0 replies; 61+ messages in thread
From: Devan Franchini @ 2013-09-23  0:19 UTC (permalink / raw
  To: gentoo-commits

commit:     51b5115702b7585c68efd70929e0762db9b8e897
Author:     Devan Franchini <twitch153 <AT> hotmail <DOT> com>
AuthorDate: Sun Sep 22 23:30:54 2013 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sun Sep 22 23:30:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=51b51157

WebappConfig/permissions.py: Corrected syntax for eval() function.

When the permissions octal was being passed to the eval() function they
were previously not being evaluated with python3.2 due to the fact that
the octal value was not being declared as an octal. To fix this, it was
simply stated that the octal value was one by appending '0o' to the
values being piped into the eval() function.

X-GENTOO-BUG: 481298
X-GENTOO-BUG-URL: https://bugs.gentoo.org/481298

---
 WebappConfig/permissions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WebappConfig/permissions.py b/WebappConfig/permissions.py
index ad65df1..2e506e1 100644
--- a/WebappConfig/permissions.py
+++ b/WebappConfig/permissions.py
@@ -161,7 +161,7 @@ class PermissionMap:
 
         if re.compile('[0-7]{4}').match(permissions):
             self.__absolute    = True
-            self.__permissions = eval(permissions)
+            self.__permissions = eval("0o"+permissions)
 
         else:
             # Split on commas first


^ permalink raw reply related	[flat|nested] 61+ messages in thread

end of thread, other threads:[~2015-06-19 19:19 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23  1:13 [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/ Devan Franchini
  -- strict thread matches above, loose matches on Subject: below --
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-06-19 19:19 Devan Franchini
2015-05-17  3:54 Devan Franchini
2015-05-17  3:44 Devan Franchini
2015-05-17  3:19 Devan Franchini
2015-05-17  2:51 Devan Franchini
2015-05-17  2:42 Devan Franchini
2015-05-17  2:28 Devan Franchini
2015-05-17  0:38 Devan Franchini
2015-05-16  2:16 Devan Franchini
2014-11-18  0:03 Devan Franchini
2014-11-17 23:58 Devan Franchini
2014-11-17 23:42 Devan Franchini
2014-11-14  1:14 Devan Franchini
2014-10-16 19:18 Devan Franchini
2014-10-15 13:27 Devan Franchini
2014-10-15 13:27 Devan Franchini
2014-10-15 13:27 Devan Franchini
2014-10-14 19:13 Devan Franchini
2014-10-14 17:14 Devan Franchini
2014-10-09 18:02 Devan Franchini
2014-10-09 17:58 Devan Franchini
2014-10-09 17:52 Devan Franchini
2014-09-23 17:09 Devan Franchini
2014-04-26 19:33 Devan Franchini
2014-01-24 21:45 Devan Franchini
2014-01-22 15:32 Devan Franchini
2014-01-08  4:03 Devan Franchini
2014-01-04  1:40 Devan Franchini
2014-01-04  1:13 Devan Franchini
2013-12-19  6:34 Devan Franchini
2013-12-10  1:34 Devan Franchini
2013-12-09  8:31 Devan Franchini
2013-12-01  8:50 Devan Franchini
2013-12-01  8:44 Devan Franchini
2013-11-05 22:17 Devan Franchini
2013-11-05 22:17 Devan Franchini
2013-10-29  2:18 Devan Franchini
2013-10-27 19:27 Devan Franchini
2013-10-27  2:26 Devan Franchini
2013-10-19  3:34 Devan Franchini
2013-10-18  3:39 Devan Franchini
2013-10-10  3:46 Devan Franchini
2013-10-10  3:41 Devan Franchini
2013-10-10  3:36 Devan Franchini
2013-10-10  2:00 Devan Franchini
2013-09-23  3:51 Devan Franchini
2013-09-23  1:06 Devan Franchini
2013-09-23  0:19 Devan Franchini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox