Changeset 63 for trunk

Show
Ignore:
Timestamp:
02/04/08 10:10:35 (15 years ago)
Author:
andreu
Message:

add AS selection and rotated record (on 24hours)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tool/renetcolGUI.py

    r62 r63  
    44##  Authors: ANDREU Francois-Xavier  
    55  
    6 ##  Copyright (C) 2005 GIP RENATER  
     6##  Copyright (C) 2005-2006-2007-2008 GIP RENATER  
    77  
    88 
     
    3434os.environ['PATH'] += ";%s/lib;%s/bin" % (gtkdir, gtkdir) 
    3535 
     36import operator 
    3637import threading 
    3738import string 
     
    112113oldTpl = 0 
    113114fromRouter = "" 
     115myTimer = None 
     116myCPT = 1 
    114117 
    115118class InputControl(threading.Thread): 
     
    155158        resS = 1 
    156159        resD = 1 
    157         resInIndex = 1 
    158         resOutIndex = 1 
    159160        for i in range (0, len(tpl_def[self.flow[0]])): 
    160161            f = tpl_def[self.flow[0]][i][0] 
     
    168169            elif ( (f==1) and (checkUpValues[f]==1) ): 
    169170                res = res & ( (self.flow[1][i] <= ((firstParseValue[f])+((firstParseValue[f])*5/100))) and ((self.flow[1][i] >= ((firstParseValue[f])-((firstParseValue[f])*5/100)))) ) 
    170             elif ((f==10) and (checkUpValues[f]==1)): 
    171                 resInIndex = resInIndex & ( self.flow[1][i] == firstParseValue[f]) 
    172             elif ((f==14) and (checkUpValues[f]==1)): 
    173                 resOutIndex = resOutIndex & ( self.flow[1][i] == firstParseValue[f]) 
    174171            elif (checkUpValues[f]==1): 
    175172                res = res & (self.flow[1][i] == firstParseValue[f]) 
    176173        if ( checkUpValues[69]==1 ): 
    177174            res = res & ( (fromRouter == firstParseValue[69]) ) 
    178         res = res & (resS or resD) & (resInIndex or resOutIndex) 
     175        res = res & (resS or resD) 
    179176        return res 
    180177 
     
    518515        type           = gtk.MESSAGE_INFO, 
    519516        buttons        = gtk.BUTTONS_OK, 
    520         message_format = "Author : FX Andreu\nemail andreu@renater.fr\nCopyright (C) 2005 GIP RENATER\n\nThis file is part of renetcol.\n\nrenetcol is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\n\nrenetcol is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with renetcol; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA ")  
     517        message_format = "Author : FX Andreu\nemail andreu@renater.fr\nCopyright (C) 2005-2008 GIP RENATER\n\nThis file is part of renetcol.\n\nrenetcol is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\n\nrenetcol is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with renetcol; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA ")  
    521518    dialog.set_title('About') 
    522519    dialog.connect('response', lambda dialog, response: dialog.destroy()) 
     
    589586    if widget.get_active()==1: 
    590587        router=1 
     588 
     589def timer_action(): 
     590    global record_file, record_file_name, myTimer, myCPT 
     591    myCPT+=1 
     592    myTimer.cancel() 
     593    my_new_file_name = "%s_%s_%d" % (record_file_name,time.strftime("%Y%m%d", time.gmtime()),myCPT) 
     594    ##my_new_file_name = "%s_%d" % (record_file_name,myCPT) 
     595    print my_new_file_name 
     596    new_record_file = file(my_new_file_name, 'w') 
     597    old_record_file = record_file 
     598    record_file = new_record_file 
     599    old_record_file.close() 
     600    now2 = time.time() 
     601    reste = 86400-(operator.mod(now2,86400)) 
     602    myTimer = threading.Timer(300.0,timer_action) 
     603    myTimer.start() 
     604 
     605def callback_RotRec(widget, data=None): 
     606    global record, myTimer 
     607    if ((record == 0) and (widget.get_active() == 1)): 
     608        info_dialog(widget, None, "You must before activated the record ! ") 
     609        widget.set_active(0) 
     610    else: 
     611        if widget.get_active() == 1: 
     612            print "STARTING RECORD ROTATION" 
     613            now2 = time.time() 
     614            reste = 86400-(operator.mod(now2,86400)) 
     615            myTimer = threading.Timer(300.0,timer_action) 
     616            myTimer.start() 
     617        if widget.get_active() == 0: 
     618            myTimer.cancel() 
     619            print "STOPPING RECORD ROTATION" 
    591620 
    592621def callback_collector(widget, controlWindow): 
     
    831860 
    832861def user_quit(widget, data=None): 
    833     global myInputControlThread, localPort, record_file 
     862    global myInputControlThread, localPort, record_file, myTimer 
    834863    if myInputControlThread != None: 
    835864        myInputControlThread.kill(1) 
     
    842871            record_file.close() 
    843872        print "\n\n\n\n\n Input Stream closed. \n\n\n\n\n By :-) \n\n\n\n" 
     873    myTimer.cancel() 
    844874    gtk.main_quit() 
    845875 
     
    10351065    global window, mainTT, comboRouter, os_type, printShit 
    10361066     
    1037     gtk.threads_init() 
     1067    gtk.gdk.threads_init() 
    10381068     
    10391069    if (os.name =="nt"): 
     
    10451075 
    10461076    print "---------------------------------------------------------------" 
    1047     print "In this version 0.0.7, you can apply rules on the collector based on the following fields:" 
     1077    print "In this version, you can only apply rules on the collector based on the following fields:" 
    10481078    print "IN_BYTES: 1," 
    10491079    print "L4_SRC_PORT: 7," 
     
    11341164    hbox.pack_start(buttonrecord, False, False, 2) 
    11351165    buttonrecord.show() 
     1166    ## incremental record 
     1167    buttonRotRec = gtk.ToggleButton("Rot. Record") 
     1168    buttonRotRec.connect("toggled", callback_RotRec, None) 
     1169    mainTT.set_tip(buttonRotRec, "Stop/Start the record in a different file for each day.") 
     1170    hbox.pack_start(buttonRotRec, False, False, 2) 
     1171    buttonRotRec.show() 
    11361172    ## control collector button 
    11371173    buttoncollector = gtk.ToggleButton("Collector Control") 
     
    12191255 
    12201256##  gtk main loop 
    1221     gtk.threads_enter() 
     1257    gtk.gdk.threads_enter() 
    12221258    gtk.main() 
    1223     gtk.threads_leave() 
     1259    gtk.gdk.threads_leave()