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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: besapi
3
- Version: 3.3.3
3
+ Version: 3.4.1
4
4
  Summary: Library for working with the BigFix REST API
5
5
  Home-page: https://github.com/jgstew/besapi
6
6
  Author: Matt Hansen, James Stewart
@@ -29,7 +29,7 @@ import requests
29
29
  from lxml import etree, objectify
30
30
  from pkg_resources import resource_filename
31
31
 
32
- __version__ = "3.3.3"
32
+ __version__ = "3.4.1"
33
33
 
34
34
  besapi_logger = logging.getLogger("besapi")
35
35
 
@@ -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(log_file_name="", verbose=0, console=True):
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 log_file_name or log_file_name == "":
95
- log_file_name = get_invoke_file_name() + ".log"
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
- log_filename, maxBytes=5 * 1024 * 1024, backupCount=1
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
- bes_conn = besapi.besapi.get_bes_conn_using_config_file()
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: besapi
3
- Version: 3.3.3
3
+ Version: 3.4.1
4
4
  Summary: Library for working with the BigFix REST API
5
5
  Home-page: https://github.com/jgstew/besapi
6
6
  Author: Matt Hansen, James Stewart
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