From cac34c879f139eb8d29a47c3de13af369e4cdb6c Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 10 Jan 2014 23:07:41 +0000 Subject: [PATCH 1/7] add requirements file with Debian Wheezy version --- wheezyreq.pip | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 wheezyreq.pip diff --git a/wheezyreq.pip b/wheezyreq.pip new file mode 100644 index 0000000..f177096 --- /dev/null +++ b/wheezyreq.pip @@ -0,0 +1,20 @@ +Babel==0.9.6 +Beaker==1.6.3 +FormEncode==1.2.4 +Mako==0.7.0 +MarkupSafe==0.15 +Paste==1.7.5.1 +PasteDeploy==1.5.0 +PasteScript==1.7.5 +Pygments==1.5 +Pylons==1.0 +Routes==1.13 +Tempita==0.5.1 +WebError==0.10.3 +WebHelpers==1.3 +WebOb==1.1.1 +WebTest==1.3.4 +argparse==1.2.1 +nose==1.1.2 +simplejson==2.5.2 +wsgiref==0.1.2 From 2bcb98fcf26c332b3aa9b50e5272813319ba3697 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 10 Jan 2014 23:10:29 +0000 Subject: [PATCH 2/7] refer to wheezyreq.pip and remove squeezereq.pip --- docs/source/devdocs.rst | 4 ++-- squeezereq.pip | 20 -------------------- 2 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 squeezereq.pip diff --git a/docs/source/devdocs.rst b/docs/source/devdocs.rst index a07365c..d0360bd 100644 --- a/docs/source/devdocs.rst +++ b/docs/source/devdocs.rst @@ -44,12 +44,12 @@ requirements using `pip `_:: virtualenv --distribute ~/.virtualenvs/dmportfolio . ~/.virtualenvs/dmportfolio/bin/activate cd ~/src/ddportfolioservice - pip install -r squeezereq.pip + pip install -r wheezyreq.pip .. note:: The Debian Member Portfolio Service instance at http://portfolio.debian.net/ - is running on a Debian Squeeze server, therefore :file:`squeezereq.pip` + is running on a Debian Wheezy server, therefore :file:`wheezyreq.pip` contains dependency versions matching that Debian release. The dependency download and installation into the virtual environment takes diff --git a/squeezereq.pip b/squeezereq.pip deleted file mode 100644 index 165e508..0000000 --- a/squeezereq.pip +++ /dev/null @@ -1,20 +0,0 @@ -Babel==0.9.4 -Beaker==1.5.4 -FormEncode==1.2.2 -Mako==0.3.4 -MarkupSafe==0.9.2 -Paste==1.7.5.1 -PasteDeploy==1.3.3 -PasteScript==1.7.3 -Pygments==1.3.1 -Pylons==0.10 -Routes==1.12.3 -Tempita==0.4 -WebError==0.10.2 -WebHelpers==1.1 -WebOb==0.9.8 -WebTest==1.2.1 -argparse==1.1 -nose==0.11.1 -simplejson==2.1.1 -wsgiref==0.1.2 From a74c778258a872a39f09568597cb4b9564c8fb8b Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 11 Jan 2014 00:02:56 +0000 Subject: [PATCH 3/7] ignore .ropeproject --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9da49a7..08da140 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ data/ *.pyc *.egg-info/ .coverage +.ropeproject/ From 275885cb4187d7df5b72182f9fba091cdd21e3b5 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 11 Jan 2014 00:03:09 +0000 Subject: [PATCH 4/7] improve keyring analyzer - define separate gnupg homedir as gnupghome - update file comments in ddportfolioservice/model/ddportfolio.ini and ddportfolioservice/model/keyringanalyzer.py to reflect current copyright years and project name - keyringanalyzer.py: - refactor to reduce function complexity - fix PEP8 violations - use gnupghome setting - switch to SafeConfigParser --- ddportfolioservice/model/ddportfolio.ini | 23 ++-- ddportfolioservice/model/keyringanalyzer.py | 117 ++++++++++++-------- 2 files changed, 81 insertions(+), 59 deletions(-) diff --git a/ddportfolioservice/model/ddportfolio.ini b/ddportfolioservice/model/ddportfolio.ini index 7dd4073..3545b44 100644 --- a/ddportfolioservice/model/ddportfolio.ini +++ b/ddportfolioservice/model/ddportfolio.ini @@ -1,24 +1,25 @@ # -# Configuration for DDPortfolio service -# Copyright © 2009, 2010, 2011, 2012, 2013 Jan Dittberner +# Configuration for Debian Member Portfolio service # -# This file is part of DDPortfolio service. +# Copyright © 2009-2014 Jan Dittberner # -# DDPortfolio service is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. +# This file is part of the Debian Member Portfolio service. # -# DDPortfolio service is distributed in the hope that it will be -# useful, but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. +# Debian Member Portfolio service is free software: you can redistribute it +# and/or modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Debian Member Portfolio service is distributed in the hope that it will be# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. # # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see # . # [DEFAULT] +gnupghome=~/debian/gnupghome keyring.dir=~/debian/keyring.debian.org/keyrings urlbuilder.sections=overview,bugs,build,qa,lists,files,membership, miscellaneous,ssh,ubuntu diff --git a/ddportfolioservice/model/keyringanalyzer.py b/ddportfolioservice/model/keyringanalyzer.py index c82772e..4f134a4 100644 --- a/ddportfolioservice/model/keyringanalyzer.py +++ b/ddportfolioservice/model/keyringanalyzer.py @@ -1,20 +1,21 @@ # -*- python -*- # -*- coding: utf-8 -*- # -# DDPortfolio service application key ring analyzer tool -# Copyright © 2009, 2010, 2011, 2012 Jan Dittberner +# Debian Member Portfolio service application key ring analyzer tool # -# This file is part of DDPortfolio service. +# Copyright © 2009-2014 Jan Dittberner # -# DDPortfolio service is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of +# This file is part of the Debian Member Portfolio service. +# +# Debian Member Portfolio service is free software: you can redistribute it +# and/or modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of # the License, or (at your option) any later version. # -# DDPortfolio service is distributed in the hope that it will be -# useful, but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. +# Debian Member Portfolio service is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. # # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see @@ -38,27 +39,28 @@ import sys import email.utils +CONFIG = ConfigParser.SafeConfigParser() + + def _get_keyrings(): """ Gets the available keyring files from the keyring directory configured in ddportfolio.ini. """ - my_config = ConfigParser.ConfigParser() - my_config.readfp(pkg_resources.resource_stream( - __name__, 'ddportfolio.ini')) - keyringdir = os.path.expanduser(my_config.get('DEFAULT', 'keyring.dir')) + keyringdir = os.path.expanduser(CONFIG.get('DEFAULT', 'keyring.dir')) logging.debug("keyring dir is %s", keyringdir) keyrings = glob.glob(os.path.join(keyringdir, '*.gpg')) keyrings.extend(glob.glob(os.path.join(keyringdir, '*.pgp'))) keyrings.sort() return keyrings + def _parse_uid(uid): """ Parse a uid of the form 'Real Name ' into email and realname parts. """ - + # First try with the Python library, but it doesn't always catch everything (name, mail) = email.utils.parseaddr(uid) if (not name) and (not mail): @@ -103,49 +105,63 @@ def _add_to_result(key, newvalue): resultdict[thekey].append(newvalue) +def _handle_mail(mail, fpr): + if mail.endswith('@debian.org'): + login = mail[0:-len('@debian.org')] + _add_to_result('login:email:%s' % mail, login) + _add_to_result('login:fpr:%s' % fpr, login) + _add_to_result('fpr:login:%s' % login, fpr) + _add_to_result('fpr:email:%s' % mail, fpr) + _add_to_result('email:fpr:%s' % fpr, mail) + + +def _handle_uid(uid, fpr): + # Do stuff with 'uid' + if uid: + (uid, mail) = _parse_uid(uid) + if mail: + _handle_mail(mail, fpr) + if uid: + _add_to_result('name:fpr:%s' % fpr, uid) + if mail: + _add_to_result('name:email:%s' % mail, uid) + return fpr + + +def process_gpg_list_keys_line(line, fpr): + """ + Process a line of gpg --list-keys --with-colon output. + """ + items = line.split(':') + if items[0] == 'pub': + return None + if items[0] == 'fpr': + return items[9].strip() + if items[0] == 'uid': + if items[1] == 'r': + return fpr + return _handle_uid(items[9].strip(), fpr) + else: + return fpr + + def process_keyrings(): """Process the keyrings and store the extracted data in an anydbm file.""" for keyring in _get_keyrings(): logging.debug("get data from %s", keyring) - proc = subprocess.Popen(["gpg", "--no-options", "--no-default-keyring", + proc = subprocess.Popen([ + "gpg", "--no-options", "--no-default-keyring", + "--homedir", os.path.expanduser( + CONFIG.get('DEFAULT', 'gnupghome')), "--no-expensive-trust-checks", "--keyring", keyring, "--list-keys", - "--with-colons", "--fixed-list-mode", "--with-fingerprint", "--with-fingerprint"], + "--with-colons", "--fixed-list-mode", "--with-fingerprint", + "--with-fingerprint"], stdout=subprocess.PIPE) fpr = None - entry = None - lastpub = None for line in proc.stdout.readlines(): - items = line.split(':') - uid = None - if items[0] == 'pub': - fpr = entry = None - lastpub = items[4].strip() - continue - elif items[0] == 'fpr': - fpr = items[9].strip() - elif items[0] == 'uid': - if items[1] == 'r': - continue - uid = items[9].strip() - else: - continue - # Do stuff with 'uid' - if uid: - (uid, mail) = _parse_uid(uid) - if mail: - if mail.endswith('@debian.org'): - login = mail[0:-len('@debian.org')] - _add_to_result('login:email:%s' % mail, login) - _add_to_result('login:fpr:%s' % fpr, login) - _add_to_result('fpr:login:%s' % login, fpr) - _add_to_result('fpr:email:%s' % mail, fpr) - _add_to_result('email:fpr:%s' % fpr, mail) - if uid: - _add_to_result('name:fpr:%s' % fpr, uid) - if mail: - _add_to_result('name:email:%s' % mail, uid) + fpr = process_gpg_list_keys_line(line, fpr) retcode = proc.wait() if retcode != 0: logging.error("subprocess ended with return code %d", retcode) @@ -158,4 +174,9 @@ def process_keyrings(): if __name__ == '__main__': logging.basicConfig(stream=sys.stderr, level=logging.WARNING) + CONFIG.readfp(pkg_resources.resource_stream( + __name__, 'ddportfolio.ini')) + gpghome = os.path.expanduser(CONFIG.get('DEFAULT', 'gnupghome')) + if not os.path.isdir(gpghome): + os.makedirs(gpghome, 0700) process_keyrings() From 4e18b2bd53a98faec91ae2b6cdaebece384f0e33 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 11 Jan 2014 01:33:45 +0100 Subject: [PATCH 5/7] update templates - bump copyright years and update program name - fix escape call to work with webhelpers 1.3 --- ddportfolioservice/templates/base.mako | 29 +++++++++++----------- ddportfolioservice/templates/showform.mako | 28 ++++++++++----------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ddportfolioservice/templates/base.mako b/ddportfolioservice/templates/base.mako index 3b23a73..1e2dd8b 100644 --- a/ddportfolioservice/templates/base.mako +++ b/ddportfolioservice/templates/base.mako @@ -3,23 +3,22 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <%doc> Base template for XHTML templates. -Copyright © 2009, 2010 Jan Dittberner +Copyright © 2009-2014 Jan Dittberner -This file is part of DDPortfolio service. +This file is part of the Debian Member Portfolio service. -DDPortfolio service is free software: you can redistribute it and/or -modify it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. +Debian Member Portfolio service is free software: you can redistribute it +and/or modify it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. -DDPortfolio service is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Affero General Public License for more details. +Debian Member Portfolio service is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +General Public License for more details. -You should have received a copy of the GNU Affero General Public -License along with this program. If not, see -. +You should have received a copy of the GNU Affero General Public License along +with this program. If not, see . @@ -42,10 +41,10 @@ License along with this program. If not, see ${h.image(h.url('/images/agplv3-88x31.png'), _('AGPL - Free Software'), 88, 31, id='agpllogo')}

