response = request(method, url, json_dump(new_config) if new_config else None)
if response.status != 200:
- print(response)
+ print(response, file=sys.stderr)
sys.exit(1)
if self.operation == Operations.GET and self.file:
lua = KresConfig(parsed).render_lua()
reset_global_validation_context()
except (DataParsingError, DataValidationError) as e:
- print(e)
+ print(e, file=sys.stderr)
sys.exit(1)
if self.output_file:
else:
print(response.body)
else:
- print(response)
+ print(response, file=sys.stderr)
sys.exit(1)
response = request("POST", f"{args.socket}/reload")
if response.status != 200:
- print(response)
+ print(response, file=sys.stderr)
sys.exit(1)
if self.live:
response = request("GET", f"{args.socket}/schema")
if response.status != 200:
- print(response)
+ print(response, file=sys.stderr)
sys.exit(1)
schema = response.body
else:
response = request("POST", f"{args.socket}/stop")
if response.status != 200:
- print(response)
+ print(response, file=sys.stderr)
sys.exit(1)
@staticmethod
KresConfig(try_to_parse(data))
reset_global_validation_context()
except (DataParsingError, DataValidationError) as e:
- print(e)
+ print(e, file=sys.stderr)
sys.exit(1)
return Response(err.code, err.read().decode("utf8"))
except URLError as err:
if err.errno == 111 or isinstance(err.reason, ConnectionRefusedError):
- print("Connection refused.")
- print(f"\tURL: {url}")
- print("Is the URL correct?")
- print("\tUnix socket would start with http+unix:// and URL encoded path.")
- print("\tInet sockets would start with http:// and domain or ip")
+ msg = f"""
+ Connection refused.
+ \tURL: {url}
+ Is the URL correct?
+ \tUnix socket would start with http+unix:// and URL encoded path.
+ \tInet sockets would start with http:// and domain or ip
+ """
+ print(msg, file=sys.stderr)
else:
print(f"{err}: url={url}", file=sys.stderr)
sys.exit(1)