Skip to content

Commit

Permalink
Move ViewVCException from debug module to common
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpilato committed Apr 7, 2020
1 parent f7fd7a3 commit 1fe4ecc
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 109 deletions.
11 changes: 11 additions & 0 deletions lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,14 @@ def merge(self, template_data):

assert isinstance(template_data, TemplateData)
self._items.update(template_data._items)


class ViewVCException(Exception):
def __init__(self, msg, status=None):
self.msg = msg
self.status = status

def __str__(self):
if self.status:
return '%s: %s' % (self.status, self.msg)
return "ViewVC Unrecoverable Error: %s" % self.msg
12 changes: 1 addition & 11 deletions lib/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

import sys
from common import ViewVCException

# Set to non-zero to track and print processing times
SHOW_TIMES = 0
Expand Down Expand Up @@ -57,17 +58,6 @@ def t_dump(out):
t_start = t_end = t_dump = lambda *args: None


class ViewVCException(Exception):
def __init__(self, msg, status=None):
self.msg = msg
self.status = status

def __str__(self):
if self.status:
return '%s: %s' % (self.status, self.msg)
return "ViewVC Unrecoverable Error: %s" % self.msg


def PrintException(server, exc_data):
status = exc_data['status']
msg = exc_data['msg']
Expand Down
11 changes: 5 additions & 6 deletions lib/vcauth/svnauthz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import vcauth
import os.path
import debug
from common import ViewVCException

from ConfigParser import ConfigParser

Expand All @@ -29,9 +29,9 @@ def __init__(self, root_lookup_func, username, params={}):
self.authz_file = params.get('authzfile')
self.rel_authz_file = params.get('root_relative_authzfile')
if not (self.authz_file or self.rel_authz_file):
raise debug.ViewVCException("No authzfile configured")
raise ViewVCException("No authzfile configured")
if self.authz_file and self.rel_authz_file:
raise debug.ViewVCException("Multiple authzfile locations defined")
raise ViewVCException("Multiple authzfile locations defined")

# See if the admin wants us to do case normalization of usernames.
self.force_username_case = params.get('force_username_case')
Expand All @@ -42,8 +42,7 @@ def __init__(self, root_lookup_func, username, params={}):
elif not self.force_username_case:
self.username = username
else:
raise debug.ViewVCException("Invalid value for force_username_case "
"option")
raise ViewVCException("Invalid value for force_username_case option")

def _get_authz_file(self, rootname):
if self.rel_authz_file:
Expand All @@ -66,7 +65,7 @@ def _get_paths_for_root(self, rootname):
try:
cp.read(self._get_authz_file(rootname))
except:
raise debug.ViewVCException("Unable to parse configured authzfile file")
raise ViewVCException("Unable to parse configured authzfile file")

# Ignore context; assume the authz file only has the repository URL's
# basename, just like mod_dav_svn requires it.
Expand Down
Loading

0 comments on commit 1fe4ecc

Please sign in to comment.