Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
295 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
language: python | ||
python: 2.7 | ||
env: | ||
global: LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so | ||
matrix: | ||
- TOXENV=check | ||
- TOXENV=2.7,coveralls | ||
- TOXENV=2.7-nocover | ||
- TOXENV=3.3,coveralls | ||
- TOXENV=3.3-nocover | ||
- TOXENV=3.4,coveralls | ||
- TOXENV=3.4-nocover | ||
before_install: | ||
- python --version | ||
- virtualenv --version | ||
- pip --version | ||
- uname -a | ||
- lsb_release -a | ||
install: | ||
- pip install tox | ||
script: | ||
- tox -v | ||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: never | ||
deploy: | ||
provider: pypi | ||
user: RayCrafter | ||
distributions: sdist bdist_wheel | ||
on: | ||
tags: true | ||
repo: RayCrafter/clusterlogger | ||
password: | ||
secure: xi1GnKW2t9hx9pX3PAMee0UsJ4QG182HmIeFfo0egunANS2M8qvk/c2n114YUGXi2CmhvzbVjhJDCdZmcsU/2a2rQ2ueDRXLQPSyCIj9van4FL00TVZLU4Vhvg4a/zLHBvh+Aq9mCgWVrHcdDsibcNVTLNSnuk7/CMlNn/NU/JxRJ2uVXe6DsDCDiNJblRVbRyJ33Gpq+Ngok5hxleN1kQ47WiQcKu1938w0+BzgNnUvquac6dPf0GSd1974Mgq6Yek5dyQPCsQYdZNDEcbcfm1G6Z9ufUkgqVa3mvmY61FvumHAkU3B/+XYRdezIMEL5UosfKBNYb4nyvkfbzp2xtxck/NsWVAZAS8mRvKf6lI1xowsTk8tJkQrScuRecKum/sDRdbkK3tSTkWhED+JHzPTwjuFd85qwrLFXcuhiYRl9A+M09xuYDQKbzeOQUFCADeTW+3FpwkWtyJI1xMl4TVvo8zeNy+FWM61x7gYQ0/iyQPKsg9DZkWHGinA/L8z0q6dZJjrTGz6bBLzD1QwQ+e0znS2CyKnassHl1Ys4vNCp9xxfTLaucesmZH/rRwy0cu/EkKjGOZgR20guOlTPk5B3mqGk5glu0fwAEZV42DHOFuJ6Kgce53MCLPkDMruwRdyYRSPjHzVJjD9p/nOMl74PbB7WtX+UGSRYtOBFHg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ Contents: | |
|
||
installation | ||
usage | ||
userdoc/index | ||
devdoc/index | ||
reference | ||
contributing | ||
authors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[flake8] | ||
max-line-length = 140 | ||
ignore = F403 | ||
|
||
[bdist_wheel] | ||
universal=1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
from __future__ import absolute_import | ||
|
||
from .logfilter import * | ||
|
||
__all__ = [logfilter.__all__] | ||
|
||
__author__ = 'David Zuber' | ||
__email__ = 'zuber.david@gmx.de' | ||
__version__ = '0.1.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import logging | ||
import os | ||
import socket | ||
|
||
__all__ = ['HazelHenFilter'] | ||
|
||
|
||
class HazelHenFilter(logging.Filter): | ||
"""Filter for adding contextual information on ``Hazel Hen`` | ||
`Hazel Hen <http://www.hlrs.de/systems/platforms/cray-xc40-hazel-hen/>`_ | ||
is the Cray XC40 system at HLRS in Stuttgart. | ||
This filter adds information about the currently running job. | ||
""" | ||
def __init__(self): | ||
"""Initialize a new HazelHenFilter | ||
:raises: None | ||
""" | ||
self.jobid = os.environ.get('PBS_JOBID', -1) | ||
"""The job identifier assigned to the job by the batch system. | ||
This is the same number you see when you do qstat. | ||
-1 if logging when not running in a job. | ||
""" | ||
self.logname = os.environ.get('PBS_O_LOGNAME') | ||
"""Value of the LOGNAME variable in the environment in which qsub was executed""" | ||
self.jobname = os.environ.get('PBS_JOBNAME') | ||
"""The job name supplied by the user""" | ||
self.queue = os.environ.get('PBS_QUEUE') | ||
"""The name of the queue from which the job is executed""" | ||
self.fqdn = socket.getfqdn() | ||
"""The fully qualified domain name.""" | ||
|
||
def filter(self, record): | ||
"""Add contextual information to the log record | ||
:param record: the log record | ||
:type record: :class:`logging.LogRecord` | ||
:returns: True, if log should get sent | ||
:rtype: :class:`bool` | ||
:raises: None | ||
""" | ||
record.jobid = self.jobid | ||
record.submitter = self.logname | ||
record.jobname = self.jobname | ||
record.queue = self.queue | ||
record.fqdn = self.fqdn | ||
return True |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
Tests for `logfilter` module. | ||
""" | ||
import os | ||
import socket | ||
|
||
import pytest | ||
|
||
from clusterlogger import logfilter | ||
|
||
|
||
class DummyRecord(object): | ||
pass | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def hazelhen_environ(request): | ||
envvars = {'PBS_JOBID': '28572', | ||
'PBS_O_LOGNAME': 'hpcmscuser', | ||
'PBS_JOBNAME': 'loggingtest', | ||
'PBS_QUEUE': 'test'} | ||
oldvars = {} | ||
for k, v in envvars.items(): | ||
oldvars[k] = os.environ.get(k, '') | ||
os.environ[k] = v | ||
|
||
def restore(): | ||
os.environ.update(oldvars) | ||
request.addfinalizer(restore) | ||
|
||
|
||
@pytest.mark.parametrize('attr,envvar', | ||
[('jobid', 'PBS_JOBID'), | ||
('submitter', 'PBS_O_LOGNAME'), | ||
('jobname', 'PBS_JOBNAME'), | ||
('queue', 'PBS_QUEUE')]) | ||
def test_hazelhen_filter_envvar(hazelhen_environ, attr, envvar): | ||
hhf = logfilter.HazelHenFilter() | ||
record = DummyRecord() | ||
hhf.filter(record) | ||
assert getattr(record, attr) == os.environ[envvar],\ | ||
'Filter did not add envvar %s to the logrecord attribute %s.' % (envvar, attr) | ||
|
||
|
||
def test_hazelhen_filter_fqdn(hazelhen_environ): | ||
hhf = logfilter.HazelHenFilter() | ||
record = DummyRecord() | ||
hhf.filter(record) | ||
assert record.fqdn == socket.getfqdn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,150 @@ | ||
; this is just a bootstrap tox configuration, run tox or ./bootstrap.py to have the full tox.ini | ||
|
||
[tox] | ||
toxworkdir = {toxinidir}/../.toxclusterlogger | ||
envlist = configure | ||
envlist = | ||
clean, | ||
check, | ||
2.7, | ||
2.7-nocover, | ||
3.3, | ||
3.3-nocover, | ||
3.4, | ||
3.4-nocover, | ||
report, | ||
docs | ||
|
||
[testenv] | ||
setenv = | ||
PYTHONPATH={toxinidir}/tests | ||
PYTHONUNBUFFERED=yes | ||
deps = | ||
pytest | ||
pytest-capturelog | ||
commands = | ||
{posargs:py.test -vv} | ||
|
||
[testenv:spell] | ||
setenv = | ||
SPELLCHECK = 1 | ||
commands = | ||
sphinx-build -b spelling docs/source dist/docs | ||
usedevelop = true | ||
deps = | ||
-r{toxinidir}/docs/requirements.txt | ||
sphinxcontrib-spelling | ||
pyenchant | ||
|
||
[testenv:docs] | ||
whitelist_externals = | ||
rm | ||
commands = | ||
rm -rf dist/docs | ||
sphinx-build -b linkcheck docs/source dist/docs | ||
sphinx-build -b html docs/source dist/docs | ||
usedevelop = true | ||
deps = | ||
-r{toxinidir}/docs/requirements.txt | ||
-r{toxinidir}/requirements.txt | ||
|
||
[testenv:configure] | ||
deps = | ||
jinja2 | ||
matrix | ||
usedevelop = true | ||
commands = | ||
python bootstrap.py | ||
python bootstrap.py | ||
|
||
[testenv:check] | ||
deps = | ||
docutils | ||
flake8 | ||
collective.checkdocs | ||
usedevelop = true | ||
commands = | ||
python setup.py checkdocs | ||
python setup.py check --restructuredtext --strict --metadata | ||
flake8 src | ||
|
||
[testenv:coveralls] | ||
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH | ||
deps = | ||
coveralls | ||
usedevelop = true | ||
commands = | ||
coverage combine | ||
coverage report | ||
coveralls | ||
|
||
[testenv:report] | ||
commands = | ||
coverage combine | ||
coverage report | ||
usedevelop = true | ||
deps = coverage<3.999 | ||
|
||
[testenv:clean] | ||
commands = coverage erase | ||
usedevelop = true | ||
deps = coverage<3.999 | ||
|
||
[testenv:2.7] | ||
basepython = python2.7 | ||
setenv = | ||
{[testenv]setenv} | ||
WITH_COVERAGE=yes | ||
usedevelop = true | ||
commands = | ||
{posargs:py.test --cov src -vv} | ||
deps = | ||
{[testenv]deps} | ||
coverage<3.999 | ||
pytest-cov | ||
|
||
[testenv:2.7-nocover] | ||
basepython = python2.7 | ||
deps = | ||
{[testenv]deps} | ||
coverage<3.999 | ||
pytest-cov | ||
|
||
[testenv:3.3] | ||
basepython = python3.3 | ||
setenv = | ||
{[testenv]setenv} | ||
WITH_COVERAGE=yes | ||
usedevelop = true | ||
commands = | ||
{posargs:py.test --cov src -vv} | ||
deps = | ||
{[testenv]deps} | ||
coverage<3.999 | ||
pytest-cov | ||
|
||
[testenv:3.3-nocover] | ||
basepython = python3.3 | ||
deps = | ||
{[testenv]deps} | ||
coverage<3.999 | ||
pytest-cov | ||
|
||
[testenv:3.4] | ||
basepython = python3.4 | ||
setenv = | ||
{[testenv]setenv} | ||
WITH_COVERAGE=yes | ||
usedevelop = true | ||
commands = | ||
{posargs:py.test --cov src -vv} | ||
deps = | ||
{[testenv]deps} | ||
coverage<3.999 | ||
pytest-cov | ||
|
||
[testenv:3.4-nocover] | ||
basepython = python3.4 | ||
deps = | ||
{[testenv]deps} | ||
coverage<3.999 | ||
pytest-cov | ||
|
||
|
||
|