From ea278eeb351defdf66eee1c00b4924e78067e09c Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Thu, 25 Dec 2014 21:20:16 +0100 Subject: [PATCH] implement and document GVAFileException --- docs/code.rst | 6 ++++++ docs/conf.py | 5 +++++ gvafile/gvafile/exceptions.py | 12 ++++++++++++ gvafile/osusers/tasks.py | 5 +++-- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gvafile/gvafile/exceptions.py diff --git a/docs/code.rst b/docs/code.rst index 2b273a7..227508a 100644 --- a/docs/code.rst +++ b/docs/code.rst @@ -29,6 +29,12 @@ The project module :py:mod:`gvafile` .. automodule:: gvafile.urls +:py:mod:`gvafile.exceptions` +---------------------------- + +.. automodule:: gvafile.exceptions + + :py:mod:`gvafile.wsgi` ---------------------- diff --git a/docs/conf.py b/docs/conf.py index dc4f85e..daa0c8d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,6 +14,7 @@ import sys import os +import django # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -22,6 +23,10 @@ sys.path.insert(0, os.path.abspath(os.path.join('..', 'gvafile'))) os.environ['GVAFILE_ALLOWED_HOSTS'] = 'localhost' os.environ['GVAFILE_SERVER_EMAIL'] = 'root@localhost' +os.environ['GVAFILE_SFTP_DIRECTORY'] = '/home/www' +os.environ['GVAFILE_MAIL_DIRECTORY'] = '/home/mail' + +django.setup() # -- General configuration ----------------------------------------------------- diff --git a/gvafile/gvafile/exceptions.py b/gvafile/gvafile/exceptions.py new file mode 100644 index 0000000..06f6cfb --- /dev/null +++ b/gvafile/gvafile/exceptions.py @@ -0,0 +1,12 @@ +""" +This module defines exceptions for gvafile. + +""" +from __future__ import unicode_literals + + +class GVAFileException(Exception): + """ + Generic Exception class for gvafile. + + """ diff --git a/gvafile/osusers/tasks.py b/gvafile/osusers/tasks.py index 34b09e4..65c8091 100644 --- a/gvafile/osusers/tasks.py +++ b/gvafile/osusers/tasks.py @@ -13,7 +13,8 @@ from django.conf import settings from celery import shared_task from celery.utils.log import get_task_logger -from celery.exceptions import Reject + +from gvafile.exceptions import GVAFileException _logger = get_task_logger(__name__) @@ -60,7 +61,7 @@ def setup_file_sftp_userdir(username): except subprocess.CalledProcessError: _logger.exception( 'could not create SFTP directory for user %s', username) - raise Exception( + raise GVAFileException( "could not create SFTP directory for user %s" % username) return sftp_directory