Not logged in
Check-in [d5282e9f92]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added some functionality to the menu. Not tested on the real hardware.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d5282e9f925919292a1823b8cfd3691462af8149
User & Date: petr 2010-11-11 15:20:43
Context
2010-11-11
16:12
Missed/dialed/received calls are now being shown separately. check-in: a71227df8e user: petr tags: trunk
15:20
Added some functionality to the menu. Not tested on the real hardware. check-in: d5282e9f92 user: petr tags: trunk
13:18
Added basic daemon implementation. Renamed main file. Can now read parameters from the env vars. check-in: ae7e120287 user: petr tags: trunk
Changes

Changes to static/general.css.

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
52
53
54
55
56
57
58
59









































}
#nav {
    width: 134px;
    margin-top: 15px;
    padding-bottom: 15px;
}
#header {
    border-bottom: 1px solid #AAAAAA;
}
#container {
}
#content {
    width: 810px;
    margin-top: 15px;
    margin-bottom: 15px;
    border-left: 1px solid #AAAAAA;
    padding-left: 15px;
}
#footer {
    border-top: 1px solid #AAAAAA;
    padding-top: 15px;
}
table {
    width: 100%;
}
tr:nth-child(odd) {
    background-color:#AAAAAA;
................................................................................
    color: #ccc;
    background-color: #ccc;
    border: 0;
    margin-top: 15px;
    margin-bottom: 15px;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #fff;
}
















































|







|



|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
}
#nav {
    width: 134px;
    margin-top: 15px;
    padding-bottom: 15px;
}
#header {
    border-bottom: 1px solid #ccc;
}
#container {
}
#content {
    width: 810px;
    margin-top: 15px;
    margin-bottom: 15px;
    border-left: 1px solid #ccc;
    padding-left: 15px;
}
#footer {
    border-top: 1px solid #ccc;
    padding-top: 15px;
}
table {
    width: 100%;
}
tr:nth-child(odd) {
    background-color: #AAAAAA;
................................................................................
    color: #ccc;
    background-color: #ccc;
    border: 0;
    margin-top: 15px;
    margin-bottom: 15px;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #fff;
}
#nav .menuitem {
    width: 119px;
    height: 32px;
    margin-bottom: 5px;
    font-weight: bold;
}
#nav .menuitem:hover {
    background-color: #AAAAAA;
}
#nav hr {
    width: 80%;
}
#nav h3 {
    text-align: center;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    margin-top: 0px;
    margin-botom: 0px;
    margin-left: auto;
    margin-right: auto;
    width: 80%;
}
#nav a {
    color: black;
    text-decoration: none;
    width: 100%;
    height: 32px;
    display: block;
}
#nav a:visited {
    color: black;
    text-decoration: none;
}
#nav a:hover {
    color: black;
    text-decoration: none;
}
#nav img {
    vertical-align: middle;
    border: 0px;
}

Added static/media32.png.

cannot compute difference between binary files

Added static/reboot32.png.

cannot compute difference between binary files

Added static/settings32.png.

cannot compute difference between binary files

Added static/system32.png.

cannot compute difference between binary files

Changes to templates/global.tpl.

15
16
17
18
19
20
21
22

23












24
25

















26
27
28
29
30
31
32
                <div class="yui3-g" id="header">
                    <div class="yui3-u-1">
                        <h1>Nortel 1535 Management Interface - $title</h1>
                    </div>
                </div>
                <div class="yui3-g" id="container">
                    <div class="yui3-u" id="nav">
                        <h3>Menu</h3>

                        <a href="/">All calls</a><br/>












                        <a href="/phonebook">Phonebook</a><br/>
                        <a href="/settings">Settings</a><br/>

















                    </div>
                    <div class="yui3-u" id="content">
                        $content
                    </div>
                </div>
                <div class="yui3-g" id="footer">
                    <div class="yui3-u-1 center">







|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
                <div class="yui3-g" id="header">
                    <div class="yui3-u-1">
                        <h1>Nortel 1535 Management Interface - $title</h1>
                    </div>
                </div>
                <div class="yui3-g" id="container">
                    <div class="yui3-u" id="nav">
                        <h3>Calls</h3>
                        <div class="menuitem">
                            <a href="/">All calls</a>
                        </div>
                        <div class="menuitem">
                            <a href="/missed"><img src="/static/missed32.png"/> Missed</a>
                        </div>
                        <div class="menuitem">
                            <a href="/dialed"><img src="/static/called32.png"/> Dialed</a>
                        </div>
                        <div class="menuitem">
                            <a href="/received"><img src="/static/received32.png"/> Received</a>
                        </div>
                        <h3>Phonebook</h3>
                        <div class="menuitem">
                            <a href="/phonebook">Phonebook</a>

                        </div>
                        <div class="menuitem">
                            <a href="/phonebook">Quick dial</a>
                        </div>
                        <div class="menuitem">
                            <a href="/media"><img src="/static/media32.png"/> Media</a>
                        </div>
                        <h3>System</h3>
                        <div class="menuitem">
                            <a href="/sip"><img src="/static/settings32.png"/> SIP Settings</a>
                        </div>
                        <div class="menuitem">
                            <a href="/system"><img src="/static/system32.png"/> Status</a>
                        </div>
                        <div class="menuitem">
                            <a href="/reboot"><img src="/static/reboot32.png"/> Reboot</a>
                        </div>
                    </div>
                    <div class="yui3-u" id="content">
                        $content
                    </div>
                </div>
                <div class="yui3-g" id="footer">
                    <div class="yui3-u-1 center">

