Skip to content

Commit

Permalink
Merge 6a9ebb9 into 61b5eb6
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Jul 27, 2018
2 parents 61b5eb6 + 6a9ebb9 commit 8629702
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions drmaa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

from __future__ import absolute_import, print_function, unicode_literals

import logging

from .const import (ATTR_BUFFER, BLOCK_EMAIL, CONTACT_BUFFER,
control_action_to_string, DEADLINE_TIME, DRM_SYSTEM_BUFFER,
DRMAA_IMPLEMENTATION_BUFFER, DURATION_HLIMIT,
Expand Down Expand Up @@ -98,3 +100,8 @@
'SUBMISSION_STATE_ACTIVE', 'SUBMISSION_STATE_HOLD',
'TIMEOUT_NO_WAIT', 'TIMEOUT_WAIT_FOREVER', 'TRANSFER_FILES',
'V_ARGV', 'V_EMAIL', 'V_ENV', 'WCT_HLIMIT', 'WCT_SLIMIT', 'WD']


logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.NullHandler())
21 changes: 20 additions & 1 deletion drmaa/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@

from __future__ import absolute_import, print_function, unicode_literals

import logging
import sys
from collections import namedtuple
from ctypes import (byref, c_uint, create_string_buffer, POINTER, pointer,
sizeof)

from wurlitzer import pipes

from drmaa.const import ATTR_BUFFER, ENCODING, NO_MORE_ELEMENTS
from drmaa.errors import error_buffer
from drmaa.wrappers import (drmaa_attr_names_t, drmaa_attr_values_t,
Expand All @@ -55,6 +58,11 @@
_BUFLEN = ATTR_BUFFER


logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.NullHandler())


class BoolConverter(object):

"""Helper class to convert to/from bool attributes."""
Expand Down Expand Up @@ -299,8 +307,19 @@ def c(f, *args):
A helper function wrapping calls to the C DRMAA functions with error
managing code.
"""
return f(*(args + (error_buffer, sizeof(error_buffer))))

with pipes() as (stdout, stderr):
result = f(*(args + (error_buffer, sizeof(error_buffer))))

for line in stdout.readline():
if line:
logger.debug(line)

for line in stderr.readline():
if line:
logger.debug(line)

return result

def string_vector(v):
vlen = len(v)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def readme():
license="BSD",
keywords="python grid hpc drmaa",
url="https://github.com/pygridtools/drmaa-python",
install_requires=["wurlitzer"],
tests_require='nose',
test_suite='nose.collector',
classifiers=["Development Status :: 4 - Beta",
Expand Down

0 comments on commit 8629702

Please sign in to comment.