besapi 3.3.3__tar.gz → 3.4.1__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.3/src/besapi.egg-info → besapi-3.4.1}/PKG-INFO +1 -1
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/besapi.py +1 -1
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/plugin_utilities.py +30 -11
- {besapi-3.3.3 → besapi-3.4.1/src/besapi.egg-info}/PKG-INFO +1 -1
- {besapi-3.3.3 → besapi-3.4.1}/LICENSE.txt +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/MANIFEST.in +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/README.md +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/pyproject.toml +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/setup.cfg +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/setup.py +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/__init__.py +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/__main__.py +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/schemas/BES.xsd +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/schemas/BESAPI.xsd +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi/schemas/BESActionSettings.xsd +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi.egg-info/SOURCES.txt +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi.egg-info/dependency_links.txt +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi.egg-info/requires.txt +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/besapi.egg-info/top_level.txt +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/bescli/__init__.py +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/bescli/__main__.py +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/src/bescli/bescli.py +0 -0
- {besapi-3.3.3 → besapi-3.4.1}/tests/tests.py +0 -0
|
@@ -86,27 +86,25 @@ def setup_plugin_argparse(plugin_args_required=False):
|
|
|
86
86
|
return arg_parser
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
def setup_plugin_logging(
|
|
89
|
+
def setup_plugin_logging(log_file_path="", verbose=0, console=True):
|
|
90
90
|
"""setup logging for plugin use"""
|
|
91
|
-
# get folder the script was invoked from:
|
|
92
|
-
invoke_folder = get_invoke_folder(verbose)
|
|
93
91
|
|
|
94
|
-
if not
|
|
95
|
-
|
|
92
|
+
if not log_file_path or log_file_path == "":
|
|
93
|
+
log_file_path = os.path.join(
|
|
94
|
+
get_invoke_folder(verbose), get_invoke_file_name(verbose) + ".log"
|
|
95
|
+
)
|
|
96
96
|
|
|
97
97
|
# set different log levels:
|
|
98
98
|
log_level = logging.WARNING
|
|
99
99
|
if verbose:
|
|
100
100
|
log_level = logging.INFO
|
|
101
|
+
print("INFO: Log File Path: %s", log_file_path)
|
|
101
102
|
if verbose > 1:
|
|
102
103
|
log_level = logging.DEBUG
|
|
103
104
|
|
|
104
|
-
# get path to put log file in:
|
|
105
|
-
log_filename = os.path.join(invoke_folder, log_file_name)
|
|
106
|
-
|
|
107
105
|
handlers = [
|
|
108
106
|
logging.handlers.RotatingFileHandler(
|
|
109
|
-
|
|
107
|
+
log_file_path, maxBytes=5 * 1024 * 1024, backupCount=1
|
|
110
108
|
)
|
|
111
109
|
]
|
|
112
110
|
|
|
@@ -134,6 +132,9 @@ def get_besapi_connection(args):
|
|
|
134
132
|
print("Password was not provided, provide REST API password:")
|
|
135
133
|
password = getpass.getpass()
|
|
136
134
|
|
|
135
|
+
if args.user:
|
|
136
|
+
logging.debug("REST API Password Length: %s", len(password))
|
|
137
|
+
|
|
137
138
|
# process args, setup connection:
|
|
138
139
|
rest_url = args.rest_url
|
|
139
140
|
|
|
@@ -145,12 +146,16 @@ def get_besapi_connection(args):
|
|
|
145
146
|
if args.user and password:
|
|
146
147
|
try:
|
|
147
148
|
bes_conn = besapi.besapi.BESConnection(args.user, password, rest_url)
|
|
148
|
-
# bes_conn.login()
|
|
149
149
|
except (
|
|
150
150
|
AttributeError,
|
|
151
151
|
ConnectionRefusedError,
|
|
152
152
|
besapi.besapi.requests.exceptions.ConnectionError,
|
|
153
153
|
):
|
|
154
|
+
logging.exception(
|
|
155
|
+
"connection to `%s` failed, attempting `%s` instead",
|
|
156
|
+
rest_url,
|
|
157
|
+
args.besserver,
|
|
158
|
+
)
|
|
154
159
|
try:
|
|
155
160
|
# print(args.besserver)
|
|
156
161
|
bes_conn = besapi.besapi.BESConnection(
|
|
@@ -159,8 +164,22 @@ def get_besapi_connection(args):
|
|
|
159
164
|
# handle case where args.besserver is None
|
|
160
165
|
# AttributeError: 'NoneType' object has no attribute 'startswith'
|
|
161
166
|
except AttributeError:
|
|
162
|
-
|
|
167
|
+
logging.exception("----- ERROR: BigFix Connection Failed ------")
|
|
168
|
+
logging.exception(
|
|
169
|
+
"attempts to connect to BigFix using rest_url and besserver both failed"
|
|
170
|
+
)
|
|
171
|
+
return None
|
|
172
|
+
except BaseException as err:
|
|
173
|
+
# always log error and stop the current process
|
|
174
|
+
logging.exception("ERROR: %s", err)
|
|
175
|
+
logging.exception(
|
|
176
|
+
"----- ERROR: BigFix Connection Failed! Unknown reason ------"
|
|
177
|
+
)
|
|
178
|
+
return None
|
|
163
179
|
else:
|
|
180
|
+
logging.info(
|
|
181
|
+
"attempting connection to BigFix using config file method as user command arg was not provided"
|
|
182
|
+
)
|
|
164
183
|
bes_conn = besapi.besapi.get_bes_conn_using_config_file()
|
|
165
184
|
|
|
166
185
|
return bes_conn
|
|
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
|
|
File without changes
|