Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Commit b39d225

Browse files
author
Jim Olsen
committed
added client_count.py
1 parent 0aef67e commit b39d225

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

bin/client_count.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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

Comments
 (0)