Commit 156b749b authored by Arno Töll's avatar Arno Töll
Browse files

* Refactor scripts into bin/

* Change copyright header
* Remove PPA controller
* Remove static HTML hooks we don't use anyway
parent 3dfdbf2a
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ddc.py — debian-devel-changes mail parser
#
# This file is part of debexpo - http://debexpo.workaround.org
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
"""
Executable script to parse debian-devel-changes emails and perform
appropriate action.
"""
__author__ = 'Jonny Lamb'
__copyright__ = 'Copyright © 2008 Jonny Lamb'
__license__ = 'MIT'
from optparse import OptionParser
import ConfigParser
import logging
import logging.config
import os
import sys
log = None
class DdcParser(object):
"""
Class to handle a package uploaded to Debian.
"""
def __init__(self, ini, email):
"""
Object constructor. Sets class fields to sane values.
``ini``
.ini configuration file.
``email``
Email sent to d-d-c.
"""
self.ini_file = ini
self.email = email
def _fail(self, message):
if log is not None:
log.critical(message)
else:
print >> sys.stderr, message
sys.exit(1)
def _setup_logging(self):
"""
Parse the config file and create the ``log`` object for other methods to log their
actions.
"""
global log
# Parse the ini file to validate it
parser = ConfigParser.ConfigParser()
parser.read(self.ini_file)
# Check for the presence of [loggers] in self.ini_file
if not parser.has_section('loggers'):
print >> sys.stderr, 'Config file does not have [loggers] section'
return
logging.config.fileConfig(self.ini_file)
# Use "name.pid" to avoid parser confusions in the logs
logger_name = '%s.%s' % (__name__, os.getpid())
log = logging.getLogger(logger_name)
def _setup(self):
"""
Set up logging, import pylons/paste/debexpo modules, parse config file and create config
"""
# Look for ini file
if not os.path.isfile(self.ini_file):
self._fail('Cannot find ini file %s' % self.ini_file)
self._setup_logging()
# Import debexpo root directory
sys.path.append(os.path.dirname(self.ini_file))
# Import debexpo modules
from paste.deploy import appconfig
from pylons import config
from debexpo.config.environment import load_environment
# Save app config for later
self.config = config
# Initialize Pylons app
conf = appconfig('config:' + options.ini)
load_environment(conf.global_conf, conf.local_conf)
def main(self):
"""
Parse the d-d-c email and take action.
"""
# Set up
self._setup()
if log is not None:
log.debug('d-d-c parser started with arguments: %s' % sys.argv[1:])
from debexpo.lib.changes import Changes
from debexpo.lib.repository import Repository
from debexpo.lib.plugins import Plugins
changes = Changes(string=self.email)
Plugins('post-upload-to-debian', changes, None)
# Refresh the Sources/Packages files.
log.debug('Updating Sources and Packages files')
r = Repository(self.config['debexpo.repository'])
r.update()
log.debug('Done')
if __name__ == '__main__':
parser = OptionParser(usage="%prog -i FILE")
parser.add_option('-i', '--ini', dest='ini',
help='Configuration file to user',
metavar='FILE', default=None)
(options, args) = parser.parse_args()
if not options.ini:
parser.print_help()
sys.exit(0)
email = sys.stdin.read()
p = DdcParser(options.ini, email)
p.main()
......@@ -3,7 +3,7 @@
#
# debexpo-importer — executable script to import new packages
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
#
......
......@@ -3,7 +3,7 @@
#
# debexpo_worker.py — Worker task
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2011 Arno Töll <debian@toell.net>
#
......
......@@ -3,7 +3,7 @@
#
# key_importer.py — Regenerate the mentors keyring from scratch
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2012 Arno Töll <debian@toell.net>
#
......
......@@ -2,7 +2,7 @@
#
# mass-reimporter.sh - Reimport all the packages from a pool into debexpo
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2012 Nicolas Dandrimont <nicolas.dandrimont@crans.org>
#
......
......@@ -2,7 +2,7 @@
#
# debexpo-importer — executable script to import new packages
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2011 Asheesh Laroia <paulproteus@debian.org>
#
......
......@@ -2,7 +2,7 @@
#
# environment.py — Pylons environment configuration
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# middleware.py — Pylons middleware initialization
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyrithg © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# routing.py — Routes configuration
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......@@ -96,8 +96,6 @@ def make_map(config):
action='index')
map.connect('/upload/{filename}', controller='upload', action='index')
map.connect('ppa', '/ppa/{email}', controller='ppa', action='index')
#map.connect('/ppa/{email}/*filename', controller='ppa', action='file')
map.connect('/soap.wsdl', controller='soap')
map.connect('/{controller}/{action}')
......
......@@ -2,7 +2,7 @@
#
# debian.py — Debian controller for accessing the repository
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
#
......
......@@ -2,7 +2,7 @@
#
# error.py — The application's ErrorController object
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# index.py — index controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......@@ -56,13 +56,6 @@ class IndexController(BaseController):
def index(self):
pkg_controller = PackagesController()
if 'debexpo.html.frontpage' in config:
f = open(config['debexpo.html.frontpage'])
c.custom_html = literal(f.read())
f.close()
else:
c.custom_html = ''
c.config = config
c.packages = pkg_controller._get_packages(
package_version_filter=(PackageVersion.uploaded >= (datetime.today() - timedelta(days=30))),
......@@ -86,12 +79,6 @@ class IndexController(BaseController):
def intro_maintainers(self):
"""Return an introduction page for package maintainers"""
if 'debexpo.html.maintainer_intro' in config:
f = open(config['debexpo.html.maintainer_intro'])
c.custom_html = literal(f.read())
f.close()
else:
c.custom_html = ''
# The template will need to look at the user details.
if 'user_id' in session:
......
......@@ -2,7 +2,7 @@
#
# login.py — Login controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# my.py — My Controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# package.py — Package controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# packages.py — Packages controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# password_recover.py -- controller for doing web-based password recovery
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
# -*- coding: utf-8 -*-
#
# ppa.py — ppa controller
#
# This file is part of debexpo - http://debexpo.workaround.org
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
"""
Holds the PPA controller.
"""
__author__ = 'Jonny Lamb'
__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner'
__license__ = 'MIT'
import bz2
import logging
import paste.fileapp
import os
import zlib
from debexpo.lib.base import *
from debexpo.lib.repository import Repository
from debexpo.model import meta
from debexpo.model.users import User
from debexpo.model.packages import Package
from debexpo.model.package_versions import PackageVersion
from debexpo.model.source_packages import SourcePackage
from debexpo.model.binary_packages import BinaryPackage
from debexpo.model.package_files import PackageFile
log = logging.getLogger(__name__)
class PpaController(BaseController):
def index(self, email):
"""
Displays information on accessing a user's PPA.
``email``
Email address of user.
"""
c.user = meta.session.query(User).filter_by(email=email).first()
c.config = config
return render('/ppa/index.mako')
def _create_dists(self, email, filename):
"""
Create a /dists/... file and return it in the appropraite format.
``email``
Email address to filter on.
``filename``
Filename requested. This should be something like:
"dists/unstable/main/source/Sources".
"""
splitfilename = filename.split('/')
if not len(splitfilename) == 5:
log.error('File not found')
abort(404, 'File not found')
dists, dist, component, arch, type = filename.split('/')
if arch.startswith('binary-'):
arch = arch[7:]
user = meta.session.query(User).filter_by(email=email).first()
if user is None:
log.error('User not found')
abort(404, 'User not found')
repo = Repository(config['debexpo.repository'])
if type.startswith('Sources'):
out_file = repo.get_sources_file(dist, component, user.id)
elif type.startswith('Packages'):
out_file = repo.get_packages_file(dist, component, arch, user.id)
else:
log.error('File not found')
abort(404, 'File not found')
if type.endswith('.gz'):
return zlib.compress(out_file)
elif type.endswith('.bz2'):
return bz2.compress(out_file)
else:
return out_file
def file(self, email, filename):
"""
Opens a file in the repository using Paste's FileApp.
"""
log.debug('%s requested' % filename)
if filename.startswith('dists/'):
return self._create_dists(email, filename)
file = os.path.join(config['debexpo.repository'], filename)
if os.path.isfile(file):
fapp = paste.fileapp.FileApp(file)
else:
log.error('File not found')
abort(404, 'File not found')
return fapp(request.environ, self.start_response)
......@@ -2,7 +2,7 @@
#
# register.py — Register Controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
......@@ -2,7 +2,7 @@
#
# soap.py — soap controller
#
# This file is part of debexpo - http://debexpo.workaround.org
# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment