;ς
f§ςBc           @   sκ  d  k  Td  k Td  k Td  k Td k Z d k Z d k Z d k Z d k Z d k	 Z	 d k
 Z
 d k Z d k Z d k l Z d  k Td k l Z d f  d     YZ d f  d     YZ d   Z e d	  Z d
   Z d d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! e" d j o‘e# i#   Z$ e$ d Z% e$ d Z& e' Z( e i)   Z* d e* _+ d e* _, d e* _- e# i. d e# i/ e&   e* _0 e# i. d e# i/ e$   e* _1 d e* _0 d e* _1 d e* _2 d d d d  e* _3 d e* _4 d! e* _5 d" e* _6 d e* _7 d# e* _8 d$ e* _9 d% e* _: d e* _; d$ e* _< d$ e* _= d& e* i0 d' e* i1 d( e> e* i-  d) e> e(  e* _? d e* _@ d* e* _A d+ e* _B d$ e* _C d, e* _D d e* _E e e*  \ ZF ZG ZH eF GHn d S(-   (   s   *N(   s   strptime(   s   Sorters   GraphToplistDatac           B   sY   t  Z d Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d Z d Z d Z d   Z RS(   Ni    s    c         C   s   d  S(   N(    (   s   self(    (    s   C:\Python\PL\PL_Toplist.pys   __init__?   s    (   s   __name__s
   __module__s   unit_ins   unit_outs   unit_tots   unit_in_speeds   unit_out_speeds   unit_tot_speeds   unit_avg_in_speeds   unit_avg_out_speeds   unit_avg_tot_speeds   speed_total_in_avgs   speed_total_out_avgs   speed_total_tot_avgs   __init__(    (    (    s   C:\Python\PL\PL_Toplist.pys   GraphToplistData-   s   s
   SpeedGraphc           B   s   t  Z d d d  Z RS(   Ni    c         C   s(   t  d d d d  |  _ t   |  _ d  S(   Ns   sizeBarDatai    s   sizeLineData(   s	   GraphDatas   selfs   datas   GraphSpeedDatas	   speedData(   s   selfs   sizeBarDatas   sizeLineData(    (    s   C:\Python\PL\PL_Toplist.pys   _ini_D   s    (   s   __name__s
   __module__s   _ini_(    (    (    s   C:\Python\PL\PL_Toplist.pys
   SpeedGraphB   s   c         C   si  t  d |  i d |  i d |  i d |  i d t |  i  d |  i d t |  i	   t
 d  t t i t |  i d	   t i t |  i d	   d
  } | d j o | |  _ n
 d |  _ t  t |  i  d  t d j o t i |  i |  i  |  _ n |  i d j o |  i d 7_ n |  i t j  o t |  _ n t |   } |  i t j on t t i d t i d |  i d |  i i t i  d d  d  d } t" i# | | |   | d | f Sn |  i t$ j on t t i d t i d |  i d |  i i t i  d d  d  d } t" i% | | |   | d | f Sn t& i' | |   Sd  S(   Ns   makeToplist: s    s    chartName=s	    groupId=s    force=s    reverseLookup=s    stop=s   DIST-0000-04a9-8e46-eec8s   %Y-%m-%d %H:%MiQ i    i   s    daysinCharts    s    - s   exports   toplist_s   _s   :- s   .csvs   .xml((   s   debugMsgs   toplistGraphs   stat_start_times   stat_end_times	   chartNames   groupIds   strs   forces   reverseLookups   stops   setLicenseCodes   ints   times   mktimes   strptimes   daysInCharts   PL2s   PL_miscs   buildChartPaths
   IP_addresss   db_start_times   toplistDatas	   graphDatas   outputs	   exportCSVs   PL_paths   oss   seps   graph_start_times   graph_end_times	   translates   strings	   maketranss   filenames
   PL2_exports   exportToplistToCSVs	   exportXMLs   exportToplistToXMLs	   drawgraphs   drawToplistGraph(   s   toplistGraphs   daysInCharts	   graphDatas   filename(    (    s   C:\Python\PL\PL_Toplist.pys   toplistImageJ   s.    _
>	JJc   	      C   sΪ  | t j o |  i  } n t i   } t | d  d } | d } d |  i d d !t i	 d t i	 } |  i |  _ |  i |  _ t d |  i d |  i d	 t |  i  d
 t |  i  d t i d t i |   d |  i d } d } t i d t i |   |  i j o |  i o­t d  d |  i d d !t i	 d t i	 d t i	 } |  i d d f j o" t i d t i |   |  _ n |  i d d f j o" t i d t i |   |  _ n |  i d j o" t i d t i |   |  _ n |  i d j oD t i d t i |   |  _ t i d t i | d   |  _ n |  i d j oH t i t |  i d   t i } t i d t i | d   |  _ n |  i d j o |  i |  _ qΞn t | d |  i d |  i i t i d d  d  d |  _ t d |  i d |  i d	 t |  i  d
 t |  i  d t i d t i |   d |  i t i  i! |  i  o |  i" o t# o/ t$ d |  i |  d |  _% t& |  i  } no t$ d  |  i |  d! |  _% t# d j o9 d" |  _% |  i( t) j o t* |   } q7t+ |   } n t, |   } t- | i.  | _/ t0 |  i1  |  _2 |  i1 d j o)|  i1 d j oJ | i/ |  _2 |  i2 d# j  o d$ |  _2 qΕ|  i2 d% j  o d& |  _2 qΕn |  i1 d j  o> |  i2 d% j  o d' |  _3 n |  i2 d# j  o d |  _3 qn |  i2 d( j o d( |  _2 n |  i2 t4 d) d*  j o d+ |  _3 n |  i2 t4 d, d-  j o d. |  _3 n d/ |  i2 d0 |  _3 n t d1 t | i/  d2 t |  i2   t5 | |  i2 |  i   | Sd  S(3   Ni,  iQ s   dati    i   s   toplists   Before s    - s    stop=s    randomread=s	    curtime=s   %Y-%m-%d %H:%Ms   hosts    s   curTime <= stat_end_times   tmpi   ie   i   if   s   %Y-%m-%d 00:00i   ig   ih   ic   s   tl_s   _s   :- s   .dats   After s   looks   creates   *s   €i   i
   i   i   iΒ  iK   i   i1   iθ  i2   id   i°  i   i   s   graphData.hosts=s    hostsInDraw=(6   s   reverseLookups   Nones   toplistGraphs   times   todays   longs   tomorrows   stat_start_times   oss   seps
   filePrefixs   graph_start_times   stat_end_times   graph_end_times   debugMsgs   strs   stops
   randomReads   strftimes	   localtimes	   debugHosts   chartURLs   map1URLs   mktimes   strptimes   timezones   time_tmps   PL_paths	   translates   strings	   maketranss   filenames   paths   existss   forces   PL2s   loggPLgraphUses   createdFlags   loadGraphDatas	   graphDatas   stats   VBS_stats   getVBS_toplistGraphDatas   getPL2ToplistGraphDatas   getPL1ToplistGraphDatas   lens   toplistData0s   hostss   abss   hostsInGraphs   hostsInDraws   sizes   ranges   hostReverseLookup(	   s   toplistGraphs   reverseLookups   chartURLs   tomorrows
   filePrefixs	   graphDatas   todays   map1URLs   time_tmp(    (    s   C:\Python\PL\PL_Toplist.pys   toplistDatau   s    
&W/
1"""&"&?W)			(c         C   s  t  d  t   } t i d  }	 d  k } | i i   } g  }
 |  i i d d  } | d j obxΥ| D]Ν} t | d | d |  i d  } d d f \ } } x? t t | i   D]( } | | i | 7} | | i | 7} qΈ Wd d d f \ } } } xΪ | i D]Ο } | d o8 | o# | d | j  o | d } qKqO| d } n | d o8 | o# | d | j  o | d } qq| d } n | d o8 | o# | d | j  o | d } qΡqΥ| d } qqW|
 i h  d | <d	 | <d
 | | <d | d i   <d | i  <d | | | f < qi Wd Gt! |
  GHt  d  | |
 d
  |
 i"   xF|
 D]>} |	 i i t# | d   |	 i i t# | d	   |	 i$ i | d  |	 i% i | d  |	 i& i d  | d |	 _  |	 i i | d  | d o# |	 i' i d  |	 i  d 7_  n |	 i' i d  |	 i( | d
 j  o | d
 |	 _( n xD | d D]8 } | |	 i* j o
 | d j o |	 i* i |  qsqsWqqW|	 i* i   nH xD | D]< } | | d j o% t | d | d |  i d  }	 qΛqΛW|	 Sd  S(   Ns   VBS toplisti    s   /s    i   iά  i   s   ins   outs   totals   labels
   VBS_shapeds	   VBS_speeds'    ======================================s   Sorting VBS-datai)#  s   FF0000(+   s   debugMsgs   Sorters   sorts	   drawgraphs   ToplistGraphDatas	   graphDatas
   PL2_pldPLDs   pldPLDs   vbs_lists   VBSs   VBS_datas   toplistGraphs	   netObjects   replaces   VBS_groupIds   xs   getVBS_listDatas   daysInCharts   VBS_graphDatas   inbounds   outbounds   ranges   lens   toplistData0s   indexs   toplistData1s   speedIns   speedOuts   speedTots	   VBS_speeds   appends   strips
   VBS_shapeds   reprs   reverses   floats   toplistLabelss   nodess   clickableLabelss
   labelColors   maxvalues   speeds   VBS_speedValue(   s   toplistGraphs
   PL2_pldPLDs   VBSs   speedOuts   speedIns   speeds   indexs   outbounds   VBS_groupIds	   graphDatas   VBS_datas   sorts   inbounds	   VBS_speeds   speedTots   VBS_graphDatas   x(    (    s   C:\Python\PL\PL_Toplist.pys   getVBS_toplistGraphDataα   s    
		 ! 
 a

   )i    c         C   sW  t    } t i d  } d  k } | i i |  |  } t |  oΩt d  | | d  | i   x΅| D]©} | d d j o | d | j o| i i t | d   | i i t | d   | i i | d i    | i i t | d   | d | i j o | i i | d  n | d | i j o | i i | d  n | d	 | i j o | i i | d	  n | i i | d | d | d	 f  | d | d | d	 d j o | i i d
  n | i d 7_ | i | d j  o | d | _ qqk qk Wn y | i i d  Wn n X| i i   | i GH| Sd  S(   Ni    s   Sorting VBS-lists   bidirectionals   inbounds   outbounds	   splitnames   inbound speeds   outbound speeds   bidirectional speeds    i   (   s   Sorters   sorts	   drawgraphs   ToplistGraphDatas	   graphDatas
   PL2_pldPLDs   pldPLDs	   vbs_querys	   machineIds   VBS_lists   VBS_datas   lens   debugMsgs   reverses   xs   outbound_thresholds   toplistData0s   appends   floats   toplistData1s   toplistLabelss   strips   nodess
   escapeTexts   VBS_speedValues	   VBS_speeds
   labelColors
   VBS_shapeds   maxvalues   remove(   s	   machineIds   VBS_lists   outbound_thresholds   sorts	   graphDatas   xs
   PL2_pldPLDs   VBS_data(    (    s   C:\Python\PL\PL_Toplist.pys   getVBS_listDataA  sF    		

 "%! c         C   sε  d  k  } t i t i |  i d   } t i d t i | d   |  _ |  i |  i	 j  o |  i	 |  _ n t
   } t i d  } | i i |  i	 |  i |  i  } t |  o+x$ | D] } | d | d | d <qΉ Wt d  | | d  | i   xΰ | D]Τ } | d d j o | d |  i d j o₯ | i i t | d   | i i t | d   | i i | d	  | i i | d
 i    | i i t  | d
   | i! | d j  o | d | _! qΥqqWn | Sd  S(   Ns   %Y-%m-%d %H:%MiQ i    s   ins   outs   traffic_totals   Sorting iά  s   prioritys   name("   s   PL2_PLDBs   times   mktimes   strptimes   toplistGraphs   stat_end_times   time_tmps   strftimes	   localtimes   stat_start_times   Sorters   sorts	   drawgraphs   ToplistGraphDatas	   graphDatas   pldbs   stat_node_lists	   netObjects   nodes   lens   xs   debugMsgs   reverses   daysInCharts   toplistData0s   appends   floats   toplistData1s   clickableLabelss   toplistLabelss   strips   nodess
   escapeTexts   maxvalue(   s   toplistGraphs   sorts   nodes   time_tmps   PL2_PLDBs	   graphDatas   x(    (    s   C:\Python\PL\PL_Toplist.pys   getPL2ToplistGraphData{  s6    	"	! 

 ) c         C   sX  t    } t i d  } t |  i |  i |  i	  } t d  | | d  | i   t d  d | _ d } x» | D]³ } | d o | d o | i i t | d   | i i t | d   | i i | d d | d	  | i | d | d j  o | d | d | _ n | d
 7} qt qt Wt | t |  i	  } t |  i |  | Sd  S(   Ni    s   Sorterar hostss   traffic_totals   Sortering klars
   traffic_ins   traffic_outs   hostnames     s   addressi   (   s   Sorters   sorts	   drawgraphs   ToplistGraphDatas	   graphDatas   getToplistDatas   toplistGraphs   stat_start_times   stat_end_times   reverseLookups   hosts_totals   debugMsgs   reverses   maxvalues   cous   xs   toplistData0s   appends   floats   toplistData1s   toplistLabelss   hostReverseLookups   hostCous   saveToplistGraphDatas   filename(   s   toplistGraphs   sorts   cous   hosts_totals	   graphDatas   x(    (    s   C:\Python\PL\PL_Toplist.pys   getPL1ToplistGraphData₯  s*    	


	  c         C   s=  d  k  } |  d j o
 t } n t } | i   } t d t t	   t d |  | i
 h  d | <d t <d t < } t d t |   t d |  d	 | d
  y | i |  |  } Wn g  } t d  n X| i   }	 t d t |	   t   } t	 d j o% x" | D] } t t |   qWn t d  d }
 xy| D]q} t i | d  | d <| d | d | d <| d | d | d <| d | d | d | d | d <| d d j t |  d d ! t d d  j @|  d d !d  j @o: | d d | d <| d d | d <| d d | d <n | d d! j t |  d d ! t d d  j @|  d d !d  j @o: | d d | d <| d d | d <| d d | d <n |
 d }
 qNWt d"  | | d  g  } t |  o>| d } | d d } xt d t |  d  D]χ} | | d d | d j ot	 d j ob | | d | | d d j o	 d# GHn | | d G| | d d G| d G| | d d Gn | d c | | d d 7<| d c | | d d 7<| d c | | d d 7<t	 d j o d$ G| d GHn | d d% j | | d d d% j @o | | d d | d <n | | d d | j oI | | d d } | | d d d% j o | | d d | d <qΖqq| d d& j o d' | d <n | i |  | | d } | | d d } qW| i |  n t d(  | Sd  S()   Ns   2004-01-01 00:00s   Debuglevel = s   Connecting statistic-server s   hosts   users   passwords   Status connect = s   fetching data s    s    ******s   Error: No datas   Disconnect status = i   s   Berδknar total in och uti    s   addresss   num_addresss   server_inbounds   client_inbounds
   traffic_ins   server_outbounds   client_outbounds   traffic_outs   traffic_totals   hostnames   www.madonnashots.comi   i   i   i   i   s   2003s   www.sverigebygger.nus	   Sorterar s   xxxs    = s    s   81.8.136.13s   gw2-tanaka.dmz.brinet.ses   End getToplistData(    s	   statlogics   stat_start_times   PL1_addresss
   PL_addresss   PL2_addresss   news   stats   debugMsgs   strs   debugs   connects   PL_users   PL_passwords   zs   stat_end_times   hostlists   hostss
   disconnects   cs   Sorters   sorts   xs   cous   IP_miscs   dottedQuadToNums   ints   ranges   hosts_totals   lens   datas   topdatas   append(   s   stat_start_times   stat_end_times   reverseLookups	   statlogics   topdatas
   PL_addresss   sorts   stats   datas   cs   cous   hosts_totals   hostss   xs   z(    (    s   C:\Python\PL\PL_Toplist.pys   getToplistDataΜ  s    	
*	 
 &BB

 !	8 '
c         C   s%  t  d d t d  k } t  d d t | i d  } t  d t |  d t t i d  }	 d |	 _
 d } x€t t |  i   D]}
 y^ |  i |
 } | i t d  } t |  d j  o | d } d } n | d } | d } Wn d } d } d } n X| i | | |  \ } } } | oΉ |  i |
 o |  i |
 o |	 i i |  i |
  |	 i i |  i |
  t d  |	 _ |	 i i |  i |
  |	 i
 |  i |
 |  i |
 j  o |  i |
 |  i |
 |	 _
 qΰqδn t o( t  | d	 t |  d	 | d
  q q W|	 | f Sd  S(   Ns   Import PL_Netobjects   hosts   Get nets from PL_Netobjecti   s   Selekterar data fφr gruppen i    s    i   s    s   *(    s   debugMsgs	   debugHosts   PL_Netobjects	   netobjects   netss   strs
   numGroupIds	   drawgraphs   ToplistGraphDatas   groupGraphDatas   maxvalues	   groupNames   ranges   lens	   graphDatas   toplistData0s   xs   toplistLabelss   hosts   splits   Nones	   host_infos
   IP_addresss   hostnames   IsHostInNetObjects   addressLookupFlags   itemIds   toplistData1s   appends   floats   toplistData2s   debug(   s	   graphDatas
   numGroupIds   PL_Netobjects
   IP_addresss	   host_infos   netss   hostnames	   groupNames   hosts   groupGraphDatas   xs   itemIds   addressLookupFlag(    (    s   C:\Python\PL\PL_Toplist.pys   selectToplistByGroupIdK  sD    		 



"' ,c         C   s6  t  d t |  d t |   x	t |  D]ϋ} d } y‘|  i | }	 |  i
 | } t  d t |	  d t x= |	 D]5 } | | d t d t |   i d  d	 7} qy Wt  | d t |	 i t d  } t |  d j  o4 t i | d
  } | d
 } t i |  d } n5 t i | d  } | d } t i |  | d
 } t o |	 Gd G| Gd	 Gn | d j o
 | d j p
 | d j oJ y< d }
 t i |  }
 |
 d
 d } | d | |  i | <WqΫqΫXn Wn d } d } d }	 n Xt  d t |	  d t |   t o	 | GHq/ q/ W|  Sd  S(   Ns   hostReverseLookup: hostCou=s    reverseLokup=s    s   ## Host=s   hosts   =s   %0xi   s    i    i   s   -----  s   1s   2s   .s     s   Host=s    IP-address =(    s   debugMsgs   strs   hostCous   reverseLookups   ranges   xs   ss	   graphDatas   toplistLabelss   hosts   nodess   nodes   reprs	   debugHosts   chrs   ords   rjusts   splits   Nones	   host_infos   lens   PL_miscs   removeDataBeforeSlashs
   IP_addresss   IP_address_hashs   IP_miscs   dottedQuadToNums   hostnames   debugs   thenames   sockets   gethostbyaddr(   s	   graphDatas   hostCous   reverseLookups   IP_address_hashs
   IP_addresss	   host_infos   hostnames   chrs   nodes   hosts   thenames   ss   x(    (    s   C:\Python\PL\PL_Toplist.pys   hostReverseLookup}  sP    "  3



 '
" c         C   s   t  d |   t |  d  } t i | i | d  t i | i | d  t i | i	 | d  t i | i
 | d  | i   d  S(   Ns   Saveing s   wbi   (   s   debugMsgs   filenames   opens   oufs   cPickles   dumps	   graphDatas   toplistData0s   toplistData1s   toplistLabelss   maxvalues   close(   s   filenames	   graphDatas   ouf(    (    s   C:\Python\PL\PL_Toplist.pys   saveToplistGraphData΅  s    c         C   s   t  i d  } t d |   t |  d  } t i |  | _	 t i |  | _
 t d  | _ t i |  | _ t i |  | _ | Sd  S(   Ni    s   Loading s   rb(   s	   drawgraphs   ToplistGraphDatas	   graphDatas   debugMsgs   filenames   opens   infs   cPickles   loads   toplistData0s   toplistData1s   floats   toplistData2s   toplistLabelss   maxvalue(   s   filenames	   graphDatas   inf(    (    s   C:\Python\PL\PL_Toplist.pys   loadGraphDataΐ  s    c         C   sA  t  o6d  k }	 t i   }
 t i d t i |
   } y |	 i d } Wn d } n Xd } d } | d j o
 | d j o< y t i |  } Wn n Xt |  o | d } qΊ n t d |	 i | d	 | d	 | d
 i t i d d  d  } t | d  } | i | d	 |  d	 | d	 |  | i   n d  S(   Ns   %Y-%m-%d %H:%M:%Ss   REMOTE_ADDRs	   127.0.0.1s    s   Xs   1i    s   logs    s   .txts   :-s   w(   s   developments   oss   times   todays   strftimes	   localtimes
   event_times   environs
   IP_addresss   thenames   hostnames   reverseLookups   sockets   gethostbyaddrs   lens   PL_paths   seps	   translates   strings	   maketranss   filenames   opens
   outputfiles   writes   chartURLs   routins   close(   s   routins   chartURLs   reverseLookups   hostnames
   event_times
   IP_addresss   thenames   filenames
   outputfiles   oss   today(    (    s   C:\Python\PL\PL_Toplist.pys   loggPLgraphUseΟ  s*    	
 A%c         C   s,   |  i t d  d  i t d  d  Sd  S(   Ni   s   %0Di
   s   %0A(   s   texts   replaces   chr(   s   text(    (    s   C:\Python\PL\PL_Toplist.pys
   escapeTextξ  s    (c         C   sh   |  i d d  i d d  i d d  i d d  i d	 d
  i d t d   i d t d   Sd  S(   Ns   &amp;s   &s   &quot;s   "s   &apos;s   's   &lt;s   <s   &gt;s   >s   &#13;i   s   &#10;i
   (   s   texts   replaces   chr(   s   text(    (    s   C:\Python\PL\PL_Toplist.pys   unEscapeTextύ  s    s   __main__iQ i   i   s   %Y-%m-%d 00:00s   2005-05-01 00:00s   2005-05-02 00:00s   1i   i   ig   iΌ  s   Genaration-2s    s   /s   PL_SpeedGraph.py?from=s   &to=s   &charttype=s   &graph=s   tests   0s   /Hosts(I   s   PL1_inis   PL2_inis   PL_debugs   PL_consts   PL_miscs	   drawgraphs
   PL2_exports   IP_miscs   sockets   strings   oss   calendars   cPickles   strptimes
   pychartdirs   sorts   Sorters   GraphToplistDatas
   SpeedGraphs   toplistImages   Nones   toplistDatas   getVBS_toplistGraphDatas   getVBS_listDatas   getPL2ToplistGraphDatas   getPL1ToplistGraphDatas   getToplistDatas   selectToplistByGroupIds   hostReverseLookups   saveToplistGraphDatas   loadGraphDatas   loggPLgraphUses
   escapeTexts   unEscapeTexts   __name__s   times   todays   tomorrows	   yesterdays   customGraphs   Graphs	   GraphParas   toplistGraphs   graphs   charts
   chart_types   strftimes	   localtimes   stat_start_times   stat_end_times   reverseLookups   topboxs   forces   stops   sizes   hostsInGraphs	   chartNames   topListBackgroundImages   groupIds   printhostnames
   IP_addresss   hostnames   strs	   file2calls   layouts   images	   flag_5mins	   debugHosts	   netObjects   outputs   chartURLs   imageMaps	   graphData(#   s   IP_miscs   Graphs   getToplistDatas	   graphDatas   toplistDatas   calendars   chartURLs   saveToplistGraphDatas   tomorrows   strptimes   selectToplistByGroupIds   Sorters   getVBS_listDatas
   PL2_exports   getPL1ToplistGraphDatas   loadGraphDatas   hostReverseLookups   imageMaps   todays   cPickles   strings   loggPLgraphUses
   SpeedGraphs   toplistGraphs	   yesterdays   unEscapeTexts   getVBS_toplistGraphDatas   GraphToplistDatas   sockets
   escapeTexts	   drawgraphs   getPL2ToplistGraphDatas   toplistImages   PL_miscs   os(    (    s   C:\Python\PL\PL_Toplist.pys   ?   s   										+l	`:	*	'		2	8						

																:						