-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdirect.py
More file actions
50 lines (41 loc) · 1.67 KB
/
direct.py
File metadata and controls
50 lines (41 loc) · 1.67 KB
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
# Copyright contributors to the python-itoolkit project
# SPDX-License-Identifier: MIT
# -*- coding: utf-8 -*-
from .base import XmlServiceTransport
try:
# _direct will raise an ImportError when it is running on an unsupported
# platform. This is fine, we check for this in DirectTransport.call
from . import _direct
except ImportError:
pass
__all__ = [
'DirectTransport'
]
class DirectTransport(XmlServiceTransport):
"""Call XMLSERVICE directly in-process using _ILECALL
Args:
**kwargs: Base transport options. See `XmlServiceTransport`.
Example:
>>> from itoolkit.transport import DirectTransport
>>> transport = DirectTransport()
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
def _call(self, tk):
try:
data = _direct.xmlservice(tk.xml_in(), self.ctl, self.ipc)
if len(data) == 0:
# Older versions of XMLSERVICE did not work correctly when
# called directly from a 64-bit PASE application and output is
# left empty. We check for that here and suggest they install
# the updated version.
raise RuntimeError(
"No data returned from XMLSERVICE. "
"This could be a bug present in XMLSERVICE prior to 2.0.1. "
"Perhaps you need to apply PTF SI70667, SI70668 or SI70669?"
)
return data.decode('utf-8')
except NameError:
# When we drop support for Python 2:
# raise RuntimeError("Not supported on this platform") from None
raise RuntimeError("Not supported on this platform")