diff --git a/debexpo/base/static/img/admin-trash.png b/debexpo/base/static/img/admin-trash.png new file mode 100644 index 0000000000000000000000000000000000000000..024e8fc4bb1560fbf08c43d26272de1bf1dac202 Binary files /dev/null and b/debexpo/base/static/img/admin-trash.png differ diff --git a/debexpo/base/static/img/key.png b/debexpo/base/static/img/key.png deleted file mode 100644 index fabe3b72e677e6ac256a517b3529b5898f901f0d..0000000000000000000000000000000000000000 Binary files a/debexpo/base/static/img/key.png and /dev/null differ diff --git a/debexpo/importer/models.py b/debexpo/importer/models.py index 1e59eff79f7e875d4a27f64b1a6185705b0c31d9..c418abdc27136c813c5103e7bbcd978df06c46ba 100644 --- a/debexpo/importer/models.py +++ b/debexpo/importer/models.py @@ -154,7 +154,8 @@ class Spool(): def get_all_changes(self, queue): changes = [] - for name in glob(join(self.queues[queue], '*.changes')): + for name in glob(join(self.queues[queue], '**', '*.changes'), + recursive=True): try: changes.append(Changes(name)) except ExceptionChanges as e: diff --git a/debexpo/packages/templates/package.html b/debexpo/packages/templates/package.html index 8809354132fb7977b25f53eaea24db1a01fef40f..8d7a4de4d8cd817e8d2c65f800f7c6ea918dfacb 100644 --- a/debexpo/packages/templates/package.html +++ b/debexpo/packages/templates/package.html @@ -99,10 +99,8 @@ Upload #{{ index }} method="post"> {% csrf_token %} {% if user.is_superuser and user not in package.get_uploaders %} - {% trans 'Admin flag' %} {% else %} -# -# 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 worker task, which cyclically eecutes tasks, defined as cronjob -""" - -__author__ = 'Arno Töll' -__copyright__ = 'Copyright © 2011 Arno Töll' -__license__ = 'MIT' - - -import logging -import logging.config -import os -import sys -import time -import ConfigParser -import pylons -import optparse -import signal -import datetime - -from paste.deploy import appconfig -from debexpo.config.environment import load_environment - -log = None - - -class Worker(object): - def __init__(self, pidfile, inifile, daemonize): - """ - Class constructor. Sets class attributes and then runs the service - - ``pidfile`` - The file name where the worker thread stores its PID file - ``inifile`` - The configuration file used to setup the worker thread - ``inifile`` - Whether to go into background - """ - - self.pidfile = pidfile - self.inifile = os.path.abspath(inifile) - self.daemonize = daemonize - self.jobs = {} - self.can_continue = True - signal.signal(signal.SIGTERM, self._on_sig_term) - - def _on_sig_term(self, sig, frame): - log.info("Received SIGTERM, shutting down worker after current run.") - self._remove_pid() - self.can_continue = False - - def _daemonize(self): - """ - Daemonize method. Runs the actual worker thread in the background - """ - try: - pid = os.fork() - if pid > 0: - sys.exit(0) - except OSError as e: - log.error("%s failed to fork: %s (err %d)" % - (__name__, e.strerror, e.errno)) - sys.exit(1) - - os.chdir("/") - os.setsid() - os.umask(0) - - file(self.pidfile, "w+").write("%d\n" % os.getpid()) - - def _remove_pid(self): - """ - Remove the process PID file - """ - log.debug("Removing pid file") - if os.path.isfile(self.pidfile): - os.remove(self.pidfile) - - def _import_plugin(self, name): - """ - Imports a module and returns it. - This is vastly the same piece of code as lib.plugins._import_plugin - - ``name`` - The plugin name to be looked up and imported to the worker task list - """ - - try: - log.debug('Trying to import cronjob: %s', name) - mod = __import__(name) - components = name.split('.') - for comp in components[1:]: - mod = getattr(mod, comp) - log.debug('Import succeeded.') - return mod - except ImportError as e: - if str(e).startswith('No module named'): - log.debug('Import failed - module not found: %s', e) - else: - log.warn('Import of module "%s" failed with error: %s', name, e) - return None - - def _load_jobs(self): - """ - Tries to load configured cronjobs. This method roughly works the same - way, as does the equivalent method in the plugins code. - """ - - if 'debexpo.cronjobs' not in pylons.config: - log.error("debexpo.cronjobs it not set - doing nothing?") - sys.exit(1) - - for plugin in pylons.config['debexpo.cronjobs'].split(" "): - module = None - if 'debexpo.cronjobdir' in pylons.config: - sys.path.append(pylons.config['debexpo.cronjobdir']) - module = self._import_plugin(plugin) - if module is not None: - log.debug('Found cronjob in debexpo.cronjobdir') - - if module is None: - name = 'debexpo.cronjobs.%s' % plugin - module = self._import_plugin(name) - - if not module: - log.warning("Cronjob %s was configured, but not found" % - (plugin)) - continue - - if hasattr(module, 'cronjob') and hasattr(module, 'schedule'): - self.jobs[plugin] = { - 'module': getattr(module, 'cronjob')( - parent=self, config=pylons.config, log=log), - 'schedule': getattr(module, 'schedule'), - 'last_run': datetime.datetime(year=1970, month=1, day=1) - } - else: - log.debug("Cronjob %s seems invalid" % (plugin)) - - def _setup(self): - """ - Sets up the worker task. Setup logging, Pylons globals and so on - """ - - global log - config = ConfigParser.ConfigParser() - config.read(self.inifile) - - if not config.has_section('loggers'): - # Sorry, the logger has not been set up yet - print('Config file does not have [loggers] section') - sys.exit(1) - - logging.config.fileConfig(self.inifile) - logger_name = 'debexpo.worker' - log = logging.getLogger(logger_name) - - sys.path.append(os.path.dirname(self.inifile)) - conf = appconfig('config:' + self.inifile) - pylons.config = load_environment(conf.global_conf, conf.local_conf) - - def run(self): - """ - Run the event loop. - This method never returns - """ - - self._setup() - if os.path.exists(self.pidfile): - try: - read_pid = file(self.pidfile, 'r') - pid = read_pid.readline().strip() - read_pid.close() - except Exception: - pid = None - else: - pid = None - - if pid: - log.error("Refusing to start - is another instance with PID " - "%s running?" % (pid)) - sys.exit(1) - - if self.daemonize: - log.debug("Go into background now") - self._daemonize() - log.debug("Loading jobs") - self._load_jobs() - delay = int(pylons.config['debexpo.cronjob_delay']) - - while self.can_continue: - for job in self.jobs: - if ((datetime.datetime.now() - self.jobs[job]['last_run']) >= - self.jobs[job]['schedule']): - log.debug("Run job %s" % (job)) - self.jobs[job]['module'].invoke() - self.jobs[job]['last_run'] = datetime.datetime.now() - log.debug("Job %s complete" % (job)) - - if not self.can_continue: - return - - time.sleep(delay) - - -if __name__ == '__main__': - parser = optparse.OptionParser() - parser.add_option("-i", "--ini", dest="ini", - help="path to application ini file", metavar="FILE") - parser.add_option("-p", "--pid-file", dest="pid", - help="path where the PID file is stored", metavar="FILE") - parser.add_option("-d", "--daemonize", dest="daemonize", - action='store_true', help="go into background") - - (options, args) = parser.parse_args() - if not options.pid or not options.ini: - parser.print_help() - sys.exit(0) - - worker = Worker(options.pid, options.ini, options.daemonize) - worker.run() diff --git a/old/contrib/database/env.py b/old/contrib/database/env.py deleted file mode 100644 index c26f89dd4fd9ff542000801c18ceed8abffadb99..0000000000000000000000000000000000000000 --- a/old/contrib/database/env.py +++ /dev/null @@ -1,87 +0,0 @@ -"""Pylons bootstrap environment. - -Place 'pylons_config_file' into alembic.ini, and the application will -be loaded from there. - -""" -from logging.config import fileConfig - -from paste.deploy import loadapp - -from alembic import context - - -try: - # if pylons app already in, don't create a new app - from pylons import config as pylons_config - - pylons_config["__file__"] -except KeyError: - config = context.config - # can use config['__file__'] here, i.e. the Pylons - # ini file, instead of alembic.ini - config_file = config.config_file_name - fileConfig(config_file) - wsgi_app = loadapp("config:%s" % config_file, relative_to=".") - - -# customize this section for non-standard engine configurations. -meta = __import__( - "%s.model.meta" % wsgi_app.config["pylons.package"] -).model.meta - -# add your model's MetaData object here -# for 'autogenerate' support -# from myapp import mymodel -# target_metadata = mymodel.Base.metadata -target_metadata = None - - -def run_migrations_offline(): - """Run migrations in 'offline' mode. - - This configures the context with just a URL - and not an Engine, though an Engine is acceptable - here as well. By skipping the Engine creation - we don't even need a DBAPI to be available. - - Calls to context.execute() here emit the given string to the - script output. - - """ - context.configure( - url=meta.engine.url, - target_metadata=target_metadata, - literal_binds=True, - render_as_batch=True - ) - with context.begin_transaction(): - context.run_migrations() - - -def run_migrations_online(): - """Run migrations in 'online' mode. - - In this scenario we need to create an Engine - and associate a connection with the context. - - """ - # specify here how the engine is acquired - engine = meta.engine - # raise NotImplementedError("Please specify engine connectivity here") - - with engine.connect() as connection: # noqa - context.configure( - connection=connection, - target_metadata=target_metadata, - render_as_batch=True - ) - - with context.begin_transaction(): - context.run_migrations() - - -if context.is_offline_mode(): - run_migrations_offline() -else: - run_migrations_online() diff --git a/old/contrib/database/script.py.mako b/old/contrib/database/script.py.mako deleted file mode 100644 index 2c0156303a8df3ffdc9de87765bf801bf6bea4a5..0000000000000000000000000000000000000000 --- a/old/contrib/database/script.py.mako +++ /dev/null @@ -1,24 +0,0 @@ -"""${message} - -Revision ID: ${up_revision} -Revises: ${down_revision | comma,n} -Create Date: ${create_date} - -""" -from alembic import op -import sqlalchemy as sa -${imports if imports else ""} - -# revision identifiers, used by Alembic. -revision = ${repr(up_revision)} -down_revision = ${repr(down_revision)} -branch_labels = ${repr(branch_labels)} -depends_on = ${repr(depends_on)} - - -def upgrade(): - ${upgrades if upgrades else "pass"} - - -def downgrade(): - ${downgrades if downgrades else "pass"} diff --git a/old/contrib/database/versions/0000-base.py b/old/contrib/database/versions/0000-base.py deleted file mode 100644 index 2ec4f4f91c56331b3e8d885c33249d8a8e9a4f84..0000000000000000000000000000000000000000 --- a/old/contrib/database/versions/0000-base.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Base - -Revision ID: 7cceb63f746e -Revises: -Create Date: 2019-02-13 14:07:03.774616 - -This file exists to allow downgrading from the first real version -""" - -# revision identifiers, used by Alembic. -revision = '7cceb63f746e' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/old/contrib/database/versions/0001-add_a_field_on_table_package_files_to_.py b/old/contrib/database/versions/0001-add_a_field_on_table_package_files_to_.py deleted file mode 100644 index 56745905fd619d58198468ad815bbde1f4730d41..0000000000000000000000000000000000000000 --- a/old/contrib/database/versions/0001-add_a_field_on_table_package_files_to_.py +++ /dev/null @@ -1,43 +0,0 @@ -"""Add a field on table package_files to hold file's sha256 checksum - -Revision ID: 8d6f497e959e -Revises: -Create Date: 2019-02-13 13:33:36.249795 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '8d6f497e959e' -down_revision = '7cceb63f746e' -branch_labels = None -depends_on = None - -# SQlite does not support ALTER TABLE with ALTER COLUMN. -# Hence we must: -# - create a new table with the correct schema -# - copy over the data -# - swap the names -# - remove the old table -# -# https://www.sqlitetutorial.net/sqlite-alter-table/ - -# Alembic has a feature that take care of that automatically. -# -# https://alembic.sqlalchemy.org/en/latest/batch.html#batch-mode-with-autogenerate - - -def upgrade(): - op.add_column('package_files', sa.Column('sha256sum', sa.types.String(64), - nullable=False, server_default='')) - with op.batch_alter_table('package_files', schema=None) as batch_op: - batch_op.alter_column('sha256sum', server_default=None) - pass - - -def downgrade(): - with op.batch_alter_table('package_files', schema=None) as batch_op: - batch_op.drop_column('sha256sum') - pass diff --git a/old/contrib/database/versions/0002-switch_from_200_to_32_char_for_md5sum_.py b/old/contrib/database/versions/0002-switch_from_200_to_32_char_for_md5sum_.py deleted file mode 100644 index 26e189873c5723959e54f3ec68fdef3807e75032..0000000000000000000000000000000000000000 --- a/old/contrib/database/versions/0002-switch_from_200_to_32_char_for_md5sum_.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Switch from 200 to 32 char for md5sum field in package_files table - -Revision ID: 1d81fcc4f3db -Revises: 8d6f497e959e -Create Date: 2019-02-13 15:17:51.471113 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '1d81fcc4f3db' -down_revision = '8d6f497e959e' -branch_labels = None -depends_on = None - - -def upgrade(): - with op.batch_alter_table('package_files', schema=None) as batch_op: - batch_op.alter_column('md5sum', type_=sa.types.String(32)) - pass - - -def downgrade(): - with op.batch_alter_table('package_files', schema=None) as batch_op: - batch_op.alter_column('md5sum', type_=sa.types.String(200)) - pass diff --git a/old/debexpo/__init__.py b/old/debexpo/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/config/__init__.py b/old/debexpo/config/__init__.py deleted file mode 100644 index 89a0fe37fc86892624ccad185647459bf283437d..0000000000000000000000000000000000000000 --- a/old/debexpo/config/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os.path -import pylons -from paste.deploy import appconfig - - -def easy_app_init(ini_path): - ini_path = os.path.abspath(ini_path) - assert os.path.exists(ini_path) - - # Initialize Pylons app - conf = appconfig('config:' + ini_path) - import debexpo.config.environment - pylons.config = debexpo.config.environment \ - .load_environment(conf.global_conf, conf.local_conf) diff --git a/old/debexpo/config/environment.py b/old/debexpo/config/environment.py deleted file mode 100644 index 2abeeb3a95458aa36779b04bb2dad51378da5786..0000000000000000000000000000000000000000 --- a/old/debexpo/config/environment.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- -# -# environment.py — Pylons environment configuration -# -# This file is part of debexpo -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyright © 2010 Jan Dittberner -# -# 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. - -""" -Pylons environment configuration. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner' -__license__ = 'MIT' - -import os - -from mako.lookup import TemplateLookup -from pylons.configuration import PylonsConfig -from pylons.error import handle_mako_error - -import debexpo.lib.app_globals as app_globals -import debexpo.lib.helpers -from debexpo.lib.utils import get_debexpo_version -from debexpo.config.routing import make_map - -from sqlalchemy import engine_from_config -from debexpo.model import init_model - - -def load_environment(global_conf, app_conf): - """ - Configures the Pylons environment via the ``pylons.config`` object. - - ``global_conf`` - Global configuration. - - ``app_conf`` - Application configuration. - """ - config = PylonsConfig() - - # Pylons paths - root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - paths = dict(root=root, - controllers=os.path.join(root, 'controllers'), - static_files=os.path.join(root, 'public'), - templates=[os.path.join(root, 'templates')]) - - # Initialize config with the basic options - config.init_app(global_conf, app_conf, package='debexpo', - paths=paths) - - config['routes.map'] = make_map(config) - config['pylons.app_globals'] = app_globals.Globals(config) - config['pylons.h'] = debexpo.lib.helpers - - import pylons - pylons.cache._push_object(config['pylons.app_globals'].cache) - - # config['pylons.strict_c'] = False - # config['pylons.tmpl_context_attach_args'] = True - - # Customize templating options via this variable - config['pylons.app_globals'].mako_lookup = TemplateLookup( - directories=paths['templates'], - error_handler=handle_mako_error, - module_directory=os.path.join(app_conf['cache_dir'], 'templates'), - input_encoding='utf-8', default_filters=['escape'], - imports=['from webhelpers.html import escape', - 'from debexpo.lib.filters import semitrusted']) - - # CONFIGURATION OPTIONS HERE (note: all config options will override - # any Pylons config options) - - engine = engine_from_config(config, 'sqlalchemy.') - init_model(engine) - - version = get_debexpo_version() - if version: - config['debexpo.version'] = version - - return config diff --git a/old/debexpo/config/middleware.py b/old/debexpo/config/middleware.py deleted file mode 100644 index 1c452aea0ca16320a60ead9cb0ddb670b76aedc2..0000000000000000000000000000000000000000 --- a/old/debexpo/config/middleware.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- coding: utf-8 -*- -# -# middleware.py — Pylons middleware initialization -# -# This file is part of debexpo -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyrithg © 2010 Jan Dittberner -# -# 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. - -""" -Pylons middleware initialization. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner' -__license__ = 'MIT' - -from paste.cascade import Cascade -from paste.registry import RegistryManager -from paste.urlparser import StaticURLParser -from paste.deploy.converters import asbool -from beaker.middleware import SessionMiddleware -from routes.middleware import RoutesMiddleware - -from pylons.middleware import ErrorHandler, StatusCodeRedirect -from pylons.wsgiapp import PylonsApp - -from debexpo.config.environment import load_environment - - -def make_app(global_conf, full_stack=True, static_files=True, **app_conf): - """Creates a Pylons WSGI application and returns it. - - ``global_conf`` - The inherited configuration for this application. Normally from - the [DEFAULT] section of the Paste ini file. - - ``full_stack`` - Whether or not this application provides a full WSGI stack (by - default, meaning it handles its own exceptions and errors). - Disable full_stack when this application is "managed" by - another WSGI middleware. - - ``static_files`` - Whether this application serves its own static files; disable - when another web server is responsible for serving them. - - ``app_conf`` - The application's local configuration. Normally specified in the - [app:] section of the Paste ini file (where - defaults to main). - """ - # Configure the Pylons environment - config = load_environment(global_conf, app_conf) - - # The Pylons WSGI app - app = PylonsApp(config=config) - - # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) - - # Routing/Session/Cache Middleware - app = RoutesMiddleware(app, config['routes.map']) - app = SessionMiddleware(app, config) - - if asbool(full_stack): - # Handle Python exceptions - app = ErrorHandler(app, global_conf, - **config['pylons.errorware']) - - # Display error documents for 401, 403, 404 status codes (and - # 500 when debug is disabled) - if asbool(config['debug']): - app = StatusCodeRedirect(app) - else: - app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) - - # Establish the Registry for this application - app = RegistryManager(app) - - # Static files - if asbool(static_files): - static_app = StaticURLParser(config['pylons.paths']['static_files']) - app = Cascade([static_app, app]) - - app.config = config - return app diff --git a/old/debexpo/config/routing.py b/old/debexpo/config/routing.py deleted file mode 100644 index eb528192c0be9703b90d5d4d7ea7d96e8cc08d74..0000000000000000000000000000000000000000 --- a/old/debexpo/config/routing.py +++ /dev/null @@ -1,126 +0,0 @@ -# -*- coding: utf-8 -*- -# -# routing.py — Routes configuration -# -# This file is part of debexpo -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyright © 2010 Jan Dittberner -# -# 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. - -""" -Routes configuration - -The more specific and detailed routes should be defined first so they -may take precedent over the more generic routes. For more information -refer to the routes manual at http://routes.groovie.org/docs/ -""" -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner' -__license__ = 'MIT' - -from routes import Mapper - - -def make_map(config): - """ - Creates, configures and returns the routes Mapper. - """ - map = Mapper(directory=config['pylons.paths']['controllers'], - always_scan=config['debug']) - map.minimization = False - - # The ErrorController route (handles 404/500 error pages); it should - # likely stay at the top, ensuring it can always be resolved - map.connect('error/{action}', controller='error') - map.connect('error/{action}/{id}', controller='error') - - # CUSTOM ROUTES HERE - - # n.b.: chances are, this route is overriden by a productive setup in its - # web server configuration - if config['debexpo.handle_debian'].lower() == 'true': - map.connect('/debian/*filename', controller='debian', action='index') - - map.connect('index', '/', controller='index', action='index') - map.connect('contact', '/contact', controller='index', action='contact') - map.connect('intro-maintainers', '/intro-maintainers', - controller='index', action='intro_maintainers') - map.connect('sponsors', '/sponsors', controller='sponsor', action='index') - map.connect('packaging-team', '/sponsors/spackaging-team', - controller='sponsor', action='packaging_team') - map.connect('guidelines', '/sponsors/guidelines', controller='sponsor', - action='guidelines') - map.connect('sponsor-developer', '/sponsors/profile/{id}', - controller='sponsor', action='developer') - map.connect('sponsor_tag_save', '/sponsors/save', controller='sponsor', - action='save') - map.connect('sponsor_tag_clear', '/sponsors/clear', controller='sponsor', - action='clear') - map.connect('intro-reviewers', '/intro-reviewers', controller='index', - action='intro_reviewers') - map.connect('my', '/my', controller='my', action='index') - map.connect('login', '/login', controller='login', action='index') - map.connect('logout', '/logout', controller='login', action='logout') - map.connect('news', '/news', controller='index', action='news') - map.connect('/package', controller='package', action='index') - map.connect('package', '/package/{packagename}', controller='package', - action='index') - map.connect('comment', '/package/{packagename}/comment', - controller='package', action='comment') - map.connect('sponsor', '/package/{packagename}/needs_sponsor/{key}', - controller='package', action='sponsor') - map.connect('subscribe', '/package/{packagename}/subscribe', - controller='package', action='subscribe') - map.connect('delete', '/package/{packagename}/delete/{key}', - controller='package', action='delete') - map.connect('rfs-howto', '/sponsors/rfs-howto', controller='sponsor', - action='rfs_howto') - map.connect('rfs', '/sponsors/rfs-howto/{packagename}', - controller='sponsor', action='rfs_howto') - map.connect('packages', '/packages/{action}', controller='packages', - action='index') - map.connect('all-packages', '/packages', controller='packages', - action='index') - map.connect('packages-uploader', '/packages/uploader/{id}', - controller='packages', action='uploader') - # map.connect('/packages/{action}/{id}', controller='packages', - # action='index', id=None) - map.connect('packages_filter_feed', '/packages/{filter}/{id}/feed', - controller='packages', action='feed') - # map.connect('packages_feed', '/packages/feed', controller='packages', - # action='feed') - map.connect('qa', '/qa', controller='index', action='qa') - - # LEGACY ROUTE. CAN BE REMOVED LATER - map.connect('/upload/{email}/{password}/{filename}', controller='upload', - action='index') - - map.connect('/upload/{filename}', controller='upload', action='index') - - map.connect('/{controller}/{action}') - map.connect('/{controller}/{action}/{id}') - # map.connect('/*url', controller='template', action='view') - - return map diff --git a/old/debexpo/controllers/__init__.py b/old/debexpo/controllers/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/controllers/debian.py b/old/debexpo/controllers/debian.py deleted file mode 100644 index 865bc4eee6b17dbb02925a04673f7aa83dd40765..0000000000000000000000000000000000000000 --- a/old/debexpo/controllers/debian.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -# -# debian.py — Debian controller for accessing the repository -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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. - -""" -This module holds the Debian controller which manages the /debian/ directory. -""" - -# -# XXX: This controller is ONLY used if no standalone web server is running. -# For productive setups it is suggested to deliver static content through -# the web server (e.g. Apache) directly -# - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import os -import logging -import paste.fileapp - -from debexpo.lib.base import BaseController -from pylons import config, request -from pylons.controllers.util import abort - -log = logging.getLogger(__name__) - - -class DebianController(BaseController): - """ - Class for handling the /debian/ directory. - """ - - def index(self, filename): - """ - Entry point to the controller. Opens a file in the repository using - Paste's FileApp. - """ - file = os.path.join(config['debexpo.repository'], filename) - log.debug('%s requested' % filename) - - content_type = None - if filename.endswith('.dsc'): - content_type = 'text/plain' - - if os.path.isfile(file): - fapp = paste.fileapp.FileApp(file, content_type=content_type) - else: - log.error('File not found') - abort(404, 'File not found') - - return fapp(request.environ, self.start_response) diff --git a/old/debexpo/cronjobs/__init__.py b/old/debexpo/cronjobs/__init__.py deleted file mode 100644 index 55b5de4a211445bd5577d75a34aa772f2e71c699..0000000000000000000000000000000000000000 --- a/old/debexpo/cronjobs/__init__.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# -# cronjobs module — Base class for all cronjobs -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2011 Arno Töll -# -# 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. - -""" -Base class for all cronjobs -""" -__author__ = 'Arno Töll' -__copyright__ = 'Copyright © 2011 Arno Töll' -__license__ = 'MIT' - - -class BaseCronjob(object): - def __init__(self, parent, config, log): - self.parent = parent - self.config = config - self.log = log - - self.setup() - - def __del__(self): - self.teardown() - - def setup(self): - raise AssertionError("A cronjob must implement this class") - - def teardown(self): - raise AssertionError("A cronjob must implement this class") - - def invoke(self): - raise AssertionError("A cronjob must implement this class") diff --git a/old/debexpo/cronjobs/importcomments.py b/old/debexpo/cronjobs/importcomments.py deleted file mode 100644 index 8a9b191485affa9d4d26f453a4084c1311e46991..0000000000000000000000000000000000000000 --- a/old/debexpo/cronjobs/importcomments.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -# -# importcomments.py — Import RFS comments from debian-mentors -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2011 Arno Töll -# -# 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. - -""" -Import RFS comments from debian-mentors -""" -__author__ = 'Arno Töll' -__copyright__ = 'Copyright © 2011 Arno Töll' -__license__ = 'MIT' - -from debexpo.cronjobs import BaseCronjob - - -class ImportComments(BaseCronjob): - def deploy(): - print("Running ImportUpload") - - -cronjob = ImportComments -schedule = 1 diff --git a/old/debexpo/cronjobs/importuploads.py b/old/debexpo/cronjobs/importuploads.py deleted file mode 100644 index 70f4474206c78dd551d74c0652b8c1322c30e6cb..0000000000000000000000000000000000000000 --- a/old/debexpo/cronjobs/importuploads.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- coding: utf-8 -*- -# -# importuploads.py — Import FTP uploads to Debexpo -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2011 Arno Töll -# -# 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. - -""" -Import FTP uploads to Debexpo -""" -__author__ = 'Arno Töll' -__copyright__ = 'Copyright © 2011 Arno Töll' -__license__ = 'MIT' - -from debexpo.cronjobs import BaseCronjob - -import glob -import os -import os.path -import time -import datetime -import shutil - -import debexpo.lib.filesystem -from debexpo.lib.changes import Changes -from debexpo.importer.importer import Importer - - -class ImportUpload(BaseCronjob): - def setup(self): - """ - This method does nothing in this cronjob - """ - self.files = debexpo.lib.filesystem.CheckFiles() - self.log.debug("%s loaded successfully" % (__name__)) - - def teardown(self): - """ - This method does nothing in this cronjob - """ - pass - - def invoke(self): - """ - Loops through the debexpo.upload.incoming directory and runs the - debexpo.importer for each file - """ - if ('debexpo.upload.incoming' not in self.config or not - os.path.isdir(self.config['debexpo.upload.incoming'])): - self.log.critical("debexpo.upload.incoming was not configured") - return - - # 1) Process uploads - base_path = os.path.join(self.config['debexpo.upload.incoming'], "pub") - directories = map(lambda tree: tree[0], os.walk(base_path)) - for changes_file in sum((glob.glob(os.path.join(directory, '*.changes')) - for directory in directories), []): - self.log.info("Importing upload: %s", changes_file) - try: - parsed_changes = Changes(filename=changes_file) - except Exception: - self.log.exception('Invalid changes file: %s' % changes_file) - os.remove(changes_file) - continue - - directory = os.path.dirname(changes_file) - uploaded_files = parsed_changes.get_files() + \ - [parsed_changes.get_filename()] - for filename in uploaded_files: - source_file = os.path.join(directory, filename) - destination_file = os.path.join( - self.config['debexpo.upload.incoming'], filename) - - if os.path.exists(destination_file): - self.log.debug("File %s already exists on the destination " - "directory, removing.", filename) - os.remove(destination_file) - if os.path.exists(source_file): - shutil.move(source_file, - self.config['debexpo.upload.incoming']) - else: - self.log.debug("Source file %s does not exist, continuing.", - filename) - - importer = Importer(parsed_changes.get_filename(), - self.config['global_conf']['__file__'], - False, - False) - - returncode = importer.main(no_env=True) - if returncode != 0: - self.log.critical("Importer failed to import package %s " - "[err=%d]." % (changes_file, returncode)) - for filename in uploaded_files: - destination_file = os.path.join( - self.config['debexpo.upload.incoming'], filename) - if os.path.exists(destination_file): - self.log.debug("Remove stale file %s - the importer " - "probably crashed" % (destination_file)) - os.remove(destination_file) - - # 2) Mark unprocessed files and get rid of them after some time - for pub in directories: - for file in glob.glob(os.path.join(pub, '*')): - if self.files.allowed_upload(file): - self.log.debug("Incomplete upload: %s" % (file)) - last_change = time.time() - os.stat(file).st_mtime - # the file was uploaded more than 6 hours ago - if last_change > 6 * 60 * 60: - self.log.warning("Remove old file: %s (last modified " - "%.2f hours ago)" % - (file, last_change / 3600.)) - os.remove(file) - else: - if os.path.isfile(file): - self.log.warning("Remove unknown file: %s" % (file)) - os.remove(file) - - -cronjob = ImportUpload -schedule = datetime.timedelta(minutes=10) diff --git a/old/debexpo/importer/__init__.py b/old/debexpo/importer/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/lib/__init__.py b/old/debexpo/lib/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/lib/app_globals.py b/old/debexpo/lib/app_globals.py deleted file mode 100644 index aeae96b4e5e7792a5424feb3b3ff3a69cfb716f4..0000000000000000000000000000000000000000 --- a/old/debexpo/lib/app_globals.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -# -# app_globals.py — The application's Globals object -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyright © 2010 Jan Dittberner -# -# 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 Globals class. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner' -__license__ = 'MIT' - -from beaker.cache import CacheManager -from beaker.util import parse_cache_config_options - - -class Globals(object): - """ - Acts as a container for objects available throughout the life of a request. - """ - - def __init__(self, config): - """ - Object constructor; does nothing. - - One instance of Globals is created during application - initialization and is available during requests via the 'g' - variable. - """ - # Supported languages for i18n - self.supported_languages = { - 'el': 'ελληνικά', - 'en': 'English', - 'de': 'Deutsch', - 'it': 'Italiano', - 'ja': '日本語', - 'fr': 'Français', - } - self.default_language = 'en' - - self.cache = CacheManager(**parse_cache_config_options(config)) diff --git a/old/debexpo/lib/base.py b/old/debexpo/lib/base.py deleted file mode 100644 index 70bff5ec18869339f9b273e4a24e16786dbc4557..0000000000000000000000000000000000000000 --- a/old/debexpo/lib/base.py +++ /dev/null @@ -1,171 +0,0 @@ -# -*- coding: utf-8 -*- -# -# base.py — The base Controller API -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyright © 2010 Jan Dittberner -# Copyright © 2011 Arno Töll -# -# 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 base Controller API. - -Provides the BaseController class for subclassing, and other objects -utilized by Controllers. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, ' \ - 'Copyright © 2010 Jan Dittberner, ' \ - 'Copyright © 2011 Arno Töll' -__license__ = 'MIT' - -import logging - -from pylons import tmpl_context as c, cache, config, app_globals, request, \ - response, session, url -from pylons.controllers import WSGIController -from pylons.controllers.util import abort, etag_cache, redirect -from pylons.decorators import jsonify, validate -from pylons.i18n import _, ungettext, N_, get_lang, set_lang -from pylons.templating import render_mako as render - -import debexpo.model as model -from debexpo.model import meta - -log = logging.getLogger(__name__) - - -class SubMenu(object): - """ - A sub menu class, to be instantiated by controller. - This class holds several data structures which are parsed by the template - engine and result in a per-controller sub menu. - The controller only needs to feed this menu. - """ - def __init__(self): - self._label = None - self._menu = [] - self._entries = [] - self._has_menu = False - self._menu_label = None - - def has_menu(self): - return self._has_menu - - def has_label(self): - return self._label is not None - - def has_submenu(self): - return len(self._menu) > 0 - - def set_label(self, label): - self._has_menu = True - self._label = label - - def add_menu(self, label, menu): - if not isinstance(menu, SubMenu): - raise AttributeError("%s is not an instance of SubMenu" % (menu)) - self._has_menu = True - self._menu_label = label - self._menu.append(menu) - - def add_entry(self, label, link): - self._has_menu = True - self._entries.append((label, link)) - - def submenulabel(self): - return self._menu_label - - def label(self): - return self._label - - def entries(self): - for e in self._entries: - yield e - - def menus(self): - for e in self._menu: - yield e - - -class BaseController(WSGIController): - """ - Base controller class for all other controllers to extend. - """ - - requires_auth = False - - def __before__(self): - # Set language according to what the browser requested - try: - languages = request.languages - except (AttributeError, TypeError): - log.debug("Working around Pylons request.languages bug") - languages = [] - - for ua_lang in languages: - log.debug("Trying user agent language %s" % ua_lang) - # only get the main language code (fr_FR -> fr) - if ua_lang: - ua_lang = ua_lang[0:2] - if ua_lang in app_globals.supported_languages: - set_lang(ua_lang) - break - else: - set_lang(app_globals.default_language) - - if self.requires_auth and 'user_id' not in session: - # Remember where we came from so that the user can be sent there - # after a successful login - session['path_before_login'] = request.path_info - session.save() - redirect(url(controller='login', action='index')) - - c.config = config - # The templates require the submenu to be existing - # If no controller added a submenu, its fair enough to instantiate an - # empty object here - if not hasattr(c, 'submenu'): - c.submenu = SubMenu() - - def __call__(self, environ, start_response): - """ - Invokes the Controller. - """ - # WSGIController.__call__ dispatches to the Controller method - # the request is routed to. This routing information is - # available in environ['pylons.routes_dict'] - c.feed_url = None - try: - return WSGIController.__call__(self, environ, start_response) - finally: - meta.session.remove() - - -# Include the '_' function in the public names -__all__ = [__name for __name in locals().keys() if not __name.startswith('_') - or __name == '_'] diff --git a/old/debexpo/lib/filesystem.py b/old/debexpo/lib/filesystem.py deleted file mode 100644 index 40a5d768d69d821fdaaf0385adb12cc2e084dfae..0000000000000000000000000000000000000000 --- a/old/debexpo/lib/filesystem.py +++ /dev/null @@ -1,287 +0,0 @@ -# -*- coding: utf-8 -*- -# -# checkfiles.py — checkfiles plugin -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# © 2011 Arno Töll -# -# 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 various filesystem checks and interaction methods to store source package -on the disk. -""" - -__author__ = 'Jonny Lamb and Arno Töll' -__copyright__ = 'Copyright © 2008 Jonny Lamb, © 2011 Arno Töll' -__license__ = 'MIT' - -import logging -import os -import pylons -import shutil - -from debexpo.lib import constants -from debexpo.lib.constants import DPKG_COMPRESSION_ALGO -from debexpo.lib.utils import md5sum - -from debian import deb822 - -log = logging.getLogger(__name__) - - -class CheckFiles(object): - - def test_files_present(self, changes_file): - """ - Check whether each file listed in the changes file is present. - - ```changes_file``` - The changes file to parse for the orig.tar (note the dsc file - referenced must exist) - """ - for filename in changes_file.get_files(): - log.debug('Looking whether %s was actually uploaded' % filename) - if os.path.isfile( - os.path.join(pylons.config['debexpo.upload.incoming'], - filename)): - log.debug('%s is present' % filename) - else: - log.critical('%s is not present; importing cannot continue' % - filename) - raise OSError("Missing file %s in incoming" % (filename)) - - return True - - def test_md5sum(self, changes_file): - """ - Check each file's md5sum and make sure the md5sum in the changes file is - the same as the actual file's md5sum. - - ```changes_file``` - The changes file to parse for the orig.tar (note the dsc file - referenced must exist) - """ - for file in changes_file['Files']: - log.debug('Checking md5sum of %s' % file['name']) - filename = os.path.join(pylons.config['debexpo.upload.incoming'], - file['name']) - if not os.path.isfile(filename): - raise OSError("Missing file %s in incoming" % (file['name'])) - sum = md5sum(filename) - - if sum != file['md5sum']: - log.critical('%s != %s' % (sum, file['md5sum'])) - raise OSError("MD5 sum mismatch in file %s: %s != %s" % - (file['name'], sum, file['md5sum'])) - - return True - - def is_native_package(self, changes_file): - """ - Guess based on the changes file and files being uploaded, whether a - package is considered native of not - - ```changes_file``` - The changes file to parse for the orig.tar (note the dsc file - referenced must exist) - """ - - for file in changes_file['Files']: - if file['name'].endswith('.diff.gz'): - return False - if file['name'].endswith(('.debian.tar.gz', '.debian.tar.bz2', - '.debian.tar.xz')): - return False - return True - - def find_orig_tarball(self, changes_file): - """ - Look to see whether there is an orig tarball present, if the dsc refers - to one. This method returns a triple (filename, file_found, - location_hint), returning the (expected) name of the original tarball, - and whether it was found in the local repository - - ```changes_file``` - The changes file to parse for the orig.tar (note the dsc file - referenced must exist) - - Returns a tuple (orig_filename, orig_filename_was_found) - """ - - orig_name = None - if not changes_file.get_dsc() or open(changes_file.get_dsc()) is None: - return (orig_name, constants.ORIG_TARBALL_LOCATION_NOT_FOUND) - - dscfile = open(changes_file.get_dsc()) - dsc = deb822.Dsc(dscfile) - for file in dsc['Files']: - for algo in DPKG_COMPRESSION_ALGO: - if file['name'].endswith('orig.tar.{}'.format(algo)): - # We know how the orig.tar.gz should be called - at least. - orig_name = file['name'] - full_filename = os.path.join( - pylons.config['debexpo.repository'], - changes_file.get_pool_path(), - orig_name) - # tar.gz was found in the local directory - if os.path.isfile(file['name']): - sum = md5sum(file['name']) - if sum == file['md5sum']: - return (orig_name, - constants.ORIG_TARBALL_LOCATION_LOCAL) - # tar.gz was found, but does not seem to be the same - # file - # tar.gz was found in the repository - elif os.path.isfile(full_filename): - return (orig_name, - constants.ORIG_TARBALL_LOCATION_REPOSITORY) - # tar.gz was expected but not found at all - else: - return (orig_name, - constants.ORIG_TARBALL_LOCATION_NOT_FOUND) - - # We should neve end up here - return (orig_name, constants.ORIG_TARBALL_LOCATION_NOT_FOUND) - - def delete_git_storage_for_package(self, package): - """ - Removes all files associated with the package supplied - - ```package``` package object whose files are supposed to be removed - """ - git_storage_sources = os.path.join(pylons.config['debexpo.repository'], - "git", package.name) - if os.path.isdir(git_storage_sources): - # Wrap the path name in str() to workaround - # https://bugs.python.org/issue24672 . See: - # https://salsa.debian.org/mentors.debian.net-team/debexpo/issues/66 - shutil.rmtree(str(git_storage_sources), True) - - def find_files_for_packageversion(self, packageversion, - absolute_path=False): - """ - Returns all unique paths for files associated with the supplied - package version - - ```packageversion``` The package version to be scanned - - ```absolute_path``` if set to True, returns the absolute path - instead of a path relative to the repository root - """ - package_files = [] - for attr in ('binary_packages', 'source_packages'): - if hasattr(packageversion, attr): - for bp in getattr(packageversion, attr): - for files in bp.package_files: - if files.filename not in package_files: - package_files.append( - files.filename if not absolute_path - else pylons.config['debexpo.repository'] + - files.filename) - return package_files - - def find_files_for_package(self, package, absolute_path=False): - """ - Returns all unique paths for files associated with the supplied - packages - - ```package``` The package to be scanned - - ```absolute_path``` if set to True, returns the absolute path - instead of a path relative to the repository root - """ - package_files = [] - for p in package.package_versions: - package_files.extend( - self.find_files_for_packageversion(p, absolute_path)) - return package_files - - def delete_files_for_packageversion(self, packageversion): - """ - Removes all files associated with the package version supplied - - ```packageversion``` PackageVersion object whose files are supposed to - be removed - """ - files = self.find_files_for_packageversion(packageversion, - absolute_path=True) - if not files: - return - path = os.path.dirname(files[0]) - for file in files: - if os.path.exists(file): - log.debug("Removing file '%s'" % (file)) - os.unlink(file) - if os.path.isdir(path) and os.listdir(path) == []: - log.debug("Remove empty package repository '%s'" % (path)) - os.rmdir(path) - - def delete_files_for_package(self, package): - """ - Removes all files associated with the package supplied - - ```package``` package object whose files are supposed to be removed - """ - files = self.find_files_for_package(package, absolute_path=True) - self.delete_git_storage_for_package(package) - if not files: - return - path = os.path.dirname(files[0]) - for file in files: - if os.path.exists(file): - log.debug("Removing file '%s'" % (file)) - os.unlink(file) - if os.path.isdir(path) and os.listdir(path) == []: - log.debug("Remove empty package repository '%s'" % (path)) - os.rmdir(path) - - def allowed_upload(self, filename): - """ - Looks at a filename's extension and decides whether to accept it. - We only want package files to be uploaded, after all. - It returns a boolean of whether to accept the file or not. - - ``filename`` - File to test. - """ - suffixes = [ - '.asc', - '.buildinfo', - '.changes', - '.deb', - '.diff.gz', - '.dsc', - '.udeb', - ] - - for algo in DPKG_COMPRESSION_ALGO: - suffixes.append('tar.{}'.format(algo)) - - for suffix in suffixes: - if filename.endswith(suffix): - return True - - return False diff --git a/old/debexpo/lib/filters.py b/old/debexpo/lib/filters.py deleted file mode 100644 index 02be3af8bac1534d0a433badb9745b5d77d29fd6..0000000000000000000000000000000000000000 --- a/old/debexpo/lib/filters.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# -# filter.py — Output filters for the template engine -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2011 Arno Töll -# -# 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 various output filters which can be applied to templates -""" - -__author__ = 'Arno Töll' -__copyright__ = 'Copyright © 2011 Arno Töll' -__license__ = 'MIT' - -import cgi - - -def semitrusted(input_filter): - """ - This filter filters all input, but keeps formatting, e.g. newlines - - ``input_filter`` The data to be filtered - """ - escaped_filter = cgi.escape(input_filter, True) - escaped_filter = escaped_filter.replace('\n', '
') - return escaped_filter diff --git a/old/debexpo/lib/form.py b/old/debexpo/lib/form.py deleted file mode 100644 index 5d64816b6e689b51967c12de5590f64da5807cb1..0000000000000000000000000000000000000000 --- a/old/debexpo/lib/form.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- -# -# form.py — Helpers for more complex formencode forms -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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 helper functions for dealing with the state in formencode form validation -schemas and validators. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' -__contributors__ = ['Christoph Haas'] - -import formencode -import logging -import pylons - -log = logging.getLogger(__name__) - - -class State(object): - """ - Trivial state class to be used by formencode validators to store - information. - - For example:: - - >>> c = State(one='foo', two='bar') - >>> c.one - 'foo' - >>> c.two - 'bar' - """ - def __init__(self, **kw): - for key in kw: - setattr(self, key, kw[key]) - - -def validate(schema, **state_kwargs): - """ - Validate a form against a schema. - - ``schema`` - Schema to validate against. - - ``state_kwargs`` - Arguments to the state. - """ - if state_kwargs: - state = State(**state_kwargs) - else: - state = None - - log.debug('Validating form against schema %s' % schema) - return schema.to_python(pylons.request.params, state) - - -def htmlfill(html, exception_error=None): - """ - Fill an HTML form with values when a formencode.Invalid exception is thrown. - - ``html`` - Form to fill. - - ``exception_error`` - Invalid exception to use when filling the form. - """ - return formencode.htmlfill.render( - form=html, - defaults=pylons.request.params, - errors=(exception_error and exception_error.unpack_errors()), - encoding=pylons.response.determine_charset() - ) diff --git a/old/debexpo/lib/utils.py b/old/debexpo/lib/utils.py deleted file mode 100644 index 30c78064769bdc8e8a6510566be19d1aed59f2bd..0000000000000000000000000000000000000000 --- a/old/debexpo/lib/utils.py +++ /dev/null @@ -1,158 +0,0 @@ -# -*- coding: utf-8 -*- -# -# utils.py — Debexpo utility functions -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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 misc utility functions. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import logging -import hashlib -import os - -from passlib.hash import bcrypt -from debexpo.model import meta - -log = logging.getLogger(__name__) - - -def parse_section(section): - """ - Works out the component and section from the "Section" field. - Sections like `python` or `libdevel` are in main. - Sections with a prefix, separated with a forward-slash also show the - component. - It returns a list of strings in the form [component, section]. - - For example, `non-free/python` has component `non-free` and section - `python`. - - ``section`` - Section name to parse. - """ - if '/' in section: - component, thesection = section.split('/', 1) - if component not in ("main", "contrib", "non-free"): - log.warning("Parsing weird component %s, assuming main" % component) - return ['main', section.replace('/', '_')] - else: - return [component, thesection] - else: - return ['main', section] - - -def get_package_dir(source): - """ - Returns the directory name where the package with name supplied as the first - argument should be installed. - - ``source`` - Source package name to use to work out directory name. - """ - if source.startswith('lib'): - return os.path.join(source[:4], source) - else: - return os.path.join(source[0], source) - - -def sha256sum(filename): - """ - Returns the sha256sum of a file specified. - - ``filename`` - File name of the file to sha256sum. - """ - return _checksum(filename, hashlib.sha256) - - -def md5sum(filename): - """ - Returns the md5sum of a file specified. - - ``filename`` - File name of the file to md5sum. - """ - return _checksum(filename, hashlib.md5) - - -def _checksum(filename, hash_function): - try: - f = file(filename, 'rb') - except Exception: - raise AttributeError('Failed to open file %s.' % filename) - - sum = hash_function() - while True: - chunk = f.read(10240) - if not chunk: - break - sum.update(chunk) - - f.close() - - return sum.hexdigest() - - -def random_hash(): - s = os.urandom(20) - return hash_it(s) - - -def hash_it(s): - if type(s) == unicode: - s = s.encode('utf-8') - return hashlib.md5(s).hexdigest() - - -def hash_password(s): - if type(s) == unicode: - s = s.encode('utf-8') - return bcrypt.hash(s) - - -def validate_password(user, password): - if user.password.startswith('$2'): - if not bcrypt.verify(password, user.password): - log.error('Incorrect password') - return False - - else: - # Code to handle old MD5 password - if user.password != hash_it(password): - log.error('Incorrect password') - return False - - user.password = hash_password(password) - meta.session.commit() - - return True diff --git a/old/debexpo/model/__init__.py b/old/debexpo/model/__init__.py deleted file mode 100644 index ed1b46d32c1812ff519930fb5b4f22170519f18d..0000000000000000000000000000000000000000 --- a/old/debexpo/model/__init__.py +++ /dev/null @@ -1,98 +0,0 @@ -# -*- coding: utf-8 -*- -# -# __init__.py — Model initialisation code -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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. - -""" -Model initialization functions. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -from sqlalchemy import orm - -from debexpo.model import meta - - -def init_model(engine): - """ - Initializes the model. - This should be called before using any of the tables or classes in the - model. - - ``engine`` - SQLAlchemy engine to bind to. - """ - - sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine) - - meta.engine = engine - meta.session = orm.scoped_session(sm) - - -def import_all_models(): - """ - Import all models from debexpo.models. This is useful when creating tables. - """ - - from debexpo.model import binary_packages, package_files, packages, \ - source_packages, user_metrics, package_comments, package_info, \ - package_versions, user_countries, users, package_subscriptions, \ - user_upload_key, password_reset, sponsor_metrics, data_store - - -class OrmObject(object): - """ - A base class for ORM mapped objects. - - This class was found and then altered for debexpo from - http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GenericOrmBaseClass - - Contributed by ltbarcly (Justin Van Winkle). - """ - def __init__(self, **kw): - if not hasattr(self, 'foreign'): - self.foreign = [] - - items = dir(self) - for key in kw: - if key in items or key in self.foreign: - setattr(self, key, kw[key]) - else: - raise AttributeError('Cannot set attribute which is ' + - 'not column in mapped table: %s' % (key,)) - - def __repr__(self): - attrs = [] - for key in self.__dict__: - if not key.startswith('_'): - attrs.append((key, getattr(self, key))) - return self.__class__.__name__ + '(' + ', ' \ - .join(x[0] + '=' + repr(x[1]) for x in attrs) + ')' diff --git a/old/debexpo/model/data/__init__.py b/old/debexpo/model/data/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/model/data/data_store_init.py b/old/debexpo/model/data/data_store_init.py deleted file mode 100644 index 5e979385c2e535dda297d46a1a2437ba8ab463af..0000000000000000000000000000000000000000 --- a/old/debexpo/model/data/data_store_init.py +++ /dev/null @@ -1,10 +0,0 @@ -from debexpo.model.data_store import DataStore - -DATA_STORE_INIT_OBJECTS = ( - DataStore(namespace='_remove_uploads_', - code='gmane.linux.debian.devel.changes.unstable', value='527427'), - DataStore(namespace='_remove_uploads_', - code='gmane.linux.debian.devel.changes.stable', value='10836'), - DataStore(namespace='_remove_uploads_', - code='gmane.linux.debian.backports.changes', value='37694'), - ) diff --git a/old/debexpo/model/meta.py b/old/debexpo/model/meta.py deleted file mode 100644 index a3a58c12f18e6ea4a3f52ec040fc1fe500a6e747..0000000000000000000000000000000000000000 --- a/old/debexpo/model/meta.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# -# meta.py — SQLAlchemy Metadata and Session object -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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. - -""" -SQLAlchemy MetaData and Session object. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -from sqlalchemy import MetaData - -__all__ = ['engine', 'metadata', 'session'] - -# SQLAlchemy database engine. Updated by model.init_model(). -engine = None - -# SQLAlchemy session manager. Updated by model.init_model(). -session = None - -# Global metadata. If you have multiple databases with overlapping table names, -# you'll need a metadata for each database. -metadata = MetaData() diff --git a/old/debexpo/model/package_files.py b/old/debexpo/model/package_files.py deleted file mode 100644 index bae80254dcdcd1750cfa32968888600416e950da..0000000000000000000000000000000000000000 --- a/old/debexpo/model/package_files.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- -# -# package_files.py — package_files table model -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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 package_files table model. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import sqlalchemy as sa -from sqlalchemy import orm -from sqlalchemy.orm import backref - -from debexpo.model import meta, OrmObject -from debexpo.model.binary_packages import BinaryPackage -from debexpo.model.source_packages import SourcePackage - -t_package_files = sa.Table( - 'package_files', meta.metadata, - sa.Column('id', sa.types.Integer, primary_key=True), - sa.Column('binary_package_id', sa.types.Integer, - sa.ForeignKey('binary_packages.id'), nullable=True), - sa.Column('source_package_id', sa.types.Integer, - sa.ForeignKey('source_packages.id'), nullable=True), - sa.Column('filename', sa.types.String(200), nullable=False), - sa.Column('size', sa.types.Integer, nullable=False), - sa.Column('md5sum', sa.types.String(32), nullable=False), - sa.Column('sha256sum', sa.types.String(64), nullable=False), - ) - - -class PackageFile(OrmObject): - foreign = ['binary_package', 'source_package'] - - -orm.mapper(PackageFile, t_package_files, properties={ - 'binary_package': orm.relation( - BinaryPackage, - backref=backref('package_files', cascade='all, delete-orphan')), - 'source_package': orm.relation( - SourcePackage, - backref=backref('package_files', cascade='all, delete-orphan')), -}) diff --git a/old/debexpo/model/source_packages.py b/old/debexpo/model/source_packages.py deleted file mode 100644 index 4e2294e810d6001e42074d18a4dc855ec9912bab..0000000000000000000000000000000000000000 --- a/old/debexpo/model/source_packages.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# -# source_packages.py — source_packages table model -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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 source_packages table model. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import sqlalchemy as sa -from sqlalchemy import orm -from sqlalchemy.orm import backref - -from debexpo.model import meta, OrmObject -from debexpo.model.package_versions import PackageVersion - -t_source_packages = sa.Table( - 'source_packages', meta.metadata, - sa.Column('id', sa.types.Integer, primary_key=True), - sa.Column('package_version_id', sa.types.Integer, - sa.ForeignKey('package_versions.id')), - ) - - -class SourcePackage(OrmObject): - foreign = ['package_version'] - - -orm.mapper(SourcePackage, t_source_packages, properties={ - 'package_version': orm.relation( - PackageVersion, - backref=backref('source_packages', cascade='all, delete-orphan')), -}) diff --git a/old/debexpo/plugins/removepackage.py b/old/debexpo/plugins/removepackage.py deleted file mode 100644 index 6a6e69ca8c296406188f42ad172da477d6dc5eb9..0000000000000000000000000000000000000000 --- a/old/debexpo/plugins/removepackage.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- coding: utf-8 -*- -# -# removepackage.py — removepackage plugin -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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 removepackage plugin. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import apt_pkg -import logging - -from debexpo.plugins import BasePlugin - -from debexpo.model import meta -from debexpo.model.packages import Package - -log = logging.getLogger(__name__) - - -class RemovePackagePlugin(BasePlugin): - - def test_remove_package(self): - """ - Removes a package that has been uploaded to Debian. - """ - source = self.changes['Source'] - log.debug('Checking whether package %s is in the repository' % source) - - package = meta.session.query(Package).filter_by(name=source).first() - - if package is None: - # The package is not in the repository. This will happen the most - # often. - log.debug('Package is not in the repository') - return - - # Initialise apt_pkg - apt_pkg.init() - - keep_package_versions = [] - for package_version in package.package_versions: - if apt_pkg.version_compare(self.changes['Version'], - package_version.version) < 0: - keep_package_versions.append(package_version.version) - - if len(keep_package_versions) == 0: - # Get rid of the whole package. - self._remove_package_versions(package.package_versions) - log.debug('Deleting package database entry: %s' % package.name) - meta.session.delete(package) - - else: - # Only remove certain package versions. - for package_version in package.package_versions: - if package_version not in keep_package_versions: - meta.session.delete(package_version) - - meta.session.commit() - - -plugin = RemovePackagePlugin diff --git a/old/debexpo/templates/email/changes_list.mako b/old/debexpo/templates/email/changes_list.mako deleted file mode 100644 index 230a374e75bf290a2f2d9f15e22099ed0dbb8b70..0000000000000000000000000000000000000000 --- a/old/debexpo/templates/email/changes_list.mako +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="/base.mako"/>To: ${ c.to } -Subject: Accepted ${ c.changes['Source'] } ${ c.changes['Version'] } (${ c.changes['Architecture'] }) - -${ c.changes_contents } - -Accepted: -% for fileinfo in c.changes['Files']: -${ fileinfo['name'] } - to ${ c.dest }/${ fileinfo['name'] } -% endfor diff --git a/old/debexpo/templates/email/importer_fail_admin.mako b/old/debexpo/templates/email/importer_fail_admin.mako deleted file mode 100644 index 49633d9203931d73114c854a91602d719033214f..0000000000000000000000000000000000000000 --- a/old/debexpo/templates/email/importer_fail_admin.mako +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="/base.mako"/>To: ${ c.to } -Subject: ${ _('Failure in importer') } - -${ _('''Hello, - -There was a failure in importing a package into debexpo. The problem -appears to be debexpo itself. The error message was:''') } - -${ c.message } - -${ _('This message can be found in the logs.') } - -${ _('Thanks,') } diff --git a/old/debexpo/templates/email/package_uploaded.mako b/old/debexpo/templates/email/package_uploaded.mako deleted file mode 100644 index d07ce2c7e89a62ef35c1d2f05102b5b3d20a6dbb..0000000000000000000000000000000000000000 --- a/old/debexpo/templates/email/package_uploaded.mako +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="/base.mako"/>To: ${ c.to } -Subject: ${ _('New %s package uploaded' % c.package) } - -${ _('%s %s has been uploaded to the archive by %s.' % (c.package, c.version, c.user.name)) } - -${ _('You can view information on the package by visiting:') } - -${ c.config['debexpo.server'] }/${ h.url('package', packagename=c.package) } - -${ _('You can change your subscription by visiting your user account settings.') } - -${ _('Thanks,') } diff --git a/old/debexpo/templates/error.mako b/old/debexpo/templates/error.mako deleted file mode 100644 index 984e64a22e4c8641b37eae9c0469f4d5cdd3b3c7..0000000000000000000000000000000000000000 --- a/old/debexpo/templates/error.mako +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="/base.mako"/> - -
-% if c.code == 401: -

