Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 27, 2017
1 parent 0b69a32 commit cebd5a4
Show file tree
Hide file tree
Showing 80 changed files with 3,686 additions and 3,552 deletions.
2 changes: 2 additions & 0 deletions src/Products/SiteAccess/VirtualHostMonster.py
Expand Up @@ -248,6 +248,7 @@ def __bobo_traverse__(self, request, name):
request.setVirtualRoot([])
return parents.pop() # He'll get put back on


InitializeClass(VirtualHostMonster)


Expand All @@ -262,6 +263,7 @@ def manage_addVirtualHostMonster(self, id=None, REQUEST=None, **ignored):
qs = 'manage_tabs_message=Virtual+Host+Monster+added.'
raise Redirect('%s?%s' % (goto, qs))


constructors = (
('manage_addVirtualHostMonster', manage_addVirtualHostMonster),
)
2 changes: 2 additions & 0 deletions src/Signals/SignalHandler.py
Expand Up @@ -63,6 +63,7 @@ def signalHandler(self, signum, frame):
LOG.warn('A handler for %s failed!' % signame,
exc_info=sys.exc_info())


_signals = None


Expand All @@ -83,5 +84,6 @@ def get_signal_name(n):
_signals[v] = k
return _signals.get(n, 'signal %d' % n)


# The SignalHandler is actually a singleton.
SignalHandler = SignalHandler()
2 changes: 2 additions & 0 deletions src/Signals/WinSignalHandler.py
Expand Up @@ -248,6 +248,7 @@ def signalHandler(self, signum, frame):
logger.exception("A handler for %s failed!'" % signame)
wakeSelect() # trigger a walk around the Lifetime loop.


_signals = None


Expand Down Expand Up @@ -278,6 +279,7 @@ def consoleCtrlHandler(ctrlType):
# The win32 ConsoleCtrlHandler
return SignalHandler.consoleCtrlHandler(ctrlType)


# The SignalHandler is actually a singleton.
SignalHandler = SignalHandler()

Expand Down
4 changes: 3 additions & 1 deletion src/ZServer/AccessLogger.py
Expand Up @@ -26,10 +26,12 @@ def __init__(self):
BaseLogger.__init__(self, 'access')

def log(self, message):
if not self.logger.handlers: # don't log if we have no handlers
if not self.logger.handlers:
# don't log if we have no handlers
return
if message.endswith('\n'):
message = message[:-1]
self.logger.warn(message)


access_logger = AccessLogger()
2 changes: 1 addition & 1 deletion src/ZServer/BaseLogger.py
Expand Up @@ -19,7 +19,7 @@
import logging


class BaseLogger:
class BaseLogger(object):
def __init__(self, name):
self.logger = logging.getLogger(name)
self.logger.propagate = False
Expand Down
57 changes: 29 additions & 28 deletions src/ZServer/ClockServer.py
Expand Up @@ -28,48 +28,52 @@
from ZServer.HTTPResponse import make_response
from ZPublisher.HTTPRequest import HTTPRequest


def timeslice(period, when=None, t=time.time):
if when is None:
when = t()
when = t()
return when - (when % period)

class LogHelper:

class LogHelper(object):
def __init__(self, logger):
self.logger = logger

def log(self, ip, msg, **kw):
self.logger.log(ip + ' ' + msg)

class DummyChannel:

class DummyChannel(object):
# we need this minimal do-almost-nothing channel class to appease medusa
addr = ['127.0.0.1']
closed = 1

def __init__(self, server):
self.server = server

def push_with_producer(self):
pass

def close_when_done(self):
pass



class ClockServer(asyncore.dispatcher):
# prototype request environment
_ENV = dict(REQUEST_METHOD = 'GET',
SERVER_PORT = 'Clock',
SERVER_NAME = 'Zope Clock Server',
SERVER_SOFTWARE = 'Zope',
SERVER_PROTOCOL = 'HTTP/1.0',
SCRIPT_NAME = '',
_ENV = dict(REQUEST_METHOD='GET',
SERVER_PORT='Clock',
SERVER_NAME='Zope Clock Server',
SERVER_SOFTWARE='Zope',
SERVER_PROTOCOL='HTTP/1.0',
SCRIPT_NAME='',
GATEWAY_INTERFACE='CGI/1.1',
REMOTE_ADDR = '0')
REMOTE_ADDR='0')

# required by ZServer
SERVER_IDENT = 'Zope Clock'
SERVER_IDENT = 'Zope Clock'

def __init__ (self, method, period=60, user=None, password=None,
host=None, logger=None, handler=None):
def __init__(self, method, period=60, user=None, password=None,
host=None, logger=None, handler=None):
self.period = period
self.method = method

Expand Down Expand Up @@ -111,27 +115,27 @@ def get_env(self, req):
env = self._ENV.copy()
(path, params, query, fragment) = req.split_uri()
if params:
path = path + params # undo medusa bug
path = path + params # undo medusa bug
while path and path[0] == '/':
path = path[1:]
if '%' in path:
path = unquote(path)
if query:
# ZPublisher doesn't want the leading '?'
query = query[1:]
env['PATH_INFO']= '/' + path
env['PATH_TRANSLATED']= posixpath.normpath(
env['PATH_INFO'] = '/' + path
env['PATH_TRANSLATED'] = posixpath.normpath(
posixpath.join(os.getcwd(), env['PATH_INFO']))
if query:
env['QUERY_STRING'] = query
env['channel.creation_time']=time.time()
env['channel.creation_time'] = time.time()
for header in req.header:
key,value = header.split(":",1)
key, value = header.split(":", 1)
key = key.upper()
value = value.strip()
key = 'HTTP_%s' % ("_".join(key.split( "-")))
key = 'HTTP_%s' % ("_".join(key.split("-")))
if value:
env[key]=value
env[key] = value
return env

def readable(self):
Expand All @@ -147,17 +151,14 @@ def readable(self):
def handle_read(self):
return True

def handle_write (self):
def handle_write(self):
self.log_info('unexpected write event', 'warning')
return True

def writable(self):
return False

def handle_error (self): # don't close the socket on error
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
def handle_error(self): # don't close the socket on error
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
self.log_info('Problem in Clock (%s:%s %s)' % (t, v, tbinfo),
'error')



1 change: 0 additions & 1 deletion src/ZServer/DebugLogger.py
Expand Up @@ -34,7 +34,6 @@
"""

import time
import logging

from ZServer.BaseLogger import BaseLogger

Expand Down

0 comments on commit cebd5a4

Please sign in to comment.