Changeset 22

Show
Ignore:
Timestamp:
01/23/09 15:06:51 (3 years ago)
Author:
lasarux
Message:
  • config.py:
  • config.yaml:
  • misc/utils.py:
  • plugins/info/info/init.py:
  • plugins/zfs/zfs/init.py:
  • plugins/zfs/zfs/zfs.glade: More changes in config stuff. ZFS plugin uses the current connection.
Location:
trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r21 r22  
     12009-01-23  Pedro Gracia,,,  <lasarux@gmail.com> 
     2 
     3        * config.py: 
     4        * config.yaml: 
     5        * misc/utils.py: 
     6        * plugins/info/info/__init__.py: 
     7        * plugins/zfs/zfs/__init__.py: 
     8        * plugins/zfs/zfs/zfs.glade: 
     9        More changes in config stuff. 
     10        ZFS plugin uses the current connection.          
     11 
    1122009-01-23  Pedro Gracia,,,  <lasarux@gmail.com> 
    213 
  • trunk/config.py

    r11 r22  
    1111REMOTE = "TERM=unix LC_ALL=C" 
    1212 
    13 def get_command(command, opsys): 
     13def get_command(command, os): 
     14    columns = COMMANDS[command]["columns"] 
    1415    try: 
    15         args = COMMANDS[command][opsys] 
     16        args = COMMANDS[command][os] 
    1617    except: 
    1718        args = COMMANDS[command]["default"] 
    18     return "%s %s" % (command, args) 
    19  
    20 def send_command(command, ip, opsys): 
    21     rcommand = get_command(command, opsys) 
    22     s = pxssh.pxssh() 
    23     if s.login(ip, user): 
    24         s.sendline("%s %s " % (REMOTE, rcommand)) 
    25         s.prompt() 
    26         result = s.before 
    27         s.logout() 
    28         # process data 
    29         regex = COMMANDS[command]["regex"] 
    30         headlines = int(COMMANDS[command]["headlines"]) 
    31         p = re.compile(regex) 
    32         #for i in result.splitlines()[headlines+1:]: 
    33         #    m = p.search(i) 
    34         #    m.group("size") 
    35         return result 
     19    return "%s %s" % (command, args), columns 
  • trunk/config.yaml

    r20 r22  
    147147        default: -h 
    148148        headlines: 1 
     149        columns: ["Filesystem", "Size", "Used", "Avail", "Capacity", "Mounted on"] 
    149150        regex: (?P<filesystem>[\w\/\[\]<>-]+|automount -[\w]+ \[[\d]+\])\s+\ 
    150151                (?P<size>[\w,.]+)\s+\ 
  • trunk/misc/utils.py

    r21 r22  
     1# -*- coding: utf-8 -*- 
    12import gtk 
    23 
  • trunk/plugins/info/info/__init__.py

    r21 r22  
    3232        #textbuffer = self.info_tview.get_buffer() 
    3333        #textbuffer.set_text("Remoting...") 
    34         rcommand = self.main.config.get_command(command, os) 
     34        rcommand, columns = self.main.config.get_command(command, os) 
    3535         
    3636        s = self.main.s 
  • trunk/plugins/zfs/zfs/__init__.py

    r21 r22  
    55import simplepanels 
    66import gtk 
    7  
    8 TEST_ZFS_LIST=["NAME                      USED  AVAIL  REFER  MOUNTPOINT",  
    9 "rpool                    3,29G  11,8G    46K  /rpool", 
    10 "rpool/ROOT               2,28G  11,8G    18K  legacy", 
    11 "rpool/ROOT/opensolaris   2,28G  11,8G  2,22G  /", 
    12 "rpool/dump                511M  11,8G   511M  -", 
    13 "rpool/export             5,09M  11,8G    19K  /export", 
    14 "rpool/export/home        5,07M  11,8G    19K  /export/home", 
    15 "rpool/export/home/pedro  5,05M  11,8G  5,05M  /export/home/pedro", 
    16 "rpool/swap                512M  12,3G    16K  -"] 
    17  
    18  
    19  
    207 
    218class ZFSPlugin(object, SimpleGladeApp): 
     
    3118        self.main = main 
    3219        self.root.reparent(main.zfs_vbox) 
     20         
     21    def on_refresh_btn_clicked(self, button): 
    3322        self.show_list() 
    3423         
    3524    def show_list(self): 
    3625        """Show 'zfs list' info""" 
     26        s = self.main.s 
     27        s.sendline("zfs list") 
     28        s.prompt() 
     29        result = s.before.split("\n")[2:] 
     30         
    3731        columns = [('visible', 'str', 'Name'), 
    3832                   ('visible', 'str', 'Used'), 
     
    4236                   ] 
    4337        data = [] 
    44         for i in TEST_ZFS_LIST[1:]: 
    45             data.append(i.split()) 
     38        for i in result: 
     39            row = i.split() 
     40            if len(row) == len(columns): 
     41                data.append(row) 
    4642         
    4743        self.t = Treeview("list", columns, data, self.list_treeview) 
  • trunk/plugins/zfs/zfs/zfs.glade

    r19 r22  
    5757            </child> 
    5858            <child> 
    59               <widget class="GtkButton" id="button3"> 
     59              <widget class="GtkButton" id="refresh_btn"> 
    6060                <property name="visible">True</property> 
    6161                <property name="can_focus">True</property> 
     
    6464                <property name="use_stock">True</property> 
    6565                <property name="response_id">0</property> 
     66                <signal name="clicked" handler="on_refresh_btn_clicked"/> 
    6667              </widget> 
    6768              <packing>