10
10
except ImportError :
11
11
from urlparse import urlparse
12
12
13
+ CURRENT_TIMESTAMP = int (time .time ())
14
+
13
15
14
16
@click .command ()
15
17
@click .option ('-u' , '--uri' , 'annotate_uri' ,
18
20
@click .option ('-T' , '--title' , 'title' , default = 'event' , help = 'Event title. Default: "event".' )
19
21
@click .option ('-t' , '--tag' , 'tags' , multiple = True , help = 'Event tags (can be used multiple times).' )
20
22
@click .option ('-d' , '--description' , 'description' , help = 'Event description body. Optional.' )
21
- @click .option ('-s' , '--start' , 'start_time' ,
22
- default = int (time .time ()),
23
+ @click .option ('-s' , '--start' , 'start_time' , default = CURRENT_TIMESTAMP ,
23
24
help = 'Start timestamp (unix secs). Default: current timestamp.' )
24
- @click .option ('-e' , '--end' , 'end_time' , default = 0 , help = 'End timestamp (unix secs). Optional.' )
25
+ @click .option ('-e' , '--end' , 'end_time' , default = CURRENT_TIMESTAMP ,
26
+ help = 'End timestamp (unix secs). Optional.' )
25
27
def main (annotate_uri , title , tags , description , start_time , end_time ):
26
28
""" Send Grafana annotations """
27
29
@@ -46,7 +48,7 @@ def main(annotate_uri, title, tags, description, start_time, end_time):
46
48
event_data ['text' ] = '<b>%s</b>\n \n %s' % (title , description )
47
49
event_data ['tags' ] = tags
48
50
event_data ['time' ] = int (round (start_time * 1000 ))
49
- if end_time > 0 :
51
+ if end_time != start_time :
50
52
if end_time < start_time :
51
53
raise Exception ('Event end time cannot be before start time.' )
52
54
event_data ['isRegion' ] = True
0 commit comments