Skip to content

Commit

Permalink
Merge pull request #14 from collective/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
gforcada committed May 15, 2021
2 parents 67e4c9a + b899967 commit 3e1af58
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 58 deletions.
16 changes: 5 additions & 11 deletions haufe/requestmonitoring/DumpTraceback.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# -*- coding: utf-8 -*-
# $Id: DumpTraceback.py,v 1.2 2008-01-19 10:34:48 dieter Exp $
'''Dump the traceback of a long running request.'''
"""Dump the traceback of a long running request."""

from sys import _current_frames as current_frames
from zExceptions.ExceptionFormatter import TextExceptionFormatter

import os
import logging

log = logging.getLogger('RequestMonitor.DumpTrace')

try:
from sys import _current_frames as current_frames
except ImportError:
# Python 2.4 or lower: use threadframe
from threadframe import dict as current_frames


class StackFormatter(TextExceptionFormatter):
def formatStack(self, stack, limit=None):
return self.formatException(None, None, _TBFrame(stack), limit)

# overrides
# overrides
def getPrefix(self):
return 'Python call stack (innermost first)'

Expand All @@ -46,7 +40,7 @@ def formatStack(stack, limit=None):


class _NextTBFrame(object):
'''a delayed next wrapper.'''
"""a delayed next wrapper."""

def __get__(self, tbframe, unused):
back = tbframe.tb_frame.f_back
Expand All @@ -55,7 +49,7 @@ def __get__(self, tbframe, unused):


class _TBFrame(object):
'''a traceback frame proxy.'''
"""a traceback frame proxy."""
tb_next = _NextTBFrame()

def __init__(self, frame):
Expand Down
15 changes: 7 additions & 8 deletions haufe/requestmonitoring/Rotator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# $Id: Rotator.py,v 1.1.156.2 2007-11-27 09:35:56 hamannu Exp $
'''A daily rotating file.'''
"""A daily rotating file."""

from threading import Lock
from time import localtime
Expand All @@ -10,19 +9,19 @@


class RotatorInfo:
'''information about a rotating file.'''
"""information about a rotating file."""

def __init__(self, base, format='.%y%m%d'):
self._base = base
self._format = format
self._setup()

def toSwitch(self):
'''true, when we should switch filename.'''
"""true, when we should switch filename."""
return time() > self._limit

def getFilename(self):
'''the current filename.'''
"""the current filename."""
if self.toSwitch():
self._setup()
return self._filename
Expand All @@ -35,15 +34,15 @@ def _setup(self, _t=(0, 0, 0)):


class Rotator(RotatorInfo):
'''a rotating writable file like object.'''
"""a rotating writable file like object."""

def __init__(self, base, format='.%y%m%d', lock=0):
RotatorInfo.__init__(self, base, format)
self._lock = lock and Lock()
self._open()

def write(self, str):
'''write *str* and flush.'''
"""write *str* and flush."""
lock = self._lock
if lock:
lock.acquire()
Expand All @@ -58,7 +57,7 @@ def write(self, str):
lock.release()

def flush(self):
'''helper to support applications that want to flush themselves.'''
"""helper to support applications that want to flush themselves."""
pass

def close(self):
Expand Down
12 changes: 0 additions & 12 deletions haufe/requestmonitoring/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
# -*- coding: utf-8 -*-
# $Id: __init__.py,v 1.1.1.1 2005-03-04 10:46:51 dieter Exp $
'''Handler for use as request monitors.'''

# Zope versions > 2.11 don't need to be patched this way

from App.version_txt import getZopeVersion

major, minor, micro, status, release = getZopeVersion()

if major == 2 and minor <= 10:
import patch # noqa
3 changes: 1 addition & 2 deletions haufe/requestmonitoring/monitor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# $Id: monitor.py,v 1.3 2008-07-01 05:47:52 dieter Exp $
"""Monitor request execution.
Requires "feature_pubevents".
Expand Down Expand Up @@ -36,7 +35,7 @@


class Request:
'''request description.'''
"""request description."""

def __init__(self, id, info, request, startTime, threadId):
self.id = id
Expand Down
14 changes: 0 additions & 14 deletions haufe/requestmonitoring/patch.py

This file was deleted.

16 changes: 5 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,35 @@

version = '0.6.1.dev0'

long_description = ('\n\n'.join([
long_description = '\n\n'.join([
open('README.rst').read(),
open('CHANGES.rst').read(),
]))
])

install_requires = [
'setuptools',
'Zope2',
'zope.processlifetime',
]

if sys.version_info < (2, 5):
install_requires.append('threadframe')

setup(
name='haufe.requestmonitoring',
version=version,
description="Zope 2 request monitoring",
long_description=long_description,
# Get more strings from
# http://www.python.org/pypi?%3Aaction=list_classifiers
# https://pypi.org/classifiers/
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Framework :: Plone :: 5.2",
"Framework :: Zope2",
"License :: OSI Approved :: Zope Public License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Framework :: Zope2",
"Topic :: System :: Monitoring",
"Topic :: System :: Logging",
],
Expand All @@ -51,7 +45,7 @@
maintainer_email='info@zopyx.com',
license='ZPL',
url='http://github.com/collective/haufe.requestmonitoring',
packages=find_packages(exclude=['ez_setup']),
packages=find_packages(),
namespace_packages=['haufe'],
include_package_data=True,
zip_safe=False,
Expand Down

0 comments on commit 3e1af58

Please sign in to comment.