/usr/lib/python2.7/dist-packages/pygopherd/GopherExceptions.py is in pygopherd 2.0.18.3+nmu4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # pygopherd -- Gopher-based protocol server in Python
# module: exception declarations
# Copyright (C) 2002 John Goerzen
# <jgoerzen@complete.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import types, re
from pygopherd import logger
tracebacks = 0
def log(exception, protocol = None, handler = None):
"""Logs an exception. It will try to generate a nice-looking string
based on the arguments passed in."""
protostr = 'None'
handlerstr = 'None'
ipaddr = 'unknown-address'
exceptionclass = re.search("[^.]+$", str(exception.__class__)).group(0)
if protocol:
protostr = re.search("[^.]+$", str(protocol.__class__)).group(0)
ipaddr = protocol.requesthandler.client_address[0]
if handler:
handlerstr = re.search("[^.]+$", str(handler.__class__)).group(0)
logger.log("%s [%s/%s] EXCEPTION %s: %s" % \
(ipaddr, protostr, handlerstr, exceptionclass,
str(exception)))
def init(backtraceenabled):
global tracebacks
tracebacks = backtraceenabled
class FileNotFound:
def __init__(self, arg):
self.selector = arg
self.comments = ''
self.protocol = ''
if type(arg) != types.StringType:
self.selector = arg[0]
self.comments = arg[1]
if len(arg) > 2 and arg[2]:
self.protocol = arg[2]
log(self, self.protocol, None)
def __str__(self):
retval = "'%s' does not exist" % (self.selector)
if self.comments:
retval += " (%s)" % self.comments
return retval
|