Skip to content

Commit

Permalink
Add parameter "--exposure-time", defaulting to 0.5 seconds
Browse files Browse the repository at this point in the history
Unfortunately, events for the React panels can not be captured.
  • Loading branch information
amotl committed Nov 15, 2021
1 parent 7a9f6ce commit 1f183d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions grafanimate/animations.py
Expand Up @@ -2,6 +2,8 @@
# (c) 2018 Andreas Motl <andreas@hiveeyes.org>
# License: GNU Affero General Public License, Version 3
import logging
import time

from munch import munchify
from datetime import timedelta
from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -85,6 +87,10 @@ def run(self, dtstart=None, dtuntil=None, interval=None):

yield item

if self.options["exposure-time"] > 0:
logger.info("Waiting for {} seconds (exposure time)".format(self.options["exposure-time"]))
time.sleep(self.options["exposure-time"])

self.log("Animation finished")

def get_freq_delta(self, interval):
Expand Down
3 changes: 3 additions & 0 deletions grafanimate/commands.py
Expand Up @@ -24,6 +24,7 @@ def run():
--dashboard-uid=<uid> Grafana dashboard uid.
Optional:
--exposure-time=<seconds> How long to wait for each frame to complete rendering. [default: 0.5]
--panel-id=<id> Render single panel only by navigating to "panelId=<id>&fullscreen".
--dashboard-view=<mode> Use Grafana's "d-solo" view for rendering single panels without header.
Expand Down Expand Up @@ -104,6 +105,8 @@ def run():
if options['dashboard-view'] == 'd-solo' and not options['panel-id']:
raise DocoptExit('Error: Parameter --panel-id is mandatory for --dashboard-view=d-solo')

options['exposure-time'] = float(options['exposure-time'])

# Define and run Pipeline.

# Define pipeline elements.
Expand Down
2 changes: 1 addition & 1 deletion grafanimate/core.py
Expand Up @@ -29,7 +29,7 @@ def make_animation(grafana: GrafanaWrapper, storage, options):
grafana=grafana,
storage=storage,
dashboard_uid=options['dashboard-uid'],
options=filter_dict(options, ['panel-id', 'dashboard-view', 'header-layout', 'datetime-format'])
options=filter_dict(options, ['panel-id', 'dashboard-view', 'header-layout', 'datetime-format', 'exposure-time'])
)
if not hasattr(scenario, options.scenario):
raise NotImplementedError('Animation scenario "{}" not implemented'.format(options.scenario))
Expand Down

0 comments on commit 1f183d1

Please sign in to comment.