diff --git a/contrib/banner/banner-template.svg b/contrib/banner/banner-template.svg index 25856fd471f13c0730de1c09297c89b1ac9ee496..a5a26602748feeb5cdaab45352830cdb96c8557c 100644 --- a/contrib/banner/banner-template.svg +++ b/contrib/banner/banner-template.svg @@ -10,9 +10,9 @@ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" id="svg2" - viewBox="0 0 1007.991 379.57382" - height="107.12417mm" - width="284.47745mm" + viewBox="0 0 1027.5591 814.96067" + height="230mm" + width="290mm" inkscape:version="0.91 r" sodipodi:docname="banner-template.svg"> <sodipodi:namedview @@ -25,65 +25,59 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1680" - inkscape:window-height="1011" + inkscape:window-height="984" id="namedview24" showgrid="false" - inkscape:zoom="0.89702958" - inkscape:cx="434.90348" - inkscape:cy="78.342718" - inkscape:window-x="1680" - inkscape:window-y="0" + inkscape:zoom="2" + inkscape:cx="376.66489" + inkscape:cy="563.27578" + inkscape:window-x="0" + inkscape:window-y="27" inkscape:window-maximized="1" - inkscape:current-layer="svg2" + inkscape:current-layer="layer2" showguides="true" - inkscape:guide-bbox="true" - fit-margin-right="10" - fit-margin-top="10" - fit-margin-left="10" - fit-margin-bottom="10"> + inkscape:guide-bbox="true"> <sodipodi:guide - position="233.60404,305.40708" + position="262.49588,721.27247" orientation="0,1" id="guide5200" /> <sodipodi:guide - position="209.16749,245.10398" + position="238.05933,660.96936" orientation="0,1" id="guide5202" /> <sodipodi:guide - position="209.16749,185.19502" + position="238.05933,601.06039" orientation="0,1" id="guide5204" /> <sodipodi:guide - position="175.66576,125.28606" + position="204.5576,541.15142" orientation="0,1" id="guide5206" /> <sodipodi:guide - position="89.349554,225.39708" + position="118.24139,641.26246" orientation="1,0" id="guide5208" /> <sodipodi:guide - position="515.90535,174.94744" + position="544.79719,590.81281" orientation="1,0" id="guide5258" /> <sodipodi:guide - position="121.04748,89.134736" + position="149.93932,505.0001" orientation="1,0" id="guide6011" /> <sodipodi:guide - position="86.886194,306.78658" + position="115.77803,722.65197" orientation="1,0" id="guide4716" /> <sodipodi:guide - position="280.60187,65.234656" + position="309.49371,481.10002" orientation="0,1" id="guide5441" inkscape:label="" inkscape:color="rgb(0,0,255)" /> <inkscape:grid type="xygrid" - id="grid5443" - originx="-178.89184" - originy="-896.57885" /> + id="grid5443" /> </sodipodi:namedview> <defs id="defs4"> @@ -2296,7 +2290,7 @@ <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> + <dc:title /> </cc:Work> </rdf:RDF> </metadata> @@ -2305,58 +2299,58 @@ id="rect3336" width="551.54327" height="563.6651" - x="43.839142" - y="-55.109306" /> + x="72.73098" + y="-35.587784" /> <rect style="opacity:0;fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:2.5;stroke-linejoin:round;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect4138" width="346.48233" height="309.10669" - x="161.01683" - y="130.75873" /> + x="189.90868" + y="150.28026" /> <ellipse style="opacity:0;fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:2.5;stroke-linejoin:round;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="path4140" - cx="425.67679" - cy="217.63187" + cx="454.56863" + cy="237.1534" rx="239.40616" ry="194.95944" /> <ellipse style="opacity:0;fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:2.5;stroke-linejoin:round;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="path4142" - cx="218.71019" - cy="201.95639" + cx="247.60204" + cy="221.47792" rx="110.6117" ry="16.162441" /> <ellipse style="opacity:0;fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:2.5;stroke-linejoin:round;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="path4144" - cx="253.4458" - cy="200.45926" + cx="282.33765" + cy="219.98079" rx="127.78429" ry="142.4315" /> <text sodipodi:linespacing="125%" xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:125%;font-family:'Open Sans';-inkscape-font-specification:'Open Sans';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="100.40769" - y="204.49988" + x="129.29953" + y="224.02141" id="text4146"><tspan id="tspan4148" - x="100.40769" - y="204.49988" /></text> + x="129.29953" + y="224.02141" /></text> <rect style="opacity:0;fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:2.5;stroke-linejoin:round;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect4170" width="376.7869" height="316.17773" - x="277.18439" - y="48.936367" /> + x="306.07623" + y="68.457893" /> <flowRoot xml:space="preserve" id="flowRoot4156" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13px;line-height:125%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - transform="translate(-28.891841,-256.92308)"><flowRegion + transform="translate(0,-237.40156)"><flowRegion id="flowRegion4158"><rect id="rect4160" width="7.8035336" @@ -2367,7 +2361,7 @@ xml:space="preserve" id="flowRoot4164" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13px;line-height:125%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - transform="translate(-28.891841,-256.92308)"><flowRegion + transform="translate(0,-237.40156)"><flowRegion id="flowRegion4166"><rect id="rect4168" width="13.377485" @@ -2378,7 +2372,7 @@ xml:space="preserve" id="flowRoot4172" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13px;line-height:125%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - transform="translate(-28.891841,-256.92308)"><flowRegion + transform="translate(0,-237.40156)"><flowRegion id="flowRegion4174"><rect id="rect4176" width="5.5739522" @@ -2389,7 +2383,7 @@ xml:space="preserve" id="flowRoot4180" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13px;line-height:125%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - transform="translate(-28.891841,-256.92308)"><flowRegion + transform="translate(0,-237.40156)"><flowRegion id="flowRegion4182"><rect id="rect4184" width="30.099342" @@ -2400,7 +2394,7 @@ xml:space="preserve" id="flowRoot4862" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13px;line-height:125%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - transform="translate(-28.891841,-256.92308)"><flowRegion + transform="translate(0,-237.40156)"><flowRegion id="flowRegion4864"><rect id="rect4866" width="363.42169" @@ -2414,7 +2408,7 @@ style="display:inline;opacity:0.46240599;fill:url(#linearGradient7658);fill-opacity:1;stroke:none;stroke-width:1.00000024;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1" id="path5806" d="m 11.6875,11 c -0.826242,0 -1.28475,0.05742 -1.5625,0.242188 -0.2777497,0.184768 -0.5284825,0.580009 -0.8007812,1.521484 l -5.25,18.125 c -0.1708249,0.590628 0.021709,1.039316 0.4902343,1.4375 C 5.0329784,32.724356 5.7975106,33.000001 6.625,33 l 34.71875,0 c 0.744655,0 1.538941,-0.232575 2.03125,-0.609375 0.492309,-0.3768 0.719298,-0.799984 0.519531,-1.503906 l -5.0625,-17.875 C 38.52278,11.922001 38.224454,11.462814 37.910156,11.253906 37.595859,11.044998 37.112699,11 36.28125,11 L 11.6875,11 Z" - transform="translate(-28.891841,-251.92308)" /> + transform="translate(0,-232.40156)" /> <path sodipodi:type="inkscape:offset" inkscape:radius="-1.016466" @@ -2422,10 +2416,9 @@ style="display:inline;opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="path6463" d="m 7.03125,1.515625 c -0.8685059,0 -1.515625,0.6471191 -1.515625,1.515625 l 0,4.9375 c 0,0.8685059 0.6471191,1.515625 1.515625,1.515625 l 34.9375,0 c 0.868506,0 1.515625,-0.647119 1.515625,-1.515625 l 0,-4.9375 c 0,-0.8685066 -0.647117,-1.515625 -1.515625,-1.515625 l -34.9375,0 z" - transform="translate(-28.891841,-256.92308)" /> + transform="translate(0,-237.40156)" /> <g - id="g4257" - transform="translate(-28.891841,-19.521523)"> + id="g4257"> <g inkscape:export-ydpi="90" inkscape:export-xdpi="90" @@ -2692,7 +2685,7 @@ <g id="g10466" inkscape:label="Livello 1" - transform="translate(42.100179,103.05312)"> + transform="translate(70.99202,122.57464)"> <g transform="matrix(0.02216275,0,0,0.01069518,44.21234,36.053672)" id="g10468" @@ -2781,7 +2774,7 @@ </g> <g id="g2229" - transform="translate(7.0322282,98.610519)"> + transform="translate(35.924069,118.13204)"> <path style="fill:url(#linearGradient9767);fill-opacity:1;stroke:#a40000;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" d="m 38.5,57.5 0.90625,15 5.125,0 0.8125,-15 -6.84375,0 z m 0.90625,16.9375 0,5.0625 5.09375,0 0,-5.0625 -5.09375,0 z" @@ -2805,7 +2798,7 @@ <g inkscape:label="Layer 1" id="layer1-0" - transform="translate(42.302385,161.42612)"> + transform="translate(71.194226,180.94764)"> <g transform="matrix(0.958333,0,0,1,1,1)" style="opacity:0.3" @@ -3294,7 +3287,7 @@ </g> <g id="g5921" - transform="translate(40.982666,281.24679)"> + transform="translate(69.874507,300.76831)"> <g style="display:inline" inkscape:label="Shadow" @@ -3558,69 +3551,37 @@ <text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="516.12988" - y="314.48453" + x="545.02173" + y="334.00604" id="latest" sodipodi:linespacing="150%" inkscape:label="#text5963">AA:BB:CC, XX. YY. ZZZZ</text> <text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="515.72296" - y="194.41182" + x="544.61481" + y="213.93335" id="senders" sodipodi:linespacing="150%" inkscape:label="#text5967">XXXXXXXXXX</text> <text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="515.81622" - y="134.43459" + x="544.70807" + y="153.95612" id="events" sodipodi:linespacing="150%" inkscape:label="#text5967-3">XXXXXXXXXX</text> <text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="515.78394" - y="74.17466" + x="544.67578" + y="93.696182" id="database" sodipodi:linespacing="150%" inkscape:label="#text5967-3-6">XXXXXXXXXX</text> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#0066a5;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="118.17847" - y="74.237312" - id="text6017" - sodipodi:linespacing="150%"><tspan - sodipodi:role="line" - id="tspan6019" - x="118.17847" - y="74.237312" - style="font-size:40px;line-height:150%">Database Size:</tspan><tspan - sodipodi:role="line" - x="118.17847" - y="134.2373" - id="tspan6021" - style="font-size:40px;line-height:150%">Number of Events:</tspan><tspan - sodipodi:role="line" - x="118.17847" - y="194.2373" - id="tspan6023" - style="font-size:40px;line-height:150%">Number of Senders:</tspan><tspan - sodipodi:role="line" - x="118.17847" - y="254.2373" - id="tspan6025" - style="font-size:40px;line-height:150%">Number of Receivers:</tspan><tspan - sodipodi:role="line" - x="118.17847" - y="314.2373" - style="font-size:40px;line-height:150%" - id="tspan5523">Banner Created:</tspan></text> <g - transform="translate(24.810739,-13.79947)" + transform="translate(53.70258,5.7220531)" id="g4221-1"> <g transform="translate(17.093975,-1.7261365)" @@ -3857,7 +3818,7 @@ </g> <g id="g4221" - transform="translate(24.809456,-21.837084)"> + transform="translate(53.701297,-2.3155606)"> <g transform="translate(17.093975,-1.7261365)" id="g5672-0"> @@ -4093,7 +4054,7 @@ </g> <g id="g4093" - transform="translate(-101.47156,12.096653)"> + transform="translate(-72.579721,31.618176)"> <path style="display:inline;overflow:visible;visibility:visible;opacity:0.29946522;fill:url(#radialGradient1444);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none" id="path8660-9" @@ -4117,7 +4078,7 @@ </g> <g id="g5445" - transform="translate(108.71158,48.393376)"> + transform="translate(137.60342,67.914899)"> <g transform="translate(-66.806479,172.90091)" id="layer1-0-0" @@ -4632,9 +4593,55 @@ <text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="515.77136" - y="254.27832" + x="544.66321" + y="273.79984" id="receivers" sodipodi:linespacing="150%" inkscape:label="#text5967">XXXXXXXXXX</text> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="text" + style="display:inline"> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;fill:#0066a5;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="149.69128" + y="93.724373" + id="database-text" + sodipodi:linespacing="150%" + inkscape:label="#text5967-3-6">XXXXXXXXXX</text> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;display:inline;fill:#0066a5;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="149.77249" + y="153.97942" + id="events-text" + sodipodi:linespacing="150%" + inkscape:label="#text5967-3-6">XXXXXXXXXX</text> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;display:inline;fill:#0066a5;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="149.75029" + y="213.91705" + id="senders-text" + sodipodi:linespacing="150%" + inkscape:label="#text5967-3-6">XXXXXXXXXX</text> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;display:inline;fill:#0066a5;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="149.75858" + y="273.80688" + id="receivers-text" + sodipodi:linespacing="150%" + inkscape:label="#text5967-3-6">XXXXXXXXXX</text> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:150%;font-family:Arial;-inkscape-font-specification:Sans;letter-spacing:0px;word-spacing:1.70000005px;display:inline;fill:#0066a5;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="149.7755" + y="333.8858" + id="latest-text" + sodipodi:linespacing="150%" + inkscape:label="#text5967-3-6">XXXXXXXXXX</text> + </g> </svg> diff --git a/contrib/banner/banner.py b/contrib/banner/banner.py index fc94c5de27876179d554aaae94fcc98d5ac31852..751d69de2770be7518114a6902aceeab1a65f0eb 100755 --- a/contrib/banner/banner.py +++ b/contrib/banner/banner.py @@ -3,7 +3,7 @@ # # banner.py # -# Copyright 2015 CESNET z. s. p. o. +# Copyright 2015 CESNET z. s. p. o. # Author Jakub Cegan cegan@ics.muni.cz # # @@ -15,8 +15,11 @@ def main(args): # We set up path and names banner_path = "/var/www/banner/" - banner_name = "banner.svg" - template_name = "banner-template.svg" + banner_name_cz = "banner-cz.svg" + banner_name_en = "banner-en.svg" + template_name = "banner-template.svg" + + banners = [{'name': banner_name_en, 'database' : "Database Size:", 'events' : "Number of Events:", 'senders' : "Number of Senders:", 'receivers' : "Number of Receivers:", 'created' : "Banner Created:"}, {'name': banner_name_cz, 'database' : "Velikost databáze:", 'events' : "Suma všech událostĂ:", 'senders' : "OdesĂlajĂcĂ klienti:", 'receivers' : "PĹ™ijĂmajĂcĂ klienti:", 'created' : "Banner vytvoĹ™en:"}] # We have DB credentials user = "warden" @@ -30,43 +33,64 @@ def main(args): cursor.execute('SELECT count(*) AS reader_count FROM clients WHERE clients.read <> 0 AND clients.valid <> 0 AND clients.test = 0;') row = cursor.fetchone() receivers = str(row[0]) + #receivers = str(random.randint(0,100)) cursor.execute('SELECT count(*) AS writer_count FROM clients WHERE clients.write <> 0 AND clients.valid <> 0 AND clients.test = 0;') row = cursor.fetchone() senders = str(row[0]) + #senders = str(random.randint(0,100)) cursor.execute('SELECT sum(round(((data_length + index_length) / 1024 / 1024 / 1024), 2)) AS db_size FROM information_schema.tables WHERE table_schema = "warden3" AND table_name="events"') row = cursor.fetchone() database_size = str(row[0]) + ' GB' + #database_size = str(random.randint(0,50)) + ' GB' cursor.execute('SELECT max(id) - min(id) AS event_count FROM events;') row = cursor.fetchone() events = str(row[0]) + #events = str(random.randint(0,10000000)) - cursor.execute('SELECT max(id) AS last_id FROM events;') - row = cursor.fetchone() - last_event = str(row[0]) + #cursor.execute('SELECT max(id) AS last_id FROM events;') + #row = cursor.fetchone() + #last_event = str(row[0]) time = datetime.datetime.today().strftime("%Y-%m-%dT%H:%M:%S%Z") - xml_data = etree.parse(template_name) - - # We search for element 'text' with id='tile_text' in SVG namespace - find_text = etree.ETXPath("//{%s}text[@id='database']" % (SVGNS)) - find_text(xml_data)[0].text = database_size - find_text = etree.ETXPath("//{%s}text[@id='events']" % (SVGNS)) - find_text(xml_data)[0].text = events - find_text = etree.ETXPath("//{%s}text[@id='senders']" % (SVGNS)) - find_text(xml_data)[0].text = senders - find_text = etree.ETXPath("//{%s}text[@id='receivers']" % (SVGNS)) - find_text(xml_data)[0].text = receivers - find_text = etree.ETXPath("//{%s}text[@id='latest']" % (SVGNS)) - find_text(xml_data)[0].text = time - new_svg = etree.tostring(xml_data) - - xml_data.write(banner_path + banner_name) - - # We will not use pygal graphs for now + for banner in banners: + + xml_data = etree.parse(template_name) + + # We search for element 'text' with id='tile_text' in SVG namespace + + # Fill texts + find_text = etree.ETXPath("//{%s}text[@id='database-text']" % (SVGNS)) + find_text(xml_data)[0].text = unicode(banner['database'], "utf-8") + find_text = etree.ETXPath("//{%s}text[@id='events-text']" % (SVGNS)) + find_text(xml_data)[0].text = unicode(banner['events'], "utf-8") + find_text = etree.ETXPath("//{%s}text[@id='senders-text']" % (SVGNS)) + find_text(xml_data)[0].text = unicode(banner['senders'], "utf-8") + find_text = etree.ETXPath("//{%s}text[@id='receivers-text']" % (SVGNS)) + find_text(xml_data)[0].text = unicode(banner['receivers'], "utf-8") + find_text = etree.ETXPath("//{%s}text[@id='latest-text']" % (SVGNS)) + find_text(xml_data)[0].text = unicode(banner['created'], "utf-8") + + # Insert values from database + find_text = etree.ETXPath("//{%s}text[@id='database']" % (SVGNS)) + find_text(xml_data)[0].text = database_size + find_text = etree.ETXPath("//{%s}text[@id='events']" % (SVGNS)) + find_text(xml_data)[0].text = events + find_text = etree.ETXPath("//{%s}text[@id='senders']" % (SVGNS)) + find_text(xml_data)[0].text = senders + find_text = etree.ETXPath("//{%s}text[@id='receivers']" % (SVGNS)) + find_text(xml_data)[0].text = receivers + find_text = etree.ETXPath("//{%s}text[@id='latest']" % (SVGNS)) + find_text(xml_data)[0].text = time + + # Write edited svg into file + new_svg = etree.tostring(xml_data) + xml_data.write(banner_path + banner['name']) + + # We will not use pygal graphs for now #chart = pygal.StackedLine(fill=True, style=CleanStyle, x_label_rotation=40, tooltip_border_radius=10) # Setting style here is not necessary #chart.title = 'Events in last 24 hours' #chart.x_labels = map(lambda d: d.strftime('%H:%M:%S'), reversed([base - datetime.timedelta(hours=x) for x in range(0, 24)])) @@ -93,6 +117,6 @@ if __name__ == '__main__': import datetime import MySQLdb from lxml import etree - #import pygal + #import pygal #from pygal.style import CleanStyle sys.exit(main(sys.argv))