|
6 | 6 |
|
7 | 7 | from .network import CFnetwork |
8 | 8 | from .logging_helper import CFlogger |
9 | | -from .utils import user_agent, sanitize_secrets |
| 9 | +from .utils import user_agent, build_curl |
10 | 10 | from .read_configs import read_configs |
11 | 11 | from .api_v4 import api_v4 |
12 | 12 | from .api_extras import api_extras |
@@ -164,29 +164,6 @@ def _call_network(self, method, headers, parts, |
164 | 164 | params=None, data=None, files=None): |
165 | 165 | """ Cloudflare v4 API""" |
166 | 166 |
|
167 | | - if self.logger: |
168 | | - self.logger.debug('Call: %s,%s,%s,%s,%s,%s', |
169 | | - str(parts[0]), |
170 | | - str(identifier1), |
171 | | - str(parts[1]), |
172 | | - str(identifier2), |
173 | | - str(parts[2]), |
174 | | - str(identifier3)) |
175 | | - if params is not None: |
176 | | - try: |
177 | | - str_params = json.dumps(params) |
178 | | - except: |
179 | | - str_params = str(params) |
180 | | - self.logger.debug('Call: params=%s', str_params) |
181 | | - if data is not None: |
182 | | - try: |
183 | | - str_data = json.dumps(data) |
184 | | - except: |
185 | | - str_data = str(data) |
186 | | - self.logger.debug('Call: data=%s', str_data) |
187 | | - if files is not None: |
188 | | - self.logger.debug('Call: upload file %r', files) |
189 | | - |
190 | 167 | if (method is None) or (parts[0] is None): |
191 | 168 | # should never happen |
192 | 169 | raise CloudFlareInternalError(0, 'You must specify a method and endpoint') |
@@ -219,23 +196,16 @@ def _call_network(self, method, headers, parts, |
219 | 196 | url += '/' + identifier3 |
220 | 197 |
|
221 | 198 | if self.logger: |
222 | | - self.logger.debug('Call: method=%s url=%s', str(method), str(url)) |
223 | | - self.logger.debug('Call: headers=%s', str(sanitize_secrets(headers))) |
| 199 | + msg = build_curl(method, url, headers, params, data, files) |
| 200 | + self.logger.debug('Call: emulated curl command ...\n' + msg) |
224 | 201 |
|
225 | 202 | try: |
226 | | - if self.logger: |
227 | | - self.logger.debug('Call: doit!') |
228 | 203 | response = self.network(method, url, headers, params, data, files) |
229 | | - if self.logger: |
230 | | - self.logger.debug('Call: done!') |
231 | 204 | except Exception as e: |
232 | 205 | if self.logger: |
233 | 206 | self.logger.debug('Call: exception! "%s"' % (e)) |
234 | 207 | raise CloudFlareAPIError(0, 'connection failed.') |
235 | 208 |
|
236 | | - if self.logger: |
237 | | - self.logger.debug('Response: url=%s', response.url) |
238 | | - |
239 | 209 | # Create response_{type|code|data} |
240 | 210 | try: |
241 | 211 | response_type = response.headers['Content-Type'] |
@@ -929,8 +899,8 @@ def __init__(self, email=None, token=None, certtoken=None, debug=False, raw=Fals |
929 | 899 |
|
930 | 900 | try: |
931 | 901 | config = read_configs(profile) |
932 | | - except: |
933 | | - raise CloudFlareAPIError(0, 'profile/configuration read error') |
| 902 | + except Exception as e: |
| 903 | + raise CloudFlareAPIError(0, str(e)) |
934 | 904 |
|
935 | 905 | # class creation values override all configuration values |
936 | 906 | if email is not None: |
|
0 commit comments