${ _('Error') } 401 - ${ _('Authentication required') }

-

- ${ _('You need to be logged in to use this function.') } -

-% elif c.code == 403: -

${ _('Error') } 403 - ${ _('Not authorized') }

-

- ${ _('You do not have the permission to use this function.') } -

-% elif c.code == 404: -

${ _('Error') } 404 - ${ _('Page not found') }

-

- ${ _('The page you requested does not exist.') } -

-% else: -

${ _('Internal error %s') % c.code }

-

- ${ _('''An unexpected error occured in this application. - The administrator will get a detailed report about the - error situation. We appreciate if you give us more - information how this error situation happened.''') } -

-% endif - -

- ${ _('''If you have questions feel free to contact us - at %s.''' - % (config['debexpo.email'], config['debexpo.email'])) | n} -

-
diff --git a/old/debexpo/templates/upload/forbiden.mako b/old/debexpo/templates/upload/forbiden.mako deleted file mode 100644 index 84de4368afeea6f62101163522b87c482ab9876f..0000000000000000000000000000000000000000 --- a/old/debexpo/templates/upload/forbiden.mako +++ /dev/null @@ -1,3 +0,0 @@ -Failed to upload file: already present on the server. - -Please wait a few minutes for the importer to process the old files. diff --git a/old/debexpo/templates/user.mako b/old/debexpo/templates/user.mako deleted file mode 100644 index 3b2ff12f815e28f8307d7309f4c9731df1084401..0000000000000000000000000000000000000000 --- a/old/debexpo/templates/user.mako +++ /dev/null @@ -1,45 +0,0 @@ -% if config['debexpo.enable_experimental_code'] == 'true': - -

