Commit d5164037 by Gregory Nagy

client.py: environment error handling sequence changed

parent f1892912
...@@ -20,31 +20,32 @@ class Client: ...@@ -20,31 +20,32 @@ class Client:
hostname = socket.gethostname().split('.') hostname = socket.gethostname().split('.')
hostname.reverse() hostname.reverse()
self.name = "circle." + ".".join(hostname) self.name = "circle." + ".".join(hostname)
self.server_address = str(os.getenv("GRAPHITE_SERVER_ADDRESS")) if os.getenv("GRAPHITE_SERVER_ADDRESS") is None:
self.server_port = int(os.getenv("GRAPHITE_SERVER_PORT"))
self.debugMode = config["debugMode"]
self.amqp_user = str(os.getenv("GRAPHITE_AMQP_USER"))
self.amqp_pass = str(os.getenv("GRAPHITE_AMQP_PASSWORD"))
self.amqp_queue = str(os.getenv("GRAPHITE_AMQP_QUEUE"))
self.amqp_vhost = str(os.getenv("GRAPHITE_AMQP_VHOST"))
self.beat = 1
if self.server_address is None:
print("GRAPHITE_SERVER_ADDRESS cannot be found in environmental " print("GRAPHITE_SERVER_ADDRESS cannot be found in environmental "
"variables" "variables"
) )
if self.server_port is None: if os.getenv("GRAPHITE_SERVER_PORT") is None:
print("GRAPHITE_SERVER_PORT cannot be found in environmental " print("GRAPHITE_SERVER_PORT cannot be found in environmental "
"variables. (AMQP standard is: 5672" "variables. (AMQP standard is: 5672"
) )
if self.amqp_user is None or self.amqp_user is None: if os.getenv("GRAPHITE_AMQP_USER") is None or os.getenv("GRAPHITE_AMQP_PASSWORD") is None:
print("GRAPHITE_AMQP_USER or GRAPHITE_AMQP_PASSWORD cannot be " print("GRAPHITE_AMQP_USER or GRAPHITE_AMQP_PASSWORD cannot be "
"found in environmental variables. (AMQP standard is: " "found in environmental variables. (AMQP standard is: "
"guest-guest)" "guest-guest)"
) )
if self.amqp_queue is None or self.amqp_vhost is None: if os.getenv("GRAPHITE_AMQP_QUEUE") is None or os.getenv("GRAPHITE_AMQP_VHOST") is None:
print("GRAPHITE_AMQP_QUEUE or GRAPHITE_AMQP_VHOST cannot be " print("GRAPHITE_AMQP_QUEUE or GRAPHITE_AMQP_VHOST cannot be "
"found in environmental variables." "found in environmental variables."
) )
self.server_address = str(os.getenv("GRAPHITE_SERVER_ADDRESS"))
self.server_port = int(os.getenv("GRAPHITE_SERVER_PORT"))
self.debugMode = config["debugMode"]
self.amqp_user = str(os.getenv("GRAPHITE_AMQP_USER"))
self.amqp_pass = str(os.getenv("GRAPHITE_AMQP_PASSWORD"))
self.amqp_queue = str(os.getenv("GRAPHITE_AMQP_QUEUE"))
self.amqp_vhost = str(os.getenv("GRAPHITE_AMQP_VHOST"))
self.beat = 1
def __connect(self): def __connect(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment