besapi 3.3.2__tar.gz → 3.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {besapi-3.3.2/src/besapi.egg-info → besapi-3.3.3}/PKG-INFO +1 -1
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/besapi.py +1 -1
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/plugin_utilities.py +43 -9
- {besapi-3.3.2 → besapi-3.3.3/src/besapi.egg-info}/PKG-INFO +1 -1
- {besapi-3.3.2 → besapi-3.3.3}/tests/tests.py +10 -0
- {besapi-3.3.2 → besapi-3.3.3}/LICENSE.txt +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/MANIFEST.in +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/README.md +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/pyproject.toml +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/setup.cfg +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/setup.py +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/__init__.py +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/__main__.py +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/schemas/BES.xsd +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/schemas/BESAPI.xsd +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi/schemas/BESActionSettings.xsd +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi.egg-info/SOURCES.txt +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi.egg-info/dependency_links.txt +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi.egg-info/requires.txt +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/besapi.egg-info/top_level.txt +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/bescli/__init__.py +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/bescli/__main__.py +0 -0
- {besapi-3.3.2 → besapi-3.3.3}/src/bescli/bescli.py +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"""This is a set of utility functions for use in multiple plugins"""
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
|
+
import getpass
|
|
4
5
|
import logging
|
|
5
6
|
import logging.handlers
|
|
6
7
|
import ntpath
|
|
7
8
|
import os
|
|
8
9
|
import sys
|
|
9
10
|
|
|
11
|
+
import besapi
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
def get_invoke_folder(verbose=0):
|
|
12
15
|
"""Get the folder the script was invoked from"""
|
|
@@ -120,13 +123,44 @@ def setup_plugin_logging(log_file_name="", verbose=0, console=True):
|
|
|
120
123
|
)
|
|
121
124
|
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
def get_besapi_connection(args):
|
|
127
|
+
"""get connection to besapi using either args or config file if args not provided"""
|
|
128
|
+
|
|
129
|
+
password = args.password
|
|
130
|
+
|
|
131
|
+
# if user was provided as arg but password was not:
|
|
132
|
+
if args.user and not password:
|
|
133
|
+
logging.warning("Password was not provided, provide REST API password.")
|
|
134
|
+
print("Password was not provided, provide REST API password:")
|
|
135
|
+
password = getpass.getpass()
|
|
136
|
+
|
|
137
|
+
# process args, setup connection:
|
|
138
|
+
rest_url = args.rest_url
|
|
139
|
+
|
|
140
|
+
# normalize url to https://HostOrIP:52311
|
|
141
|
+
if rest_url and rest_url.endswith("/api"):
|
|
142
|
+
rest_url = rest_url.replace("/api", "")
|
|
143
|
+
|
|
144
|
+
# attempt bigfix connection with provided args:
|
|
145
|
+
if args.user and password:
|
|
146
|
+
try:
|
|
147
|
+
bes_conn = besapi.besapi.BESConnection(args.user, password, rest_url)
|
|
148
|
+
# bes_conn.login()
|
|
149
|
+
except (
|
|
150
|
+
AttributeError,
|
|
151
|
+
ConnectionRefusedError,
|
|
152
|
+
besapi.besapi.requests.exceptions.ConnectionError,
|
|
153
|
+
):
|
|
154
|
+
try:
|
|
155
|
+
# print(args.besserver)
|
|
156
|
+
bes_conn = besapi.besapi.BESConnection(
|
|
157
|
+
args.user, password, args.besserver
|
|
158
|
+
)
|
|
159
|
+
# handle case where args.besserver is None
|
|
160
|
+
# AttributeError: 'NoneType' object has no attribute 'startswith'
|
|
161
|
+
except AttributeError:
|
|
162
|
+
bes_conn = besapi.besapi.get_bes_conn_using_config_file()
|
|
163
|
+
else:
|
|
164
|
+
bes_conn = besapi.besapi.get_bes_conn_using_config_file()
|
|
131
165
|
|
|
132
|
-
|
|
166
|
+
return bes_conn
|
|
@@ -25,6 +25,7 @@ if not args.test_pip:
|
|
|
25
25
|
sys.path.reverse()
|
|
26
26
|
|
|
27
27
|
import besapi
|
|
28
|
+
import besapi.plugin_utilities
|
|
28
29
|
|
|
29
30
|
print("besapi version: " + str(besapi.besapi.__version__))
|
|
30
31
|
|
|
@@ -151,4 +152,13 @@ if bigfix_cli.bes_conn:
|
|
|
151
152
|
bes_conn = besapi.besapi.get_bes_conn_using_config_file()
|
|
152
153
|
print("login succeeded:", bes_conn.login())
|
|
153
154
|
|
|
155
|
+
# test plugin_utilities:
|
|
156
|
+
print(besapi.plugin_utilities.get_invoke_folder())
|
|
157
|
+
print(besapi.plugin_utilities.get_invoke_file_name())
|
|
158
|
+
# the following doesn't seem to work in python 3.7:
|
|
159
|
+
# besapi.plugin_utilities.setup_plugin_logging(console=True)
|
|
160
|
+
parser = besapi.plugin_utilities.setup_plugin_argparse(plugin_args_required=False)
|
|
161
|
+
# allow unknown args to be parsed instead of throwing an error:
|
|
162
|
+
args, _unknown = parser.parse_known_args()
|
|
163
|
+
|
|
154
164
|
sys.exit(0)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|