${h.literal(_('''The service is available under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. You can browse the source code or clone it from %(cloneurl)s using git. If you want to translate this service to your language you can contribute at Transifex.''') % dict((('browseurl', 'http://debianstuff.dittberner.info/gitweb.cgi?p=ddportfolioservice.git;a=summary'), ('cloneurl', 'http://debianstuff.dittberner.info/git/ddportfolioservice.git'), ('transifexurl', 'https://www.transifex.com/projects/p/debportfolioservice/'))))}

-

${_(u'''Copyright © 2009, 2010, 2011, 2012 Jan Dittberner''')}

+

${_(u'''Copyright © 2009-2014 Jan Dittberner''')}

diff --git a/ddportfolioservice/templates/showform.mako b/ddportfolioservice/templates/showform.mako index 6ee353a..6485e49 100644 --- a/ddportfolioservice/templates/showform.mako +++ b/ddportfolioservice/templates/showform.mako @@ -2,23 +2,23 @@ <%inherit file="base.mako" /> <%doc> Template for the data input form. -Copyright © 2009, 2010 Jan Dittberner -This file is part of DDPortfolio service. +Copyright © 2009-2014 Jan Dittberner -DDPortfolio service is free software: you can redistribute it and/or -modify it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. +This file is part of the Debian Member Portfolio service. -DDPortfolio service is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Affero General Public License for more details. +Debian Member Portfolio service is free software: you can redistribute it +and/or modify it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. -You should have received a copy of the GNU Affero General Public -License along with this program. If not, see -. +Debian Member Portfolio service is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +General Public License for more details. + +You should have received a copy of the GNU Affero General Public License along +with this program. If not, see . <%def name="titleaddon()"> - ${_('Enter your personal information')} @@ -40,7 +40,7 @@ ${h.form(h.url(action='urllist', controller='ddportfolio'), method='get')} % endif
${h.text('email', - h.escape(request.params.get('email', None), True), id='email')}
+ h.escape(request.params.get('email', None)), id='email')}