introduction to django web application framework and ...€¦ · introduction to django web...

14
Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz

Upload: others

Post on 29-Jul-2020

37 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Introduction to Django Web Application Framework and

Monitoring integration with I3LiveKai Schatto

Mainz

Page 2: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Django web application framework(Open source --- Python --- model-view-controller pattern)

• Object-relational mapping for MySQL, Oracle, PostgreSQL und SQLite

• view system for processing requests

• flexible URL configuration with reg. expr.

• Template system

• dynamic administrative interface

• Caching

• internationalization system

• authentication system

• form serialization and validation system

• etc …. http://www.djangoproject.com/

Page 3: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Django Database useDatabase tables (models)

class Trigger(models.Model):run = models.ForeignKey(MoniRun)trigger_type = models.ForeignKey(TriggerType)rate = models.CharField(max_length=50)rate_err = models.CharField(max_length=50)

Database access

# get all Triggers for run 114758 from Databasecurrent_run = MoniRun.objects.get(number = „114758“)for trigger in Trigger.objects.filter(run = current_run):

my_rate = trigger.ratemy_rate_err = trigger.rate_err…

MySQL Server

Raw SQL command

Python MySQLdb binding

Django ORM

Django code

Page 4: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Django Template System1. PageRequest for „https://live.icecube.wisc.edu/anypage/“

2. Call the python function assigned to this address

3. Collect and process necessary data and provide to template

4. Render page with integrated data

Template example<p>Dear {{ person_name }},</p><p>Thanks for placing an order from {{ company }}.

It's scheduled to ship on {{ship_date}}.</p>

<p>Here are the items you've ordered:</p>

<ul>{% for item in item_list %}<li>{{ item }}</li>{% endfor %}</ul>

{% if ordered_warranty %} <p>Your warranty information will be included in the packaging.</p> {% endif %}

Page 5: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Run Info

Etc.

– lxml for parsing (http://codespeak.net/lxml/)

– MySQL DB

• XML DB with lxml (Problem: corrupted XML files)

• automatic script checking for new data and saving to database

ATWD

MPE Scaler

SPE Scaler

Launches

Moni integration - Technology

All DomsBad Doms

Dead Doms

FilterSN alarms

TriggerDaily script Database

Backbone delivers bunch of xml-files

Daq-Config

Page 6: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Parsing XML files

• Using lxml

– Pythonic binding for the libxml2 and libxsltlibraries

– Fast!

– Easy, pythonic interface

lxml example# parsetree = lxml.etree.parse(path)# loop over all doms

for dom in tree.findall('.//' + „dom“):my_text = dom.findtext(„mainBoard_ID“)

Xml File<run><dom>

…<mainBoard_ID>j6dn2hGH5</mainBoard_ID>…

</dom> <dom>

…<mainBoard_ID>g836gj2hjd</mainBoard_ID>…

</dom></run>

Page 7: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Calendar Page

Moni schedule integrated

Page 8: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Run page – Recent Issues

Page 9: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Run page – Info System

Page 10: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Run page – Report Issues

Page 11: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Run page – Report Dom problems

Page 12: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Run page – Act on issues

Page 13: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

Dom Map

Page 14: Introduction to Django Web Application Framework and ...€¦ · Introduction to Django Web Application Framework and Monitoring integration with I3Live Kai Schatto Mainz. Django

ToDo

• Implementation of Sebastians suggestions

• Code Review

• Migration to Madison

• Testing