|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- mode: Python; tab-width: 4; indent-tabs-mode: nil; -*- |
| 3 | +# ex: set tabstop=4 |
| 4 | +# Please do not change the two lines above. See PEP 8, PEP 263. |
| 5 | +'''Provides an interactive console with pytan available as handler''' |
| 6 | +__author__ = 'Jim Olsen <[email protected]>' |
| 7 | +__version__ = '2.1.5' |
| 8 | + |
| 9 | +import os |
| 10 | +import sys |
| 11 | +sys.dont_write_bytecode = True |
| 12 | + |
| 13 | +my_file = os.path.abspath(sys.argv[0]) |
| 14 | +my_name = os.path.splitext(os.path.basename(my_file))[0] |
| 15 | +my_dir = os.path.dirname(my_file) |
| 16 | +parent_dir = os.path.dirname(my_dir) |
| 17 | +lib_dir = os.path.join(parent_dir, 'lib') |
| 18 | +path_adds = [lib_dir] |
| 19 | +[sys.path.append(aa) for aa in path_adds if aa not in sys.path] |
| 20 | + |
| 21 | +import pytan |
| 22 | +import pytan.binsupport |
| 23 | +import taniumpy |
| 24 | + |
| 25 | +if __name__ == "__main__": |
| 26 | + pytan.binsupport.version_check(reqver=__version__) |
| 27 | + |
| 28 | + setupmethod = getattr(pytan.binsupport, 'setup_pytan_shell_argparser') |
| 29 | + responsemethod = getattr(pytan.binsupport, 'process_pytan_shell_args') |
| 30 | + |
| 31 | + parser = setupmethod(doc=__doc__) |
| 32 | + parser.add_argument( |
| 33 | + '-c', |
| 34 | + '--count', |
| 35 | + required=False, |
| 36 | + action='store', |
| 37 | + dest='client_count', |
| 38 | + type=int, |
| 39 | + default=5, |
| 40 | + help='client count', |
| 41 | + ) |
| 42 | + args = parser.parse_args() |
| 43 | + |
| 44 | + handler = pytan.binsupport.process_handler_args(parser=parser, args=args) |
| 45 | + response = responsemethod(parser=parser, handler=handler, args=args) |
| 46 | + |
| 47 | + import xmltodict |
| 48 | + client_count = args.client_count |
| 49 | + object_list = "<client_count>{}</client_count>".format(client_count) |
| 50 | + request_body = handler.session._build_body(object_list=object_list, command="GetObject", ) |
| 51 | + response_body = handler.session._get_response(request_body=request_body) |
| 52 | + response_dict = xmltodict.parse(response_body) |
| 53 | + result_object = response_dict["soap:Envelope"]["soap:Body"]["t:return"]["result_object"] |
| 54 | + client_count = result_object["client_count"] |
| 55 | + print(client_count) |
0 commit comments