Skip to content
Browse files

examples: python: whitespacing

  • Loading branch information...
1 parent 121625e commit f509f1131182a157d7362b944335a0df0b08f9ce @SaveTheRbtz committed Dec 10, 2012
Showing with 5 additions and 6 deletions.
  1. +5 −6 examples/python_example.py
View
11 examples/python_example.py
@@ -6,7 +6,7 @@
# Sends statistics to the stats daemon over UDP
class StatsdClient(object):
def __init__(self, host='localhost', port=8125):
- self.addr=(host, port)
+ self.addr = (host, port)
def timing(self, stat, time, sample_rate=1):
"""
@@ -24,7 +24,7 @@ def increment(self, stats, sample_rate=1):
Increments one or more stats counters
>>> client = StatsdClient()
>>> client.increment('some.int')
- >>> client.increment('some.int',0.5)
+ >>> client.increment('some.int', 0.5)
"""
self.update_stats(stats, 1, sample_rate)
@@ -40,14 +40,13 @@ def update_stats(self, stats, delta=1, sampleRate=1):
"""
Updates one or more stats counters by arbitrary amounts
>>> client = StatsdClient()
- >>> client.update_stats('some.int',10)
+ >>> client.update_stats('some.int', 10)
"""
if isinstance(stats, list):
stats = [stats]
data = {}
for stat in stats:
data[stat] = "%s|c" % delta
-
self.send(data, sampleRate)
def send(self, data, sample_rate=1):
@@ -56,13 +55,13 @@ def send(self, data, sample_rate=1):
"""
sampled_data = {}
- if(sample_rate < 1):
+ if (sample_rate < 1):
import random
if random.random() <= sample_rate:
for stat, value in data.items():
sampled_data[stat] = "%s|@%s" %(value, sample_rate)
else:
- sampled_data=data
+ sampled_data = data
from socket import socket, AF_INET, SOCK_DGRAM
udp_sock = socket(AF_INET, SOCK_DGRAM)

0 comments on commit f509f11

Please sign in to comment.
Something went wrong with that request. Please try again.