Changeset 20 for trunk

Show
Ignore:
Timestamp:
01/23/09 10:33:16 (3 years ago)
Author:
lasarux
Message:
  • config.yaml:
  • glade/main.glade:
  • main.py:
  • plugins/info/info/init.py: Add connect button and use a main variable for ssh login
Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r19 r20  
     12009-01-23  Pedro Gracia  <lasarux@gmail.com> 
     2 
     3        * config.yaml: 
     4        * glade/main.glade: 
     5        * main.py: 
     6        * plugins/info/info/__init__.py: 
     7        Add connect button and use a main variable for ssh login 
     8 
    192009-01-19  Pedro Gracia  <lasarux@gmail.com> 
    210 
  • trunk/config.yaml

    r18 r20  
    1515        os: linux 
    1616        version: debian-etch 
     17    opensolaris:  
     18        ip: 127.0.0.1 
     19        port: 2222 
     20        user: root 
     21        os: opensolaris 
     22        version: 2008.11 
    1723         
    1824users: 
  • trunk/glade/main.glade

    r18 r20  
    242242                </child> 
    243243                <child> 
    244                   <widget class="GtkHBox" id="hbox1"> 
     244                  <widget class="GtkHBox" id="vbox4"> 
    245245                    <property name="visible">True</property> 
    246246                    <property name="spacing">4</property> 
     
    257257                    </child> 
    258258                    <child> 
     259                      <widget class="GtkButton" id="connect_btn"> 
     260                        <property name="visible">True</property> 
     261                        <property name="can_focus">True</property> 
     262                        <property name="receives_default">True</property> 
     263                        <property name="label" translatable="yes">gtk-connect</property> 
     264                        <property name="use_stock">True</property> 
     265                        <property name="response_id">0</property> 
     266                        <signal name="clicked" handler="on_connect_btn_clicked"/> 
     267                      </widget> 
     268                      <packing> 
     269                        <property name="position">1</property> 
     270                      </packing> 
     271                    </child> 
     272                    <child> 
    259273                      <widget class="GtkButton" id="button1"> 
    260274                        <property name="visible">True</property> 
    261275                        <property name="can_focus">True</property> 
    262276                        <property name="label">gtk-add</property> 
    263                         <property name="use_stock">True</property> 
    264                         <property name="response_id">0</property> 
    265                       </widget> 
    266                       <packing> 
    267                         <property name="expand">False</property> 
    268                         <property name="fill">False</property> 
    269                         <property name="position">1</property> 
    270                       </packing> 
    271                     </child> 
    272                     <child> 
    273                       <widget class="GtkButton" id="button2"> 
    274                         <property name="visible">True</property> 
    275                         <property name="can_focus">True</property> 
    276                         <property name="label">gtk-remove</property> 
    277277                        <property name="use_stock">True</property> 
    278278                        <property name="response_id">0</property> 
     
    282282                        <property name="fill">False</property> 
    283283                        <property name="position">2</property> 
     284                      </packing> 
     285                    </child> 
     286                    <child> 
     287                      <widget class="GtkButton" id="button2"> 
     288                        <property name="visible">True</property> 
     289                        <property name="can_focus">True</property> 
     290                        <property name="label">gtk-remove</property> 
     291                        <property name="use_stock">True</property> 
     292                        <property name="response_id">0</property> 
     293                      </widget> 
     294                      <packing> 
     295                        <property name="expand">False</property> 
     296                        <property name="fill">False</property> 
     297                        <property name="position">3</property> 
    284298                      </packing> 
    285299                    </child> 
  • trunk/main.py

    r18 r20  
    1313from misc.SimpleGladeApp import SimpleGladeApp 
    1414from misc.SimpleGladeApp import bindtextdomain 
     15from misc.pexpect import pexpect, pxssh 
    1516import config 
    1617 
     
    118119        columns = [('visible', 'str', 'Name'), 
    119120                   ('visible', 'str', 'OS'), 
    120                    ('visible', 'str', 'IP Address')] 
     121                   ('visible', 'str', 'IP Address'), 
     122                   ('novisible', 'str', 'Port')] 
    121123        for i in config.HOSTS: 
    122124            j = config.HOSTS[i] 
    123             row = (i, j["os"], j["ip"]) 
     125            try: 
     126                row = (i, j["os"], j["ip"], j["port"]) 
     127            except: 
     128                row = (i, j["os"], j["ip"], "22") 
    124129            data.append(row) 
    125130        self.t = Treeview("list", columns, data, self.treeview) 
     
    137142        self.t = Treeview("list", columns, data, self.treeview) 
    138143 
     144    def on_connect_btn_clicked(self, button): 
     145        self.s = pxssh.pxssh() 
     146        user = "root" #self.settings["user"] 
     147        ip = self.settings["ip"] 
     148        port = self.settings["port"] 
     149        os = self.settings["os"] 
     150        if self.s.login(ip, user, port=port): 
     151            print "login!" 
     152        else: 
     153            print "no login!" 
     154 
    139155    def on_treeview_button_release_event(self, widget, event): 
    140156        #Get the path at the specific mouse position 
    141157        model, iter = widget.get_selection().get_selected() 
    142158        self.settings["ip"] = model.get_value(iter, 2) 
    143         self.settings["opsys"] = model.get_value(iter, 1) 
    144  
    145          
     159        self.settings["port"] = model.get_value(iter, 3) 
     160        self.settings["os"] = model.get_value(iter, 1) 
     161 
    146162    def on_table_combo_changed(self, widget): 
    147163        """Prepare data to show in treeview""" 
  • trunk/plugins/info/info/__init__.py

    r18 r20  
    2525        """option in combox has changed""" 
    2626        command = widget.get_active_text().lower() 
    27         self.send_command(command, self.main.get_settings("ip"), self.main.get_settings("opsys")) 
     27        os = self.main.get_settings("os") 
     28        self.send_command(command, os) 
    2829 
    29     def send_command(self, command, ip, opsys): 
     30    def send_command(self, command, os): 
    3031        textbuffer = self.info_tview.get_buffer() 
    3132        textbuffer.set_text("Remoting...") 
    32         rcommand = self.main.config.get_command(command, opsys) 
    33         s = pxssh.pxssh() 
    34         if s.login(ip, self.main.username): 
    35             s.sendline(rcommand) 
    36             s.prompt() 
    37             result = s.before 
    38             s.logout() 
    39             textbuffer.set_text(result) 
     33        rcommand = self.main.config.get_command(command, os) 
     34         
     35        s = self.main.s 
     36        s.sendline(rcommand) 
     37        s.prompt() 
     38        result = s.before 
     39        textbuffer.set_text(result)