| 1 | #!/usr/bin/env python |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | # Copyright (C) 2008 Adriano Monteiro Marques |
|---|
| 4 | # |
|---|
| 5 | # Author: Francesco Piccinno <stack.box@gmail.com> |
|---|
| 6 | # |
|---|
| 7 | # This program is free software; you can redistribute it and/or modify |
|---|
| 8 | # it under the terms of the GNU General Public License as published by |
|---|
| 9 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | # (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, |
|---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | # GNU General Public License for more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License |
|---|
| 18 | # along with this program; if not, write to the Free Software |
|---|
| 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | import os, sys |
|---|
| 22 | from umit.plugin.Engine import Plugin |
|---|
| 23 | from functools import update_wrapper |
|---|
| 24 | |
|---|
| 25 | if os.name != "posix": |
|---|
| 26 | raise Exception("I need Linux to work") |
|---|
| 27 | |
|---|
| 28 | def trace(f): |
|---|
| 29 | def newf(*args, **kw): |
|---|
| 30 | print "calling %s with args %s, %s" % (f.__name__, args, kw) |
|---|
| 31 | return f(*args, **kw) |
|---|
| 32 | return update_wrapper(newf, f) |
|---|
| 33 | |
|---|
| 34 | class SystemInfo(Plugin): |
|---|
| 35 | def start(self, reader): |
|---|
| 36 | pass |
|---|
| 37 | |
|---|
| 38 | def stop(self): |
|---|
| 39 | pass |
|---|
| 40 | |
|---|
| 41 | @trace |
|---|
| 42 | def get_routes(self): |
|---|
| 43 | return "".join(os.popen("route -n").readlines()) |
|---|
| 44 | |
|---|
| 45 | @trace |
|---|
| 46 | def get_ifaces(self): |
|---|
| 47 | return "".join(os.popen("ifconfig -a").readlines()) |
|---|
| 48 | |
|---|
| 49 | @trace |
|---|
| 50 | def get_name(self): |
|---|
| 51 | return " ".join(os.uname()) |
|---|
| 52 | |
|---|
| 53 | __plugins__ = [SystemInfo] |
|---|