Skip to content

Commit

Permalink
merge conflict fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Oct 4, 2019
2 parents 2c53b29 + 435ea7f commit 37e598c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 34 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off
After the SAP NW RFC SDK [installed](#prerequisites) on your system, you can pip install the _pyrfc_ package for your platform from the [dist](dist) folder:

```shell
wget https://github.com/SAP/PyRFC/blob/master/dist/pyrfc-1.9.94-cp37-cp37m-macosx_10_14_x86_64.whl
wget https://github.com/SAP/PyRFC/raw/master/dist/pyrfc-1.9.97-cp37-cp37m-macosx_10_14_x86_64.whl

pip install pyrfc-1.9.94-cp37-cp37m-macosx_10_14_x86_64.whl
pip install pyrfc-1.9.97-cp37-cp37m-macosx_10_14_x86_64.whl
```

Alternatively, or if the _pyrfc_ package for your platform not provided, [build the package from source](http://sap.github.io/PyRFC/build.html) on your system and pip install:
Expand All @@ -55,7 +55,7 @@ Alternatively, or if the _pyrfc_ package for your platform not provided, [build
git clone https://github.com/SAP/PyRFC.git
cd PyRFC
python setup.py bdist_wheel
pip install dist/pyrfc-1.9.94-cp37-cp37m-macosx_10_14_x86_64.whl
pip install dist/pyrfc-1.9.97-cp37-cp37m-macosx_10_14_x86_64.whl
# set ABAP system parameters in test/pyrfc.cfg
pytest -vv
```
Expand Down
69 changes: 38 additions & 31 deletions examples/clientPrintDescription.py
Original file line number Diff line number Diff line change
@@ -1,77 +1,84 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from ConfigParser import ConfigParser
import sys

from pyrfc import Connection,\
ABAPApplicationError, ABAPRuntimeError, LogonError, CommunicationError

from config import PARAMS as params_connection

def parameter_key_function(parameter):
""" returns a key for sorting parameters """
value = {u'RFC_IMPORT':1,
u'RFC_CHANGING':2,
u'RFC_TABLES':3,
u'RFC_EXPORT':4}
value = {'RFC_IMPORT':1,
'RFC_CHANGING':2,
'RFC_TABLES':3,
'RFC_EXPORT':4}
return value[parameter['direction']]

def main(function_name):
config = ConfigParser()
config.read('sapnwrfc.cfg')
params_connection = config._sections['connection']

try:
connection = Connection(**params_connection)
func_desc = connection.get_function_description(function_name)
print (u"Parameters of function: {0}".format(function_name))
print('Parameters of function: {0}'.format(function_name))

parameter_keys = [u'name', u'parameter_type', u'direction',
u'nuc_length', u'uc_length', u'decimals',
u'default_value', u'optional',
u'type_description', u'parameter_text']
parameter_keys = ['name', 'parameter_type', 'direction',
'nuc_length', 'uc_length', 'decimals',
'default_value', 'optional',
'type_description', 'parameter_text']
parameter_widths = [20, 17, 11, 10, 9, 9, 15, 10, 15, 20]
for key, width in zip(parameter_keys, parameter_widths):
sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ")
sys.stdout.write(u"\n")
sys.stdout.write('{0}'.format(key).ljust(width).upper() + ' ')
sys.stdout.write('\n')

for parameter in sorted(func_desc.parameters, key=parameter_key_function):
for key, width in zip(parameter_keys, parameter_widths):
if key == u'type_description' and parameter[key] is not None:
if key == 'type_description' and parameter[key] is not None:
sys.stdout.write(
u"{0}".format(parameter[key].name).ljust(width) + u" "
'{0}'.format(parameter[key].name).ljust(width) + ' '
)
else:
sys.stdout.write(
u"{0}".format(parameter[key]).ljust(width) + u" "
'{0}'.format(parameter[key]).ljust(width) + ' '
)
sys.stdout.write(u"\n")
sys.stdout.write('\n')
type_desc = parameter['type_description']
if type_desc is not None:
# type_desc of class TypeDescription
field_keys = [u'name', u'field_type', u'nuc_length',
u'nuc_offset', u'uc_length', u'uc_offset',
u'decimals', u'type_description']
field_keys = ['name', 'field_type', 'nuc_length',
'nuc_offset', 'uc_length', 'uc_offset',
'decimals', 'type_description']
field_widths = [20, 17, 10, 10, 9, 9, 10, 15]

sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n".format(type_desc))
sys.stdout.write(' ' * 4 + '-----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n'.format(type_desc))
for key, width in zip(field_keys, field_widths):
sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ")
sys.stdout.write(u"\n")
sys.stdout.write('{0}'.format(key).ljust(width).upper() + ' ')
sys.stdout.write('\n')

for field_description in type_desc.fields:
for key, width in zip(field_keys, field_widths):
sys.stdout.write(u"{0}".format(field_description[key]).ljust(width) + u" ")
sys.stdout.write(u"\n")
sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} )-----------\n".format(type_desc))
sys.stdout.write(u"-" * sum(parameter_widths) + u"\n")
sys.stdout.write('{0}'.format(field_description[key]).ljust(width) + ' ')
sys.stdout.write('\n')
sys.stdout.write(' ' * 4 + '-----------( Structure of {0.name} )-----------\n'.format(type_desc))
sys.stdout.write('-' * sum(parameter_widths) + '\n')
connection.close()

except CommunicationError:
print ("Could not connect to server.")
print('Could not connect to server.')
raise
except LogonError:
print ("Could not log in. Wrong credentials?")
print('Could not log in. Wrong credentials?')
raise
except (ABAPApplicationError, ABAPRuntimeError):
print ("An error occurred.")
print('An error occurred.')
raise

if __name__ == '__main__':
if len(sys.argv)<2:
print("No function name provided.")
print('No function name provided.')
sys.exit()
main(sys.argv[1])
main(sys.argv[1])

0 comments on commit 37e598c

Please sign in to comment.