${ c.profile.name }

-

-% if c.profile.status == c.constants.USER_STATUS_DEVELOPER: - ${ _('Debian Developer') } -% elif c.profile.status == c.constants.USER_STATUS_MAINTAINER: - ${ _('Debian Maintainer') } -% else: - ${ _('Maintainer') } -% endif -

- -

User Information

- - - - - - -
-
-
Email:
-
${ c.profile.email }
-
IRC:
-
${ c.profile.ircnick }
-
Jabber:
-
${ c.profile.jabber }
-
-
-
-
Country
-
- % if c.profile.country_id != None: - ${ c.countries[c.profile.country_id] } - % else: - ${ _('Not specified') } - % endif -
-
GnuPG
-
${ c.profile.gpg_id }
-
-
- -% endif diff --git a/old/debexpo/tests/changes/synce-hal_0.1-1_source.changes b/old/debexpo/tests/changes/synce-hal_0.1-1_source.changes deleted file mode 100644 index 07ac1cb02924c97fa246254c831abbc03fc1e8fa..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/changes/synce-hal_0.1-1_source.changes +++ /dev/null @@ -1,40 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -Format: 1.8 -Date: Sun, 11 May 2008 00:48:39 +0100 -Source: synce-hal -Binary: synce-hal -Architecture: source -Version: 0.1-1 -Distribution: unstable -Urgency: low -Maintainer: Jonny Lamb -Changed-By: Jonny Lamb -Description: - synce-hal - Daemon to maintain a connection to Windows Mobile devices via hal -Closes: 480348 -Changes: - synce-hal (0.1-1) unstable; urgency=low - . - * Initial release. (Closes: #480348) -Checksums-Sha1: - 11504f11a52c89cba627c486032c61c4b9a765e6 1241 synce-hal_0.1-1.dsc - 0c5f77a391dba7d67190d2890de7c53730a9f7fe 357944 synce-hal_0.1.orig.tar.gz - d6d6caa243a55fb126e9b34083c8e1e8f53129c7 1589 synce-hal_0.1-1.diff.gz -Checksums-Sha256: - 2c74a1217fa4c1e0783b420fe6b93a9d780e30e173c20c4cbbd105f5ef6bdc96 1241 synce-hal_0.1-1.dsc - 6f3ee10fefb71593c936e55cd1b6aaa4cbef25926f63a4590fb3b78e101a217d 357944 synce-hal_0.1.orig.tar.gz - debbf49438cd2e8abc05f3bb400290cda9e34a655e54bfeb0baa8825c27a574d 1589 synce-hal_0.1-1.diff.gz -Files: - 41841e05ae3c14b07b4bb238a9a45718 1241 utils optional synce-hal_0.1-1.dsc - 77ea51506ac4ef2bdb81ba7f5c609d2b 357944 utils optional synce-hal_0.1.orig.tar.gz - 289e9bb4b5c1c6e4d5249d3bcedbd738 1589 utils optional synce-hal_0.1-1.diff.gz - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFIJjSywYr7ny4DlAIRAgwmAJ0UhWs2UZPuNucSs4/Z1ZohjJ23DwCfcbLC -7MOInp3Vljwf6xvqHkmdrQE= -=ThcH ------END PGP SIGNATURE----- diff --git a/old/debexpo/tests/cronjobs/__init__.py b/old/debexpo/tests/cronjobs/__init__.py deleted file mode 100644 index fe368f5fe54a10634e18ddb52ce4b7e33e5b2ae9..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/cronjobs/__init__.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -# -# py.template - template for new .py files -# -# This file is part of debexpo -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2019 Baptiste BEAUPLAT -# -# 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. - -__author__ = 'Baptiste BEAUPLAT' -__copyright__ = 'Copyright © 2019 Baptiste BEAUPLAT' -__license__ = 'MIT' - -from logging import getLogger - -from debexpo.tests import TestController -from debexpo.model import meta -from pylons import config - - -class TestCronjob(TestController): - def __init__(self, *args, **kargs): - TestController.__init__(self, *args, **kargs) - self.db = meta.session - self.config = config - self.log = getLogger(__name__) - - def setUp(self): - pass - - def tearDown(self): - pass - - def _setup_plugin(self, plugin, run_setup=True): - # Dynamically import plugin module - module = __import__('debexpo.cronjobs.{}'.format(plugin)) - module = getattr(module, 'cronjobs') - module = getattr(module, plugin) - self.assertTrue(module is not None) - - # Retrive class name - module = getattr(module, 'cronjob') - self.assertTrue(module is not None) - - # Instanciate the cronjob class - self.plugin = module(parent=self, config=self.config, log=self.log) - - if run_setup: - self.plugin.setup() - - def _invoke_plugin(self): - self.plugin.invoke() diff --git a/old/debexpo/tests/functional/__init__.py b/old/debexpo/tests/functional/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/tests/functional/test_debian.py b/old/debexpo/tests/functional/test_debian.py deleted file mode 100644 index 6d06f3c9243052db68c955e687713253b8d6abb1..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/functional/test_debian.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- -# -# test_debian.py — DebianController test cases -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyright © 2010 Jan Dittberner -# -# 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. - -""" -DebianController test cases. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner' -__license__ = 'MIT' - -import os - -from debexpo.tests import TestController, url -import pylons.test - - -class TestDebianController(TestController): - - def testFileNotFound(self): - """ - Tests whether the response to a GET request on a non-existent file is - 404. - """ - response = self.app.get(url(controller='debian', action='index', - filename='file_does_not_exist'), - expect_errors=True) - - self.assertEqual(response.status_int, 404) - - def testFileFound(self): - """ - Tests whether files that do exist in the repository are correctly - returned. - """ - file = os.path.join(pylons.test.pylonsapp.config['debexpo.repository'], - 'test_file') - - f = open(file, 'w') - f.write('test content') - f.close() - - response = self.app.get(url(controller='debian', action='index', - filename='test_file')) - - self.assertEqual(response.status_int, 200) - - self.assertEqual(response.normal_body, 'test content') - - # Remove temporary file. - if os.path.isfile(file): - os.remove(file) - - def testDscFileFound(self): - """ - Tests whether the correct content-type for dsc files is returned. - """ - file = os.path.join(pylons.test.pylonsapp.config['debexpo.repository'], - 'test.dsc') - - f = open(file, 'w') - f.write('test') - f.close() - - response = self.app.get(url(controller='debian', action='index', - filename='test.dsc')) - self.assertEqual(response.status_int, 200) - self.assertEqual(response.content_type, 'text/plain') - - # remove temporary file - if os.path.isfile(file): - os.remove(file) diff --git a/old/debexpo/tests/functional/test_index.py b/old/debexpo/tests/functional/test_index.py deleted file mode 100644 index 6300c5e4c2f9759bed36b067f417855ae6cfeb18..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/functional/test_index.py +++ /dev/null @@ -1,48 +0,0 @@ -from debexpo.tests import TestController -from pylons import url -import pylons.test - - -class TestIndexController(TestController): - def test_index(self): - # test a normal index page - testurl = url(controller='index', action='index') - pylons.test.pylonsapp.config['debexpo.sitename'] = 'test index' - response = self.app.get(testurl) - testtext = '

Welcome to test index

' - self.assertEquals(response.status_int, 200) - self.assertTrue(testtext in response) - - def test_contact(self): - response = self.app.get(url(controller='index', action='contact')) - testtext = '

Site contact

' - self.assertEquals(response.status_int, 200) - self.assertTrue(testtext in response) - - def test_qa(self): - response = self.app.get(url(controller='index', action='qa')) - testtext = '

Questions & Answers

' - self.assertEquals(response.status_int, 200) - self.assertTrue(testtext in response) - - def test_intro_reviewer(self): - response = self.app.get(url(controller='index', - action='intro-reviewers')) - testtext = '

Package reviews

' - self.assertEquals(response.status_int, 200) - self.assertTrue(testtext in response) - - def test_intro_maintainers(self): - response = self.app.get(url(controller='index', - action='intro-maintainers')) - testtext = "{}".format('

Introduction for maintainers: How will my', - ' package get into Debian

') - self.assertEquals(response.status_int, 200) - self.assertTrue(testtext in response) - - def test_intro_sponsors(self): - testurl = url('sponsors') - response = self.app.get(testurl) - testtext = '

The sponsoring process

' - self.assertEquals(response.status_int, 200) - self.assertTrue(testtext in response) diff --git a/old/debexpo/tests/gpg/pubring.gpg b/old/debexpo/tests/gpg/pubring.gpg deleted file mode 100644 index 68eee7ef28eec97afd3612e7490ebef88c3797c2..0000000000000000000000000000000000000000 Binary files a/old/debexpo/tests/gpg/pubring.gpg and /dev/null differ diff --git a/old/debexpo/tests/test_changes.py b/old/debexpo/tests/test_changes.py deleted file mode 100644 index c2f9bd4f1dda8462b198f2b576017c506cb0b356..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/test_changes.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- -# -# test_changes.py — Changes class test cases -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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. - -""" -Changes class test cases. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import os -from unittest import TestCase - -from debexpo.lib.changes import Changes - - -class TestChangesController(TestCase): - - def __init__(self, methodName): - """ - Class constructor. Starts a Changes class for use in other tests. - """ - TestCase.__init__(self, methodName) - - self.changes = Changes( - filename='debexpo/tests/changes/synce-hal_0.1-1_source.changes') - - def testInitialize(self): - """ - Tests whether the two ways of creating a Changes object output the same - result. - """ - f = open(os.path.dirname(__file__) + - '/changes/synce-hal_0.1-1_source.changes') - contents = f.read() - f.close() - - a = Changes(filename=os.path.dirname(__file__) + - '/changes/synce-hal_0.1-1_source.changes') - b = Changes(string=contents) - - self.assertEqual(a['Source'], b['Source']) - - def testGetitem(self): - """ - Tests Changes.__getitem__. - """ - self.assertEqual(self.changes['Source'], 'synce-hal') - self.assertEqual(self.changes['Urgency'], 'low') - - def testGetFiles(self): - """ - Tests Changes.get_files. - """ - self.assertEqual(self.changes.get_files(), - ['synce-hal_0.1-1.dsc', - 'synce-hal_0.1.orig.tar.gz', - 'synce-hal_0.1-1.diff.gz']) - - def testGetComponent(self): - """ - Tests Changes.get_component(). - """ - self.assertEqual(self.changes.get_component(), 'main') - - def testGetPriority(self): - """ - Tests Changes.get_priority(). - """ - self.assertEqual(self.changes.get_priority(), 'optional') - - def testGetDsc(self): - """ - Tests Changes.get_dsc(). - """ - self.assertEqual(self.changes.get_dsc(), 'synce-hal_0.1-1.dsc') diff --git a/old/debexpo/tests/test_filesystem.py b/old/debexpo/tests/test_filesystem.py deleted file mode 100644 index 1b142427606c297e5b0382f4886a7ed152ba92d7..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/test_filesystem.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -# -# test_filesystem.py — CheckFiles class test cases -# -# This file is part of debexpo - https://alioth.debian.org/projects/debexpo/ -# -# Copyright © 2012 Nicolas Dandrimont -# -# 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. - -""" -CheckFiles class test cases. -""" - -__author__ = 'Nicolas Dandrimont' -__copyright__ = 'Copyright © 2012 Nicolas Dandrimont' -__license__ = 'MIT' - -from unittest import TestCase - -from debexpo.lib.filesystem import CheckFiles - - -class TestCheckFilesController(TestCase): - - def setUp(self): - """ - Setup the environment for tests - """ - self.checkfiles = CheckFiles() - - def testAllowedUpload(self): - """ - Tests CheckFiles.allowed_upload - """ - t = self.checkfiles.allowed_upload - - self.assertTrue(t('foo_version.orig.tar.gz')) - self.assertTrue(t('foo_version.orig.tar.xz.asc')) - self.assertTrue(t('foo_version.tar.gz')) - self.assertTrue(t('foo_version.changes')) - self.assertTrue(t('foo_version_arch.buildinfo')) - self.assertTrue(t('foo_version.dsc')) - self.assertTrue(t('foo_version.deb')) - self.assertTrue(t('foo_version.diff.gz')) - - self.assertFalse(t('foo_version.etc')) diff --git a/old/debexpo/tests/test_models.py b/old/debexpo/tests/test_models.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/old/debexpo/tests/test_utils.py b/old/debexpo/tests/test_utils.py deleted file mode 100644 index f9cd1b3646f23a79d8637434208639b68dca909c..0000000000000000000000000000000000000000 --- a/old/debexpo/tests/test_utils.py +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: utf-8 -*- -# -# test_utils.py — Test cases for debexpo.lib.utils -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# -# 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. - -""" -Test cases for debexpo.lib.utils. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb' -__license__ = 'MIT' - -import os -from unittest import TestCase - -from debexpo.lib.utils import parse_section, get_package_dir, md5sum -from debexpo.lib.filesystem import CheckFiles - - -class TestUtilsController(TestCase): - - def testAllowedUpload(self): - """ - Tests debexpo.lib.utils.allowed_upload. - """ - t = CheckFiles().allowed_upload - - self.assertTrue(t('foo_version.orig.tar.gz')) - self.assertTrue(t('foo_version.tar.gz')) - self.assertTrue(t('foo_version.changes')) - self.assertTrue(t('foo_version.dsc')) - self.assertTrue(t('foo_version.deb')) - self.assertTrue(t('foo_version.diff.gz')) - - self.assertFalse(t('foo_version.etc')) - - def testParseSection(self): - """ - Tests debexpo.lib.utils.parse_section. - """ - t = parse_section - - self.assertEqual(t('section'), ['main', 'section']) - self.assertEqual(t('contrib/section'), ['contrib', 'section']) - - def testGetPackageDir(self): - """ - Tests debexpo.lib.utils.get_package_dir. - """ - t = get_package_dir - - self.assertEqual(t('foo'), 'f/foo') - self.assertEqual(t('libfoo'), 'libf/libfoo') - - def testMd5sum(self): - """ - Tests debexpo.lib.utils.md5sum. - """ - self.assertEqual(md5sum(os.path.dirname(__file__) + - '/changes/synce-hal_0.1-1_source.changes'), - 'fbb0b9c81f8a4fa9b8e3b789cf3b5220') diff --git a/old/debexpo/websetup.py b/old/debexpo/websetup.py deleted file mode 100644 index 1b5cc7dd1212703a77c3eedeb44dd20523b815dd..0000000000000000000000000000000000000000 --- a/old/debexpo/websetup.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -# -# websetup.py — Setup the debexpo application -# -# This file is part of debexpo - -# https://salsa.debian.org/mentors.debian.net-team/debexpo -# -# Copyright © 2008 Jonny Lamb -# Copyright © 2010 Jan Dittberner -# -# 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. - -""" -Setup the debexpo application. -""" - -__author__ = 'Jonny Lamb' -__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner' -__license__ = 'MIT' - -import logging -import os - -from paste.deploy import appconfig -import pylons.test - -from debexpo.config.environment import load_environment -from debexpo.model import import_all_models -from debexpo.model import meta - -import debexpo.model.data_store -import debexpo.model.user_countries - -log = logging.getLogger(__name__) - - -def setup_config(command, filename, section, vars): - """ - Run when debexpo is being set up, when ``paster setup-app`` is executed and - shouldn't be called directly. - - ``command`` - Pointer to the setup function. - - ``filename`` - File used for configuration. E.g. `development.ini`. - - ``section`` - Section in the config file; usually `app:main`. - - ``vars`` - Extra variables passed to the setup. - """ - - conf = appconfig('config:' + filename) - - if not pylons.test.pylonsapp: - config = load_environment(conf.global_conf, conf.local_conf) - else: - config = pylons.test.pylonsapp.config - - log.info('Creating database tables') - import_all_models() - meta.metadata.create_all(bind=meta.engine) - log.info('Successfully setup database tables') - - if not os.path.isdir(config['debexpo.upload.incoming']): - log.info('Creating incoming directory') - os.makedirs(config['debexpo.upload.incoming']) - os.makedirs(os.path.join(config['debexpo.upload.incoming'], 'pub')) - else: - log.info('Incoming directory already exists') - - if not os.path.isdir(config['debexpo.repository']): - log.info('Creating repository directory') - os.makedirs(config['debexpo.repository']) - else: - log.info('Repository directory already exists') - - log.info('Making sure all ISO countries are in the database') - debexpo.model.user_countries.create_iso_countries() - - log.info('Making sure all tags do exist') - debexpo.model.sponsor_metrics.create_tags() - - log.info('Import data store pre-existing data') - debexpo.model.data_store.fill_data_store() diff --git a/old/development.ini b/old/development.ini deleted file mode 100644 index 25fe2dfe59f2d81d8b07681f2a8c8af7725324cd..0000000000000000000000000000000000000000 --- a/old/development.ini +++ /dev/null @@ -1,158 +0,0 @@ -# -# debexpo - Pylons development environment configuration -# -# The %(here)s variable will be replaced with the parent directory of this file -# -[DEFAULT] -debug = true -# Uncomment and replace with the address which should receive any error reports -#email_to = you@yourdomain.com -smtp_server = localhost -smtp_username = -smtp_password = -error_email_from = support@mentors.debian.net - -[server:main] -use = egg:Paste#http -host = 127.0.0.1 -port = 5000 - -[app:main] -use = egg:debexpo -full_stack = true -cache_dir = %(here)s/data -beaker.session.key = debexpo -beaker.session.secret = somesecret -sqlalchemy.url = sqlite:///%(here)s/debexpo.db - -# If you'd like to fine-tune the individual locations of the cache data dirs -# for the Cache data, or the Session saves, un-comment the desired settings -# here: -#beaker.cache.data_dir = %(here)s/data/cache -#beaker.session.data_dir = %(here)s/data/sessions - -# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* -# Debug mode will enable the interactive debugging tool, allowing ANYONE to -# execute malicious code after an exception is raised. -#set debug = false - -# Directory name to add incoming uploaded files into -debexpo.upload.incoming = /tmp/debexpo/incoming/ - -# Directory name to store accepted uploaded files -debexpo.repository = /tmp/debexpo/files/ - -# Path to importer script -debexpo.importer = %(here)s/bin/debexpo_importer.py - -# Whether to let debexpo handle the /debian/ directory -debexpo.handle_debian = true - -# Site title (e.g. short name) -debexpo.sitetitle = Mentors - -# Site name -debexpo.sitename = debexpo - -# Site tagline -debexpo.tagline = Helps you get your packages into Debian - -# Site logo -debexpo.logo = /debexpo-logo.png - -# Site support email -debexpo.email = support@mentors.debian.net - -# Generic bounce email -debexpo.bounce_email = bounce@mentors.debian.net - -# Whether to show Debian-specific options -debexpo.debian_specific = true - -# What post-upload plugins to run, in this order -debexpo.plugins.post_upload = getorigtarball notuploader - -# What qa plugins to run, in this order -debexpo.plugins.qa = distribution lintian native maintaineremail watchfile closedbugs controlfields diffclean buildsystem debianqa rfstemplate - -# What plugins to run when the package is uploaded to Debian, in this order -debexpo.plugins.post_upload_to_debian = removepackage - -# What plugins to run when a package is successfully uploaded, in this order -debexpo.plugins.post_successful_upload = changeslist - -# Extra plugin directory -debexpo.plugindir = /tmp - -# Location of the nearest Debian mirror -debexpo.debian_mirror = http://ftp.uk.debian.org/debian - -# Email address to send package accepts to -debexpo.changes_list = changes@example.com - -# Server debexpo is being run on including http:// and excluding trailing slash -debexpo.server = http://localhost:5000 - -# Path to the gpg binary -debexpo.gpg_path = /usr/bin/gpg - -# Path to the mentors keyring -debexpo.gpg_keyring = %(here)s/dev-keyring - -# Minimum key strength required for the key to be acceptable in Debian keyring. -debexpo.gpg_minkeystrength = 2048 - -# Cronjobs to run by the Worker task -debexpo.cronjobs = removeolduploads importuploads cleanupaccounts - -# Validation token validity (in days) -token_expiration_days = 7 - -# Extra plugin directory -debexpo.cronjobdir = /tmp - -# Debexpo cronjob Worker iteration delay. -# The worker will sleep that amount of seconds after each run -debexpo.cronjob_delay = 60 - -# NNTP server to connect to fetch mailing list comments/changes -debexpo.nntp_server = news.gmane.org - -# Enable experimental and/or broken code -debexpo.enable_experimental_code = true - -# Enable git storage -debexpo.gitstorage.enabled = true - -[alembic] -# path to migration scripts -script_location = %(here)s/contrib/database/ - -# Logging configuration -[loggers] -keys = root, debexpo - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console - -[logger_debexpo] -level = DEBUG -handlers = console -qualname = debexpo - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s -datefmt = %H:%M:%S diff --git a/old/docs/Makefile b/old/docs/Makefile deleted file mode 100644 index e9969977523b35a81792f7afc31faa0af1cdcd05..0000000000000000000000000000000000000000 --- a/old/docs/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d .build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html web pickle htmlhelp latex changes linkcheck - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " pickle to make pickle files (usable by e.g. sphinx-web)" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " changes to make an overview over all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - -clean: - -rm -rf .build/* - -html: - mkdir -p .build/html .build/doctrees - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) .build/html - @echo - @echo "Build finished. The HTML pages are in .build/html." - -pickle: - mkdir -p .build/pickle .build/doctrees - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) .build/pickle - @echo - @echo "Build finished; now you can process the pickle files or run" - @echo " sphinx-web .build/pickle" - @echo "to start the sphinx-web server." - -web: pickle - -htmlhelp: - mkdir -p .build/htmlhelp .build/doctrees - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) .build/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in .build/htmlhelp." - -latex: - mkdir -p .build/latex .build/doctrees - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) .build/latex - @echo - @echo "Build finished; the LaTeX files are in .build/latex." - @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ - "run these through (pdf)latex." - -changes: - mkdir -p .build/changes .build/doctrees - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) .build/changes - @echo - @echo "The overview file is in .build/changes." - -linkcheck: - mkdir -p .build/linkcheck .build/doctrees - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) .build/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in .build/linkcheck/output.txt." diff --git a/old/docs/conf.py b/old/docs/conf.py deleted file mode 100644 index 72468d4abd644cbee4f63ef28453d09943621700..0000000000000000000000000000000000000000 --- a/old/docs/conf.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: utf-8 -*- -# -# debexpo documentation build configuration file, created by -# sphinx-quickstart on Sun Jun 1 15:36:31 2008. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# The contents of this file are pickled, so don't put values in the namespace -# that aren't pickleable (module imports are okay, they're removed automatically). -# -# All configuration values have a default value; values that are commented out -# serve to show the default value. - -import sys, os - -# If your extensions are in another directory, add it here. If the directory -# is relative to the documentation root, use os.path.abspath to make it -# absolute, like shown here. -sys.path.append(os.path.abspath('..')) - -# General configuration -# --------------------- - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc'] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['.templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# General substitutions. -project = 'debexpo' -copyright = '2008-2019 Debexpo contributors' - -# The default replacements for |version| and |release|, also used in various -# other places throughout the built documents. -# -# The short X.Y version. -version = '2.2' -# The full version, including alpha/beta/rc tags. -release = '2.2' - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -today_fmt = '%B %d, %Y' - -# List of documents that shouldn't be included in the build. -#unused_docs = [] - -# List of directories, relative to source directories, that shouldn't be searched -# for source files. -#exclude_dirs = [] - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - - -# Options for HTML output -# ----------------------- - -# The style sheet to use for HTML and HTML Help pages. A file of that name -# must exist either in Sphinx' static/ path, or in one of the custom paths -# given in html_static_path. -html_style = 'default.css' - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# The name of an image file (within the static path) to place at the top of -# the sidebar. -#html_logo = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_use_modindex = True - -# If true, the reST sources are included in the HTML build as _sources/. -#html_copy_source = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = '' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'debexpodoc' - - -# Options for LaTeX output -# ------------------------ - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, document class [howto/manual]). -latex_documents = [ - ('index', 'debexpo.tex', 'debexpo Documentation', 'Jonny Lamb', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_use_modindex = True diff --git a/old/live.ini b/old/live.ini deleted file mode 100644 index 5bc8ad7ee9d44f002bad06bce072d5bc7272be83..0000000000000000000000000000000000000000 --- a/old/live.ini +++ /dev/null @@ -1,164 +0,0 @@ -# -# debexpo - Pylons development environment configuration -# -# The %(here)s variable will be replaced with the parent directory of this file -# -[DEFAULT] -debug = false -# Uncomment and replace with the address which should receive any error reports -email_to = support@mentors.debian.net -smtp_server = localhost -smtp_username = -smtp_password = -error_email_from = support@mentors.debian.net - -[server:main] -use = egg:Paste#http -host = 0.0.0.0 -port = 5000 - -[app:main] -use = egg:debexpo -full_stack = true -cache_dir = %(here)s/data -beaker.session.key = debexpo_live -beaker.session.secret = FIXME_SECRET -sqlalchemy.url = FIXME_SECRET - -# If you'd like to fine-tune the individual locations of the cache data dirs -# for the Cache data, or the Session saves, un-comment the desired settings -# here: -#beaker.cache.data_dir = %(here)s/data/cache -#beaker.session.data_dir = %(here)s/data/sessions - -# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* -# Debug mode will enable the interactive debugging tool, allowing ANYONE to -# execute malicious code after an exception is raised. -set debug = false - -# Directory name to add incoming uploaded files into -debexpo.upload.incoming = /var/cache/debexpo/incoming/ - -# Directory name to store accepted uploaded files -debexpo.repository = /var/cache/debexpo/uploaded/ - -# Path to importer script -debexpo.importer = %(here)s/bin/debexpo_importer.py - -# Whether to let debexpo handle the /debian/ directory -debexpo.handle_debian = true - -# Site title (e.g. short name) -debexpo.sitetitle = Mentors - -# Site name -debexpo.sitename = mentors.debian.net - -# Site tagline -debexpo.tagline = Helps you get your packages into Debian - -# Site logo -debexpo.logo = /debexpo-logo.png - -# Site support email -debexpo.email = support@mentors.debian.net - -# Generic bounce email -debexpo.bounce_email = bounce@mentors.debian.net - -# Whether to show Debian-specific options -debexpo.debian_specific = true - -# What post-upload plugins to run, in this order -debexpo.plugins.post_upload = getorigtarball - -# What qa plugins to run, in this order -debexpo.plugins.qa = distribution lintian native maintaineremail watchfile closedbugs controlfields diffclean buildsystem debianqa rfstemplate - -# What plugins to run when the package is uploaded to Debian, in this order -debexpo.plugins.post_upload_to_debian = removepackage - -# What plugins to run when a package is successfully uploaded, in this order -debexpo.plugins.post_successful_upload = changeslist - -# Extra plugin directory -debexpo.plugindir = /tmp - -# Location of the nearest Debian mirror -debexpo.debian_mirror = http://ftp.uk.debian.org/debian - -# Email address to send package accepts to -debexpo.changes_list = debexpo@asheesh.org - -# Server debexpo is being run on including http:// and excluding trailing slash -debexpo.server = https://mentors.debian.net - -# Path to the gpg binary -debexpo.gpg_path = /usr/bin/gpg - -# Path to the mentors keyring -debexpo.gpg_keyring = /home/expo/mentors-keyring.gpg - -# Minimum key strength required for the key to be acceptable in Debian keyring. -debexpo.gpg_minkeystrength = 2048 - -# Cronjobs to run by the Worker task -debexpo.cronjobs = removeolduploads importuploads cleanupaccounts - -# Validation token validity (in days) -token_expiration_days = 7 - -# Extra plugin directory -debexpo.cronjobdir = /tmp - -# Debexpo cronjob Worker iteration delay. -# The worker will sleep that amount of seconds after each run -debexpo.cronjob_delay = 60 - -# NNTP server to connect to fetch mailing list comments/changes -debexpo.nntp_server = news.gmane.org - -# Enable experimental and/or broken code -debexpo.enable_experimental_code = false - -# Enable git storage -debexpo.gitstorage.enabled = true - -[alembic] -# path to migration scripts -script_location = %(here)s/contrib/database/ - -# Logging configuration -[loggers] -keys = root, debexpo - -[handlers] -keys = console, accesslog - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console, accesslog - -[logger_debexpo] -level = DEBUG -handlers = console, accesslog -qualname = debexpo - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[handler_accesslog] -class = FileHandler -args = ('/var/log/debexpo/expo.log','a') -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s -datefmt = %Y-%m-%d %z %H:%M:%S diff --git a/old/live.wsgi b/old/live.wsgi deleted file mode 100644 index d13ff484984c04aab6fd30781c803c5ffb66eef5..0000000000000000000000000000000000000000 --- a/old/live.wsgi +++ /dev/null @@ -1,13 +0,0 @@ -#! /usr/bin/env python - -import os -import logging.config -from paste.deploy import loadapp - -# "cd" into the code root -os.chdir('/var/www/debexpo') - -logging.config.fileConfig('/var/www/debexpo/live.ini') - -# Load the Pylons application -application = loadapp('config:/var/www/debexpo/live.ini') diff --git a/old/setup.cfg b/old/setup.cfg deleted file mode 100644 index e32d9ef2b1d26d4bc40390afe3086ee3840b3577..0000000000000000000000000000000000000000 --- a/old/setup.cfg +++ /dev/null @@ -1,69 +0,0 @@ -[egg_info] -tag_build = dev -tag_svn_revision = true - -[easy_install] -find_links = http://www.pylonshq.com/download/ - -[pudge] -theme = pythonpaste.org - -# Add extra doc files here with spaces between them -docs = docs/index.txt - -# Doc Settings -doc_base = docs/ -dest = docs/html - -# Add extra modules here separated with commas -modules = debexpo -title = Debexpo -organization = Pylons - -# Highlight code-block sections with Pygments -highlighter = pygments - -# Optionally add extra links -#organization_url = http://pylonshq.com/ -#trac_url = http://pylonshq.com/project -settings = no_about=true - -# Optionally add extra settings -# link1=/community/ Community -# link2=/download/ Download - -[publish] -doc-dir=docs/html -make-dirs=1 - -[nosetests] -with-pylons = test.ini -cover-package = debexpo -verbosity = 3 - -# Babel configuration -[compile_catalog] -domain = debexpo -directory = debexpo/i18n -statistics = true - -[extract_messages] -add_comments = TRANSLATORS: -output_file = debexpo/i18n/debexpo.pot -width = 80 - -[init_catalog] -domain = debexpo -input_file = debexpo/i18n/debexpo.pot -output_dir = debexpo/i18n - -[update_catalog] -domain = debexpo -input_file = debexpo/i18n/debexpo.pot -output_dir = debexpo/i18n -previous = true - -[flake8] -max_line_length = 80 -exclude = data/*, docs/*, ./debexpo/model/__init__.py, ./debexpo/lib/helpers.py, ./debexpo/lib/base.py -builtins = file, unicode, reduce diff --git a/old/test.ini b/old/test.ini deleted file mode 100644 index 6781405df753cd4fdda2ccd519b53de127cbf8ad..0000000000000000000000000000000000000000 --- a/old/test.ini +++ /dev/null @@ -1,161 +0,0 @@ -# -# debexpo - Pylons testing environment configuration -# -# The %(here)s variable will be replaced with the parent directory of this file -# -[DEFAULT] -debug = true -# Uncomment and replace with the address which should receive any error reports -#email_to = you@yourdomain.com -smtp_server = localhost -smtp_username = -smtp_password = -error_email_from = support@mentors.debian.net - -[server:main] -use = egg:Paste#http -host = 127.0.0.1 -port = 5000 - -[app:main] -use = egg:debexpo -full_stack = true -cache_dir = %(here)s/data -beaker.session.key = debexpo -beaker.session.secret = somesecret -sqlalchemy.url = sqlite:// - -# If you'd like to fine-tune the individual locations of the cache data dirs -# for the Cache data, or the Session saves, un-comment the desired settings -# here: -#beaker.cache.data_dir = %(here)s/data/cache -#beaker.session.data_dir = %(here)s/data/sessions - -# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* -# Debug mode will enable the interactive debugging tool, allowing ANYONE to -# execute malicious code after an exception is raised. -#set debug = false - -# Directory name to add incoming uploaded files into -debexpo.upload.incoming = /tmp/debexpo/incoming/ - -# Directory name to store accepted uploaded files -debexpo.repository = /tmp/debexpo/files/ - -# Path to importer script -debexpo.importer = %(here)s/bin/debexpo_importer.py - -# Whether to let debexpo handle the /debian/ directory -debexpo.handle_debian = true - -# Site title (e.g. short name) -debexpo.sitetitle = Mentors - -# Site name -debexpo.sitename = debexpo - -# Site tagline -debexpo.tagline = Helps you get your packages into Debian - -# Site logo -debexpo.logo = /debexpo-logo.png - -# Site support email -debexpo.email = support@mentors.debian.net - -# Generic bounce email -debexpo.bounce_email = bounce@mentors.debian.net - -# Whether to show Debian-specific options -debexpo.debian_specific = true - -# What post-upload plugins to run, in this order -debexpo.plugins.post_upload = getorigtarball notuploader - -# What qa plugins to run, in this order -debexpo.plugins.qa = distribution lintian native maintaineremail watchfile closedbugs controlfields diffclean buildsystem debianqa rfstemplate - -# What plugins to run when the package is uploaded to Debian, in this order -debexpo.plugins.post_upload_to_debian = removepackage - -# What plugins to run when a package is successfully uploaded, in this order -debexpo.plugins.post_successful_upload = changeslist - -# Extra plugin directory -debexpo.plugindir = /tmp - -# Location of the nearest Debian mirror -debexpo.debian_mirror = http://ftp.uk.debian.org/debian - -# Email address to send package accepts to -debexpo.changes_list = changes@example.com - -# Server debexpo is being run on including http:// and excluding trailing slash -debexpo.server = http://localhost:5000 - -# Path to the gpg binary -debexpo.gpg_path = /usr/bin/gpg - -# Path to the mentors keyring -debexpo.gpg_keyring = %(here)s/test-debexpo-keyring.gpg - -# Minimum key strength required for the key to be acceptable in Debian keyring. -debexpo.gpg_minkeystrength = 2048 - -# Cronjobs to run by the Worker task -debexpo.cronjobs = removeolduploads importuploads cleanupaccounts - -# Validation token validity (in days) -token_expiration_days = 7 - -# Extra plugin directory -debexpo.cronjobdir = /tmp - -# Debexpo cronjob Worker iteration delay. -# The worker will sleep that amount of seconds after each run -debexpo.cronjob_delay = 60 - -# NNTP server to connect to fetch mailing list comments/changes -debexpo.nntp_server = news.gmane.org - -# Enable experimental and/or broken code -debexpo.enable_experimental_code = true - -# In testing mode, do not use a real smtp -debexpo.testsmtp = /tmp/debexpo-testing.mbox - -# Enable git storage -debexpo.gitstorage.enabled = true - -[alembic] -# path to migration scripts -script_location = %(here)s/contrib/database/ - -# Logging configuration -[loggers] -keys = root, debexpo - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console - -[logger_debexpo] -level = DEBUG -handlers = console -qualname = debexpo - -[handler_console] -class = StreamHandler -args = (sys.stdout,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s -datefmt = %H:%M:%S diff --git a/tests/functional/importer/__init__.py b/tests/functional/importer/__init__.py index ced9190cf0f2504ac3c35e10fa60007255be75dd..a10f27c42a5753bf4e5e5b6bc50d681782e78ca2 100644 --- a/tests/functional/importer/__init__.py +++ b/tests/functional/importer/__init__.py @@ -105,11 +105,14 @@ class TestImporterController(TestController): def _cleanup_mailbox(self): mail.outbox = [] - def _upload_package(self, package_dir): + def _upload_package(self, package_dir, sub_dir=None): """Copy a directory content to incoming queue""" # copytree dst dir must not exist upload_dir = self.spool.get_queue_dir('incoming') + if sub_dir: + upload_dir = join(upload_dir, sub_dir) + if isdir(upload_dir): rmtree(upload_dir) copytree(package_dir, upload_dir) @@ -149,21 +152,22 @@ class TestImporterController(TestController): remove_uploads(uploads) def import_source_package(self, package_dir, skip_gpg=False, - skip_email=False, base_dir=None): + skip_email=False, base_dir=None, sub_dir=None): source_package = TestSourcePackage(package_dir, base_dir) source_package.build() self._run_importer(source_package.get_package_dir(), skip_gpg=skip_gpg, - skip_email=skip_email) + skip_email=skip_email, sub_dir=sub_dir) def import_package(self, package_dir): self._run_importer(join(self.data_dir, package_dir)) - def _run_importer(self, package_dir, skip_gpg=False, skip_email=False): + def _run_importer(self, package_dir, skip_gpg=False, skip_email=False, + sub_dir=None): """Run debexpo importer on package_dir/*.changes""" # Copy uplod files to incomming queue self.assertTrue(isdir(package_dir)) - self._upload_package(package_dir) + self._upload_package(package_dir, sub_dir) # Run the importer on change file with self.settings(REPOSITORY=self.repository): diff --git a/tests/functional/importer/test_importer.py b/tests/functional/importer/test_importer.py index 4cb43e068c8a95a2ee9df3e6b4946dce9604db69..0d0d7b8c09a8cd5274fb1f6278838dd8124d6430 100644 --- a/tests/functional/importer/test_importer.py +++ b/tests/functional/importer/test_importer.py @@ -338,6 +338,22 @@ r1JREXlgQRuRdd5ZWSvIxKaKGVbYCw== # self.assert_package_count('hello', '1.0-1', 1) # self.assert_package_in_repo('hello', '1.0-1') + def test_import_recursive_pool(self): + self.import_source_package('hello', sub_dir='sub') + self.assert_importer_succeeded() + self.assert_package_count('hello', '1.0-1', 1) + self.assert_package_in_repo('hello', '1.0-1') + + def test_import_no_network_access(self): + with self.settings(DEBIAN_ARCHIVE_URL='http://no-nxdomain', + TRACKER_URL='http://no-nxdomain', + FTP_MASTER_NEW_PACKAGES_URL='http://no-nxdomain', + FTP_MASTER_API_URL='http://no-nxdomain'): + self.import_source_package('hello', sub_dir='sub') + self.assert_importer_succeeded() + self.assert_package_count('hello', '1.0-1', 1) + self.assert_package_in_repo('hello', '1.0-1') + @override_settings() def test_import_package_hello(self): del settings.GIT_STORAGE