Changeset 63 for trunk/tool
- Timestamp:
- 02/04/08 10:10:35 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/tool/renetcolGUI.py
r62 r63 4 4 ## Authors: ANDREU Francois-Xavier 5 5 6 ## Copyright (C) 2005 GIP RENATER6 ## Copyright (C) 2005-2006-2007-2008 GIP RENATER 7 7 8 8 … … 34 34 os.environ['PATH'] += ";%s/lib;%s/bin" % (gtkdir, gtkdir) 35 35 36 import operator 36 37 import threading 37 38 import string … … 112 113 oldTpl = 0 113 114 fromRouter = "" 115 myTimer = None 116 myCPT = 1 114 117 115 118 class InputControl(threading.Thread): … … 155 158 resS = 1 156 159 resD = 1 157 resInIndex = 1158 resOutIndex = 1159 160 for i in range (0, len(tpl_def[self.flow[0]])): 160 161 f = tpl_def[self.flow[0]][i][0] … … 168 169 elif ( (f==1) and (checkUpValues[f]==1) ): 169 170 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])174 171 elif (checkUpValues[f]==1): 175 172 res = res & (self.flow[1][i] == firstParseValue[f]) 176 173 if ( checkUpValues[69]==1 ): 177 174 res = res & ( (fromRouter == firstParseValue[69]) ) 178 res = res & (resS or resD) & (resInIndex or resOutIndex)175 res = res & (resS or resD) 179 176 return res 180 177 … … 518 515 type = gtk.MESSAGE_INFO, 519 516 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 ") 521 518 dialog.set_title('About') 522 519 dialog.connect('response', lambda dialog, response: dialog.destroy()) … … 589 586 if widget.get_active()==1: 590 587 router=1 588 589 def 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 605 def 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" 591 620 592 621 def callback_collector(widget, controlWindow): … … 831 860 832 861 def user_quit(widget, data=None): 833 global myInputControlThread, localPort, record_file 862 global myInputControlThread, localPort, record_file, myTimer 834 863 if myInputControlThread != None: 835 864 myInputControlThread.kill(1) … … 842 871 record_file.close() 843 872 print "\n\n\n\n\n Input Stream closed. \n\n\n\n\n By :-) \n\n\n\n" 873 myTimer.cancel() 844 874 gtk.main_quit() 845 875 … … 1035 1065 global window, mainTT, comboRouter, os_type, printShit 1036 1066 1037 gtk. threads_init()1067 gtk.gdk.threads_init() 1038 1068 1039 1069 if (os.name =="nt"): … … 1045 1075 1046 1076 print "---------------------------------------------------------------" 1047 print "In this version 0.0.7, you canapply 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:" 1048 1078 print "IN_BYTES: 1," 1049 1079 print "L4_SRC_PORT: 7," … … 1134 1164 hbox.pack_start(buttonrecord, False, False, 2) 1135 1165 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() 1136 1172 ## control collector button 1137 1173 buttoncollector = gtk.ToggleButton("Collector Control") … … 1219 1255 1220 1256 ## gtk main loop 1221 gtk. threads_enter()1257 gtk.gdk.threads_enter() 1222 1258 gtk.main() 1223 gtk. threads_leave()1259 gtk.gdk.threads_leave()