Changeset 4300

Show
Ignore:
Timestamp:
03/06/09 17:00:48 (4 years ago)
Author:
gpolo
Message:

Merged revisions 4291-4299 via svnmerge from
http://svn.umitproject.org/svnroot/umit/trunk

........

r4291 | gpolo | 2009-03-05 22:10:12 -0300 (Thu, 05 Mar 2009) | 1 line


Added classifier for python 2.4

........

r4292 | gpolo | 2009-03-05 22:12:32 -0300 (Thu, 05 Mar 2009) | 1 line


Added missing commas.

........

r4293 | gpolo | 2009-03-06 13:03:40 -0300 (Fri, 06 Mar 2009) | 1 line


typo fix.

........

r4294 | gpolo | 2009-03-06 13:07:45 -0300 (Fri, 06 Mar 2009) | 3 lines


Avoiding a "GtkWarning?: gtk_label_set_label: assertion `str != NULL'
failed" when not giving a value to text.

........

r4295 | gpolo | 2009-03-06 13:10:00 -0300 (Fri, 06 Mar 2009) | 1 line


Adjusted example to work with the current paths.

........

r4296 | gpolo | 2009-03-06 13:11:51 -0300 (Fri, 06 Mar 2009) | 1 line


Removed bad sys.exit (which didn't even work since sys was never imported here).

........

r4297 | gpolo | 2009-03-06 13:17:37 -0300 (Fri, 06 Mar 2009) | 1 line


Fixed bad widget packing.

........

r4298 | gpolo | 2009-03-06 13:38:11 -0300 (Fri, 06 Mar 2009) | 1 line


Misc tweaks, also removed the broken example.

........

r4299 | gpolo | 2009-03-06 13:50:40 -0300 (Fri, 06 Mar 2009) | 1 line


read_file is gone for more than one year, removed its use here. This code doesn't replace the previous read_file func.

........

Location:
branch/NetworkInventory
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • branch/NetworkInventory

    • Property svnmerge-integrated changed from /trunk:1-560,563-566,574,577-597,599-615,617-618,620-635,641-648,651,653-662,666-667,669-764,766-845,848-964,966-1038,1041,1047-1059,1070-1103,1113-1119,1139,1156-1187,1189,1196-1202,1206-1223,1225-1241,1244-1248,1251-1258,1260-1274,1276-1279,1281,1283-1284,1290-1295,1297-1305,1307-1308,1310-1311,1313-1322,1326,1328-1333,1335,1337-1397,1399-1418,1420-3939,3941-3945,3948-3952,3955-3978,3980-4122,4124-4287 to /trunk:1-560,563-566,574,577-597,599-615,617-618,620-635,641-648,651,653-662,666-667,669-764,766-845,848-964,966-1038,1041,1047-1059,1070-1103,1113-1119,1139,1156-1187,1189,1196-1202,1206-1223,1225-1241,1244-1248,1251-1258,1260-1274,1276-1279,1281,1283-1284,1290-1295,1297-1305,1307-1308,1310-1311,1313-1322,1326,1328-1333,1335,1337-1397,1399-1418,1420-3939,3941-3945,3948-3952,3955-3978,3980-4122,4124-4299
  • branch/NetworkInventory/higwidgets/higlabels.py

    r4028 r4300  
    131131    """ 
    132132    def __init__(self, text=None, underline=False): 
    133         gtk.Label.__init__(self, text) 
     133        gtk.Label.__init__(self) 
     134        if text is not None: 
     135            self.set_text(text) 
    134136        self.set_justify(gtk.JUSTIFY_LEFT) 
    135137        self.set_alignment(0, 0.50) 
  • branch/NetworkInventory/setup.py

    r4289 r4300  
    390390            'License :: OSI Approved :: GNU General Public License (GPL)', 
    391391            'Programming Language :: Python :: 2', 
    392             'Programming Language :: Python :: 2.5' 
     392            'Programming Language :: Python :: 2.4', 
     393            'Programming Language :: Python :: 2.5', 
    393394            'Programming Language :: Python :: 2.6', 
    394395            'Topic :: System :: Networking', 
  • branch/NetworkInventory/umit/gui/CrashReport.py

    r4252 r4300  
    174174        self.destroy() 
    175175        gtk.main_quit() 
    176         sys.exit(0) 
    177176 
    178177    def get_description(self): 
  • branch/NetworkInventory/umit/gui/NmapOutputViewer.py

    r4252 r4300  
    417417 
    418418    buff = n.text_view.get_buffer() 
    419     buff.set_text(read_file("file_with_encoding_issues.txt")) 
    420      
     419    buff.set_text(open("file_with_encoding_issues.txt", 'rb').read()) 
     420 
    421421    gtk.main() 
  • branch/NetworkInventory/umit/gui/OptionBuilder.py

    r4252 r4300  
    1 #!/usr/bin/env python 
    21# -*- coding: utf-8 -*- 
    32# 
     
    2120# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 
    2221 
     22import os 
     23import sys 
    2324import gtk 
    24  
    2525from xml.dom import minidom 
    2626 
     
    2929from higwidgets.higbuttons import HIGButton 
    3030 
    31 from umit.gui.ScriptManager import ScriptChooserDialog #MAX 
     31from umit.gui.ScriptManager import ScriptChooserDialog 
    3232from umit.gui.FileChoosers import AllFilesFileChooserDialog 
    33  
    34 #from umit.core.UmitConf import is_maemo 
    3533 
    3634from umit.core.NmapOptions import NmapOptions 
    3735from umit.core.I18N import _ 
     36from umit.core.Utils import amiroot 
    3837from umit.core.OptionsConf import options_file 
    39 import os, sys 
    40  
    41 ## Integration  
    42 #class OptionTab(object): 
    43     #def __init__(self, root_tab, options, constructor, update_func): 
    44         #actions = {'option_list':self.__parse_option_list,\ 
    45                    #'option_check':self.__parse_option_check} 
    46  
    47 #<<<<<<< .working 
     38 
     39 
    4840class OptionTab(object): 
    4941    def __init__(self, root_tab, options, constructor, update_func): 
    50         actions = {'option_list':self.__parse_option_list,\ 
    51                    'option_check':self.__parse_option_check} 
     42        actions = { 
     43                'option_list':self.__parse_option_list, 
     44                'option_check':self.__parse_option_check} 
    5245 
    5346        self.options = options 
     
    5750 
    5851        options_used = self.constructor.get_options() 
    59          
     52 
    6053        # Cannot use list comprehhension because text nodes raise exception 
    6154        # when tagName is called 
     
    6558            else: 
    6659                if option_element.tagName in actions.keys(): 
    67                     self.widgets_list.append(actions[option_element.tagName](option_element, options_used)) 
     60                    self.widgets_list.append( 
     61                            actions[option_element.tagName](option_element, 
     62                                options_used)) 
    6863 
    6964    def __parse_option_list(self, option_list, options_used): 
    7065        options = option_list.getElementsByTagName(u'option') 
    71          
     66 
    7267        label = HIGEntryLabel(option_list.getAttribute(u'label')) 
    7368        opt_list = OptionList() 
    74          
     69 
    7570        for opt in options: 
    7671            opt_list.append(self.options.get_option(opt.getAttribute(u'name'))) 
    77          
     72 
    7873        for i, row in enumerate(opt_list.list): 
    7974            if row[0] in options_used: 
    8075                opt_list.set_active(i) 
    81                  
     76 
    8277        return label, opt_list 
    83      
    84     def is_root(self): 
    85         """ 
    86         Returns if is a root users 
    87         """ 
    88          
    89         root = False 
    90         try: 
    91             if sys.platform == 'win32': root = True 
    92             elif os.getuid() == 0: root = True 
    93         except: pass 
    94         return root 
    95      
     78 
    9679    def _disable_option(self, need_root): 
    9780        """ 
    9881        enable / disable option if non-root user. 
    9982        """ 
    100         is_root = self.is_root() 
    101  
    102         return not is_root and need_root 
    103      
    104      
     83        return not amiroot() and need_root 
     84 
     85 
    10586    def __with_icon(self, hint): 
    10687        """ 
     
    10889        """ 
    10990        return hint!="" 
    110      
     91 
    11192    def __parse_option_check(self, option_check, options_used): 
    112         #arg_type = option_check.getAttribute(u'arg_type') 
    113          
    11493        option = option_check.getAttribute(u'option') 
    11594        arg_type = self.options.get_arg_type(option) 
     
    124103        else: 
    125104            check = OptionCheck(label, opt_parse) 
    126         check.set_active(option in options_used)   
     105        check.set_active(option in options_used) 
    127106        if self._disable_option(need_root): 
    128107            check.disable_widget() 
    129         type_mapping = {  
    130             "str": OptionEntry, 
    131             "int": OptionIntSpin, 
    132             "float": OptionFloatSpin, 
    133             "level": OptionLevelSpin,  
    134             "path": OptionFile, 
    135             "interface": OptionInterface,  
    136             "scriptlist": OptionScriptList 
    137             } 
     108        type_mapping = { 
     109                "str": OptionEntry, 
     110                "int": OptionIntSpin, 
     111                "float": OptionFloatSpin, 
     112                "level": OptionLevelSpin, 
     113                "path": OptionFile, 
     114                "interface": OptionInterface, 
     115                "scriptlist": OptionScriptList} 
    138116 
    139117        additional = None 
     
    171149            elif te == type(OptionInterface()): 
    172150                widget[1].child.connect('changed', self.update_entry, widget[0]) 
    173              
     151 
    174152    def update_check(self, check, extra): 
    175153        if check.get_active(): 
     
    191169 
    192170        self.update_command() 
    193          
     171 
    194172    def update_entry(self, widget, check): 
    195173        if not check.get_active(): 
     
    198176        self.constructor.remove_option(check.option['name']) 
    199177        self.constructor.add_option(check.option['name'], widget.get_text()) 
    200          
     178 
    201179        self.update_command() 
    202      
     180 
    203181    def update_level(self, widget, check): 
    204182        if not check.get_active(): 
    205183            check.set_active(True) 
    206          
     184 
    207185        try: 
    208186            self.constructor.remove_option(check.option['name']) 
     
    210188                check.set_active(False) 
    211189            else: 
    212                 self.constructor.add_option(check.option['name'],\ 
    213                                         level=int(widget.get_text())) 
     190                self.constructor.add_option( 
     191                        check.option['name'], 
     192                        level=int(widget.get_text())) 
    214193        except:pass 
    215          
     194 
    216195        self.update_command() 
    217196 
     
    221200        else: 
    222201            self.constructor.remove_option(widget.last_selected) 
    223          
     202 
    224203        option_name = widget.options[widget.get_active()]['name'] 
    225        
     204 
    226205        self.constructor.add_option(option_name) 
    227206        widget.last_selected = option_name 
    228          
     207 
    229208        self.update_command() 
    230209 
     
    232211        if self.update_func: 
    233212            self.update_func() 
    234      
    235                   
     213 
     214 
    236215class OptionBuilder(object): 
    237216    def __init__(self, xml_file, constructor, update_func): 
     
    248227        self.constructor = constructor 
    249228        self.update_func = update_func 
    250          
     229 
    251230        self.root_tag = "interface" 
    252          
     231 
    253232        self.xml = self.xml.getElementsByTagName(self.root_tag)[0] 
    254233        self.options = NmapOptions(options_file) 
    255          
     234 
    256235        self.groups = self.__parse_groups() 
    257236        self.section_names = self.__parse_section_names() 
    258237        self.tabs = self.__parse_tabs() 
    259      
     238 
    260239 
    261240    def __parse_section_names(self): 
     
    265244            dic[group] = grp.getAttribute(u'label') 
    266245        return dic 
    267      
     246 
    268247    def __parse_groups(self): 
    269248        return [g_name.getAttribute(u'name') for g_name in \ 
     
    274253        dic = {} 
    275254        for tab_name in self.groups: 
    276             dic[tab_name] = OptionTab(self.xml.getElementsByTagName(tab_name)[0], 
    277                                       self.options, 
    278                                       self.constructor, 
    279                                       self.update_func) 
     255            dic[tab_name] = OptionTab( 
     256                    self.xml.getElementsByTagName(tab_name)[0], 
     257                    self.options, 
     258                    self.constructor, 
     259                    self.update_func) 
    280260        return dic 
    281261 
     
    284264    def enable_widget(self): 
    285265        self.set_sensitive(True) 
    286      
     266 
    287267    def disable_widget(self): 
    288268        self.set_sensitive(False) 
     
    292272        self.list = gtk.ListStore(str) 
    293273        gtk.ComboBoxEntry.__init__(self, self.list) 
    294          
     274 
    295275        cell = gtk.CellRendererText() 
    296276        self.pack_start(cell, True) 
     
    301281        self.list = gtk.ListStore(str) 
    302282        gtk.ComboBox.__init__(self, self.list) 
    303          
     283 
    304284        cell = gtk.CellRendererText() 
    305285        self.pack_start(cell, True) 
    306286        self.add_attribute(cell, 'text', 0) 
    307          
     287 
    308288        self.options = [] 
    309      
     289 
    310290    def append(self, option): 
    311291        self.list.append([option[u'name']]) 
     
    314294class OptionCheckIcon(HIGHBox, OptionWidget): 
    315295    def __init__(self, label=None, option=None, hint=None): 
    316          
     296 
    317297        HIGHBox.__init__(self) 
    318          
     298 
    319299        self.cbutton = OptionCheck(label,option) 
    320300        self.option = option 
     
    322302        self.pack_start(self.cbutton, False, False) 
    323303        self.pack_start(self.hint, False, False, 5) 
    324      
     304 
    325305    def connect(self, action, func, additional): 
    326306        """ 
    327         connect checkbox  
     307        connect checkbox 
    328308        """ 
    329309        self.cbutton.connect(action, func, additional) 
    330      
     310 
    331311    def set_active(self, value): 
    332312        """ 
     
    334314        """ 
    335315        self.cbutton.set_active(value) 
    336          
     316 
    337317    def get_active(self): 
    338318        return self.cbutton.get_active() 
    339      
     319 
    340320    def get_checkbox(self): 
    341321        """ 
    342         Returns checkbox  
     322        Returns checkbox 
    343323        example, to do connection 
    344324        """ 
    345325        return self.cbutton 
    346      
     326 
    347327    def get_option(self): 
    348328        return self.cbutton.get_option() 
    349329 
    350330class OptionScriptList(HIGHBox, OptionWidget, object): 
    351     # From MAX 
    352331    def __init__(self): 
    353332        HIGHBox.__init__(self) 
    354          
     333 
    355334        self.entry = OptionEntry() 
    356335        self.button = HIGButton(stock=gtk.STOCK_EDIT) 
    357          
     336 
    358337        self._pack_expand_fill(self.entry) 
    359338        self._pack_noexpand_nofill(self.button) 
    360          
     339 
    361340        self.button.connect('clicked', self.open_dialog_cb) 
     341 
    362342    def open_dialog_cb(self, widget): 
    363343        dialog = ScriptChooserDialog(self.entry.get_text()) 
     
    369349    def __init__(self, label=None, option=None): 
    370350        gtk.CheckButton.__init__(self, label) 
    371          
     351 
    372352        self.option = option 
    373      
     353 
    374354    def get_option(self): 
    375355        return self.option 
     
    400380    def __init__(self, param=""): 
    401381        HIGHBox.__init__(self) 
    402          
     382 
    403383        self.entry = OptionEntry() 
    404384        self.button = HIGButton(stock=gtk.STOCK_OPEN) 
    405          
     385 
    406386        self._pack_expand_fill(self.entry) 
    407387        self._pack_noexpand_nofill(self.button) 
     
    409389        self.entry.set_text(param) 
    410390        self.button.connect('clicked', self.open_dialog_cb) 
    411      
     391 
    412392    def open_dialog_cb(self, widget): 
    413393        dialog = AllFilesFileChooserDialog(_("Choose file")) 
     
    429409 
    430410        self.hint_image = gtk.Image() 
    431         self.hint_image.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR) 
     411        self.hint_image.set_from_stock( 
     412                gtk.STOCK_DIALOG_INFO, 
     413                gtk.ICON_SIZE_SMALL_TOOLBAR) 
    432414 
    433415        self.add(self.hint_image) 
    434416        self.add_events(gtk.gdk.BUTTON_MOTION_MASK) 
    435417        self.connect("button-press-event", self.show_hint) 
    436         #self.connect("enter-notify-event", self.show_hint) 
    437           
     418 
    438419 
    439420    def show_hint(self, widget, event=None): 
     
    441422        hint_window.show_all() 
    442423 
    443      
     424 
    444425class HintWindow(gtk.Window): 
    445      
     426 
    446427    def __init__(self, hint): 
    447428        gtk.Window.__init__(self, gtk.WINDOW_POPUP) 
    448429        self.set_position(gtk.WIN_POS_MOUSE) 
    449430        bg_color = gtk.gdk.color_parse("#fbff99") 
    450          
     431 
    451432        self.modify_bg(gtk.STATE_NORMAL, bg_color) 
    452433 
     
    455436        self.event.set_border_width(10) 
    456437        self.event.connect("button-press-event", self.close) 
    457         #self.event.connect("leave-notify-event", self.close)         
    458438        self.hint_label = gtk.Label(hint) 
    459439        self.hint_label.set_use_markup(True) 
    460440        self.hint_label.set_line_wrap(True) 
    461          
     441 
    462442        self.event.add(self.hint_label) 
    463443        self.add(self.event) 
     
    465445    def close(self, widget, event=None): 
    466446        self.destroy() 
    467          
    468 if __name__ == '__main__': 
    469     o = OptionBuilder('profile_editor.xml') 
    470  
    471     ol = OptionFile() 
    472     w = gtk.Window() 
    473     w.add(ol) 
    474     w.show_all() 
    475     w.connect('delete-event', lambda x,y,z=None: gtk.main_quit()) 
    476     gtk.main() 
  • branch/NetworkInventory/umit/gui/ProfileWizardEditor.py

    r4252 r4300  
    194194        box = HIGHBox() 
    195195        box._pack_expand_fill(self.treeview) 
    196         self.profile_group_sw.add(box) 
     196        self.profile_group_sw.add_with_viewport(box) 
    197197         
    198198         
     
    290290        column = gtk.TreeViewColumn("Name", renderer, text=0) 
    291291        treeview.append_column(column) 
    292         self.prop_frame_option.add(treeview) 
     292        prop_sw.add(treeview) 
    293293        self.prop_frame_option.add(prop_sw) 
    294294         
     
    306306        self.prop_exp = HIGExpander("Proprieties") 
    307307 
    308         label = gtk.Label('s') 
    309         self.prop_exp.add(label) 
    310         self.prop_frame.add(self.prop_exp)     
    311          
     308        self.prop_frame.add(self.prop_exp) 
     309 
    312310 
    313311 
  • branch/NetworkInventory/umit/gui/Search.py

    r4252 r4300  
    8686            self.fraction 
    8787        except: 
    88             self.fraction = 0.2         
     88            self.fraction = 0.2 
    8989        self.progress.set_fraction(self.fraction + self.progress.get_fraction()) 
    9090 
     
    9292    filename = property(get_filename, 
    9393                        set_filename, 
    94                         doc=_("File name been searched")) 
     94                        doc=_("File's name being searched")) 
    9595    path = property(get_path, 
    9696                    set_path, 
    97                     doc=_("Path been scanned")) 
     97                    doc=_("Path being scanned")) 
    9898    fraction = property(get_fraction, 
    9999                        set_fraction, 
  • branch/NetworkInventory/umit/gui/Splash.py

    r4252 r4300  
    7676 
    7777if __name__ == "__main__": 
    78     from os.path import join 
    79     s = Splash(join(".", "share", "pixmaps", "splash.png")) 
     78    import os 
     79    s = Splash(os.path.join(".", "share", "pixmaps", "umit", "splash.png")) 
    8080    gtk.main()