~clicompanion-devs/clicompanion/clicomp-glade

« back to all changes in this revision

Viewing changes to comps.drafts.builds/old/clicompanion-0.0.1.py.Version

  • Committer: duanedesign
  • Date: 2010-04-04 05:50:48 UTC
  • Revision ID: duanedesign@gmail.com-20100404055048-hqptxm1na56lawe6
"added scroling, 56 command capacity"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import os
 
4
import curses
 
5
 
 
6
 
 
7
 
 
8
def get_param(screen,y,x, prompt_string):
 
9
 
 
10
    screen.addstr(y, x, prompt_string)
 
11
    screen.refresh()
 
12
    input = screen.getstr(21, 4, 60)
 
13
    return input
 
14
 
 
15
def execute_cmd(screen, cmd_string):
 
16
    os.system("clear")
 
17
    a = os.system(cmd_string)
 
18
    print ""
 
19
    if a == 0:
 
20
        print  cmd_string + " executed correctly"
 
21
 
 
22
    else:
 
23
        print "Command terminated with error"
 
24
    raw_input("Press enter")
 
25
    print ""
 
26
    
 
27
 
 
28
def main(screen):
 
29
 
 
30
 
 
31
    if curses.has_colors():
 
32
 
 
33
        bg = curses.COLOR_WHITE
 
34
        curses.init_pair(1, curses.COLOR_BLUE, bg)
 
35
        curses.init_pair(2, curses.COLOR_RED, bg)
 
36
 
 
37
 
 
38
    x = "0"
 
39
    bye = "20"
 
40
 
 
41
    while x != "20":
 
42
 
 
43
        curses.echo()
 
44
        curses.nocbreak()
 
45
 
 
46
        screen.clear()
 
47
        screen.border(0)
 
48
        screen.addstr(2, 2, "Please enter a number then hit Enter",curses.A_BOLD)
 
49
        screen.addstr(4, 4, "1 - Find version of an installed package", curses.color_pair(1))
 
50
        screen.addstr(5, 4, "2 - List installed packages", curses.color_pair(1))
 
51
        screen.addstr(6, 4, "3 - Show disk space", curses.color_pair(1))
 
52
        screen.addstr(7, 4, "4 - Show RAM usage", curses.color_pair(1))
 
53
        screen.addstr(8, 4, "5 - Display network information", curses.color_pair(1))
 
54
        screen.addstr(9, 4, "6 - Display wireless information", curses.color_pair(1))
 
55
        screen.addstr(10, 4, "7 - Scan wireless networks", curses.color_pair(1))
 
56
        screen.addstr(11, 4, "8 - Reset the network", curses.color_pair(1))
 
57
        screen.addstr(12, 4, "9 - What version of Ubuntu do I have?", curses.color_pair(1))
 
58
        screen.addstr(13, 4, "10 - Kernel Information", curses.color_pair(1))
 
59
        screen.addstr(14, 4, "11 - Refresh update info and update all packages", curses.color_pair(1))
 
60
        screen.addstr(15, 4, "12 - Find information on a package (not installed)", curses.color_pair(1))
 
61
        screen.addstr(16, 4, "13 - Locate a file on your computer", curses.color_pair(1))
 
62
        screen.addstr(17, 4, "20 - Exit", curses.color_pair(2))
 
63
        screen.refresh()
 
64
     
 
65
 
 
66
        x = screen.getstr(18,4, 2)
 
67
 
 
68
        if x == "1" :
 
69
            package = get_param(screen, 20, 4, "Enter the package name")
 
70
            execute_cmd(screen,"dpkg -s" + package)
 
71
 
 
72
        if x == "2" :
 
73
            execute_cmd(screen, "dpkg -l")
 
74
 
 
75
        if x == "3" :
 
76
            execute_cmd(screen, "df -h")
 
77
 
 
78
        if x == "4" :
 
79
            execute_cmd(screen, "free -m")
 
80
 
 
81
        if x == "5" :
 
82
            execute_cmd(screen, "ifconfig")
 
83
 
 
84
        if x == "6" :
 
85
            execute_cmd(screen, "iwconfig")
 
86
 
 
87
        if x == "7" :
 
88
            execute_cmd(screen, "sudo iwlist scan")
 
89
 
 
90
        if x == "8" :
 
91
            execute_cmd(screen, "sudo /etc/init.d/networking restart")
 
92
 
 
93
        if x == "9" :
 
94
            execute_cmd(screen, "lsb_release -a")
 
95
 
 
96
        if x == "10" :
 
97
            execute_cmd(screen, "uname -a")
 
98
 
 
99
        if x == "11" :
 
100
            execute_cmd(screen, "sudo apt-get update && sudo apt-get upgrade")
 
101
 
 
102
        if x == "12" :
 
103
            package = get_param(screen, 20, 4,"Enter the package name")
 
104
            execute_cmd(screen, "apt-cache search " + package)
 
105
 
 
106
        if x == "13" :
 
107
            package = get_param(screen, 20, 4,"Enter the file name")
 
108
            execute_cmd(screen, "locate " + package)
 
109
 
 
110
 
 
111
curses.wrapper(main)
 
112
curses.endwin()
 
113
 
 
114