Changes to web.py.

106
107
108
109
110
111
112
113














114




115

116
117
118
119
120
121
122
...
134
135
136
137
138
139
140









141
142
143
144
145
146
147
148
149
150
151
152
...
170
171
172
173
174
175
176
177
178

179


180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
    def get(self):
        t = Template("templates/global.tpl", content="templates/phonebook.tpl")
        p = open("../lgvp/phonenumber.txt", "r")
        n = maketable(loadDSV(p, separator="\t"),
                header=("Name","Number"))
        self.write(t.safe_substitute(dict(phonebook=n, title="Phonebook")))
















mapping = {"/": Index,




        "/settings": Settings,

        "/phonebook": Phonebook}


class App(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        if self.path.startswith("/static/"):
            SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
................................................................................
    def do_HEAD(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()


class NortelDaemon(Daemon):









    def run(self):
        runmain()


def runmain():
    # listen on all interfaces on port 8080
    if not os.getenv("NORTEL_BIND"):
        NORTEL_BIND = "0.0.0.0"
    else:
        NORTEL_BIND = os.getenv("NORTEL_BIND")
    if not os.getenv("NORTEL_PORT"):
        NORTEL_PORT = 8080
................................................................................
                      action="store_true",
                      dest="debug",
                      default=False,
                      help="do not fork")

    (options, args) = parser.parse_args()

    if len(args) > 1:
        print "Incorrect number of arguments"

        sys.exit(2)


    else:
        daemon = NortelDaemon("web.pid")
        if options.debug:
            runmain()
        elif args[0] == "start":
            daemon.start()
        elif args[0] == "stop":
            daemon.stop()
        elif args[0] == "restart":
            daemon.restart()
        else:
            print "Unknown command.\n"
            print parser.print_help()
            sys.exit(2)









>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
|
>







 







>
>
>
>
>
>
>
>
>

|


|







 







|
|
>

>
>


<
<
|










106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212


213
214
215
216
217
218
219
220
221
222
223
    def get(self):
        t = Template("templates/global.tpl", content="templates/phonebook.tpl")
        p = open("../lgvp/phonenumber.txt", "r")
        n = maketable(loadDSV(p, separator="\t"),
                header=("Name","Number"))
        self.write(t.safe_substitute(dict(phonebook=n, title="Phonebook")))


class Reboot(Handler):
    def get(self):
        self.write("Rebooting...")
        os.system("sync")
        os.system("reboot")


class Status(Handler):
    def get(self):
        t = Template("templates/global.tpl", content="templates/settings.tpl")
        dump = "<pre>" + "".join(os.popen("dmesg")) + "</pre>"
        self.write(t.safe_substitute({"dump": dump, "title": "System status"}))


mapping = {"/": Index,
        "/missed": Index,
        "/received": Index,
        "/dialed": Index,
        "/system": Status,
        "/sip": Settings,
        "/reboot": Reboot,
        "/phonebook": Phonebook}


class App(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        if self.path.startswith("/static/"):
            SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
................................................................................
    def do_HEAD(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()


class NortelDaemon(Daemon):
    def __init__(self, pidfile,
                 stdin="/dev/null",
                 stdout="/dev/null",
                 stderr="/dev/null",
                 options=None):
        self.options = options
        super(NortelDaemon, self).__init__(pidfile, stdin=stdin,
                              stdout=stdout, stderr=stderr)

    def run(self):
        runmain(self.options)


def runmain(options):
    # listen on all interfaces on port 8080
    if not os.getenv("NORTEL_BIND"):
        NORTEL_BIND = "0.0.0.0"
    else:
        NORTEL_BIND = os.getenv("NORTEL_BIND")
    if not os.getenv("NORTEL_PORT"):
        NORTEL_PORT = 8080
................................................................................
                      action="store_true",
                      dest="debug",
                      default=False,
                      help="do not fork")

    (options, args) = parser.parse_args()

    if (not options.debug) and (len(args) != 1):
        print "Incorrect number of arguments.\n"
        print parser.print_help()
        sys.exit(2)
    elif options.debug:
        runmain(options)
    else:
        daemon = NortelDaemon("web.pid")


        if args[0] == "start":
            daemon.start()
        elif args[0] == "stop":
            daemon.stop()
        elif args[0] == "restart":
            daemon.restart()
        else:
            print "Unknown command.\n"
            print parser.print_help()
            sys.exit(2)