Skip to content


fix: improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Dec 6, 2020
1 parent e0eb2c0 commit 56e2f10
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions aw_client/
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import argparse
from datetime import timedelta, datetime, timezone
from pprint import pprint

import click

Expand Down Expand Up @@ -55,28 +54,28 @@ def main(ctx, testing: bool, host: str, port: int):
@click.option("--pulsetime", default=60, help="pulsetime to use for merging heartbeats")
def heartbeat(ctx, bucket_id: str, data: str, pulsetime: int):
def heartbeat(obj: _Context, bucket_id: str, data: str, pulsetime: int):
now =
e = Event(duration=0, data=json.loads(data), timestamp=now)
ctx.obj.client.heartbeat(bucket_id, e, pulsetime)
obj.client.heartbeat(bucket_id, e, pulsetime)

@main.command(help="List all buckets")
def buckets(ctx):
buckets = ctx.obj.client.get_buckets()
def buckets(obj: _Context):
buckets = obj.client.get_buckets()
for bucket in buckets:
print(" - {}".format(bucket))

@main.command(help="Query events from bucket with ID `bucket_id`")
def events(ctx, bucket_id: str):
events = ctx.obj.client.get_events(bucket_id)
def events(obj: _Context, bucket_id: str):
events = obj.client.get_events(bucket_id)
for e in events:
Expand All @@ -95,9 +94,9 @@ def events(ctx, bucket_id: str):
@click.option("--json", is_flag=True)
@click.option("--start", default=now - td1day, type=click.DateTime())
@click.option("--stop", default=now + td1yr, type=click.DateTime())
def query(
obj: _Context,
path: str,
cache: bool,
_json: bool,
Expand All @@ -107,7 +106,7 @@ def query(
with open(path) as f:
query =
result = ctx.obj.client.query(query, [(start, stop)], cache=cache, name=name)
result = obj.client.query(query, [(start, stop)], cache=cache, name=name)
if _json:
Expand Down

0 comments on commit 56e2f10

Please sign in to comment.