How to use create_embedded_plot method in autotest

Best Python code snippet using autotest_python

graphing_utils.py

Source:graphing_utils.py Github

copy

Full Screen

...645 plot_info = QualificationHistogram(query, filter_string, interval,646 drilldown_callback)647 figure, area_data = _create_qual_histogram_helper(plot_info, extra_text)648 return _create_image_html(figure, area_data, plot_info)649def create_embedded_plot(model, update_time):650 """\651 Given an EmbeddedGraphingQuery object, generate the PNG image for it.652 model: EmbeddedGraphingQuery object653 update_time: 'Last updated' time654 """655 params = pickle.loads(model.params)656 extra_text = 'Last updated: %s' % update_time657 if model.graph_type == 'metrics':658 plot_info = MetricsPlot(query_dict=params['queries'],659 plot_type=params['plot'],660 inverted_series=params['invert'],661 normalize_to=None,662 drilldown_callback='')663 figure, areas_unused = _create_metrics_plot_helper(plot_info,664 extra_text)665 elif model.graph_type == 'qual':666 plot_info = QualificationHistogram(667 query=params['query'], filter_string=params['filter_string'],668 interval=params['interval'], drilldown_callback='')669 figure, areas_unused = _create_qual_histogram_helper(plot_info,670 extra_text)671 else:672 raise ValueError('Invalid graph_type %s' % model.graph_type)673 image, bounding_box_unused = _create_png(figure)674 return image675_cache_timeout = global_config.global_config.get_config_value(676 'AUTOTEST_WEB', 'graph_cache_creation_timeout_minutes')677def handle_plot_request(id, max_age):678 """\679 Given the embedding id of a graph, generate a PNG of the embedded graph680 associated with that id.681 id: id of the embedded graph682 max_age: maximum age, in minutes, that a cached version should be held683 """684 model = models.EmbeddedGraphingQuery.objects.get(id=id)685 # Check if the cached image needs to be updated686 now = datetime.datetime.now()687 update_time = model.last_updated + datetime.timedelta(minutes=int(max_age))688 if now > update_time:689 cursor = django.db.connection.cursor()690 # We want this query to update the refresh_time only once, even if691 # multiple threads are running it at the same time. That is, only the692 # first thread will win the race, and it will be the one to update the693 # cached image; all other threads will show that they updated 0 rows694 query = """695 UPDATE embedded_graphing_queries696 SET refresh_time = NOW()697 WHERE id = %s AND (698 refresh_time IS NULL OR699 refresh_time + INTERVAL %s MINUTE < NOW()700 )701 """702 cursor.execute(query, (id, _cache_timeout))703 # Only refresh the cached image if we were successful in updating the704 # refresh time705 if cursor.rowcount:706 model.cached_png = create_embedded_plot(model, now.ctime())707 model.last_updated = now708 model.refresh_time = None709 model.save()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful