Selaa lähdekoodia

[errcode] Remove unused contrib/errcode scripts

The new errdb error code database is more accurate than the regular
expression-based errcode scripts.  This patch removes errcode scripts
in favor of errdb.

The gpxebot.py script is no longer needed, gpxebot has been released
as a separate open source codebase:

  http://git.etherboot.org/?p=people/stefanha/gpxebot.git;a=summary

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Stefan Hajnoczi 14 vuotta sitten
vanhempi
commit
232c208882

+ 0
- 35
contrib/errcode/README Näytä tiedosto

@@ -1,35 +0,0 @@
1
-Error Code Lookup for iPXE
2
-==========================
3
-This program looks up iPXE error codes so you can locate the line of source
4
-code which produced the error.
5
-
6
-Setup
7
------
8
-You must run:
9
-./build_errcodedb.py >errcodedb.py
10
-
11
-This extracts error code definitions from the iPXE source code and produces a
12
-"database" which is used by the main program.
13
-
14
-Once you have done this errcode.py and errcodedb.py are the only files you
15
-need.  They are now independent of the iPXE source code and can be moved
16
-anywhere.
17
-
18
-[OPTIONAL]
19
-A PHP script is provided as a web interface.  First edit errcode.php to point
20
-$ERRCODE_PATH to the errcode.py script.  Then move errcode.php to a location
21
-visible from your web server.
22
-
23
-[OPTIONAL]
24
-A simple IRC bot is provided.  Edit ipxebot.py to fill in the IRC details.
25
-
26
-Usage
27
------
28
-Looking up error codes on the command-line:
29
-./errcode.py 0x12345678
30
-
31
-Further information
32
--------------------
33
-See http://etherboot.org/.
34
-
35
-Released under the GPL and written by Stefan Hajnoczi <stefanha@gmail.com>.

+ 0
- 93
contrib/errcode/build_errcodedb.py Näytä tiedosto

@@ -1,93 +0,0 @@
1
-#!/usr/bin/env python
2
-# Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
3
-#
4
-# This program is free software; you can redistribute it and/or
5
-# modify it under the terms of the GNU General Public License as
6
-# published by the Free Software Foundation; either version 2 of the
7
-# License, or any later version.
8
-#
9
-# This program is distributed in the hope that it will be useful, but
10
-# WITHOUT ANY WARRANTY; without even the implied warranty of
11
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
-# General Public License for more details.
13
-#
14
-# You should have received a copy of the GNU General Public License
15
-# along with this program; if not, write to the Free Software
16
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
-import sys
18
-import re
19
-
20
-pxenv_status_files = ('../../src/include/errno.h', )
21
-errfile_files = ('../../src/include/ipxe/errfile.h',
22
-            '../../src/arch/i386/include/bits/errfile.h')
23
-posix_errno_files = ('../../src/include/errno.h', )
24
-
25
-PXENV_STATUS_RE = re.compile(r'^#define\s+(PXENV_STATUS_[^\s]+)\s+(.+)$', re.M)
26
-ERRFILE_RE = re.compile(r'^#define\s+(ERRFILE_[^\s]+)\s+(.+)$', re.M)
27
-POSIX_ERRNO_RE = re.compile(r'^#define\s+(E[A-Z0-9]+)\s+(?:\\\n)?.*(0x[0-9a-f]+).*$', re.M)
28
-
29
-def err(msg):
30
-    sys.stderr.write('%s: %s\n' % (sys.argv[0], msg))
31
-    sys.exit(1)
32
-
33
-def to_pxenv_status(errno):
34
-    return errno & 0xff
35
-
36
-def to_errfile(errno):
37
-    return (errno >> 13) & 0x7ff
38
-
39
-def to_posix_errno(errno):
40
-    return (errno >> 24) & 0x7f
41
-
42
-def load_header_file(filename, regexp):
43
-    defines = {}
44
-    data = open(filename, 'r').read()
45
-    for m in regexp.finditer(data):
46
-        key, val = m.groups()
47
-        defines[key] = val
48
-    return defines
49
-
50
-def evaluate(defines, expr):
51
-    pyexpr = ''
52
-    for token in expr.split():
53
-        if token in '()':
54
-            pass
55
-        elif token.startswith('/*') or token.startswith('//'):
56
-            break
57
-        elif token.startswith('0x') or token == '|':
58
-            pyexpr += token
59
-        else:
60
-            if token in defines:
61
-                pyexpr += '0x%x' % defines[token]
62
-            else:
63
-                return -1
64
-    if not re.match(r'^[0-9a-zA-Z_|]+$', pyexpr):
65
-        err('invalid expression')
66
-    return eval(pyexpr)
67
-
68
-def build(filenames, regexp, selector):
69
-    unevaluated = {}
70
-    for filename in filenames:
71
-        unevaluated.update(load_header_file(filename, regexp))
72
-
73
-    evaluated = {}
74
-    changed = True
75
-    while changed:
76
-        changed = False
77
-        for key in list(unevaluated.keys()):
78
-            val = evaluate(evaluated, unevaluated[key])
79
-            if val != -1:
80
-                del unevaluated[key]
81
-                evaluated[key] = val
82
-                changed = True
83
-    if unevaluated:
84
-        err('unable to evaluate all #defines')
85
-
86
-    lookup = {}
87
-    for key, val in evaluated.iteritems():
88
-        lookup[selector(val)] = key
89
-    return lookup
90
-
91
-print 'pxenv_status =', repr(build(pxenv_status_files, PXENV_STATUS_RE, to_pxenv_status))
92
-print 'errfile =', repr(build(errfile_files, ERRFILE_RE, to_errfile))
93
-print 'posix_errno =', repr(build(posix_errno_files, POSIX_ERRNO_RE, to_posix_errno))

+ 0
- 83
contrib/errcode/errcode.php Näytä tiedosto

@@ -1,83 +0,0 @@
1
-<?
2
-/*
3
- * Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License as
7
- * published by the Free Software Foundation; either version 2 of the
8
- * License, or any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful, but
11
- * WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
- * General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
- */
19
-
20
-// The path to the errcode.py script.
21
-$ERRCODE_PATH = './errcode.py';
22
-?>
23
-
24
-<html>
25
-    <head>
26
-        <title>iPXE Error Code Lookup</title>
27
-        <style>
28
-            body, pre, div, form, p, h2, b, tt {
29
-                padding: 0;
30
-                border: 0;
31
-                margin: 0;
32
-            }
33
-            body {
34
-                padding: 0.5em;
35
-                width: 750px;
36
-                font-family: sans-serif;
37
-            }
38
-            pre {
39
-                margin: 0.2em;
40
-                padding: 0.1em;
41
-                background-color: #ddd;
42
-            }
43
-            form {
44
-                margin: 0.2em;
45
-            }
46
-            div {
47
-                margin: 0.2em;
48
-                padding: 0.4em;
49
-                border: 1px dashed black;
50
-            }
51
-        </style>
52
-    </head>
53
-    <body>
54
-<?
55
-if (!empty($_REQUEST['e']) && preg_match('/^(0x)?[0-9a-f]{8}$/', $_REQUEST['e'])) {
56
-?>
57
-        <pre>
58
-<?
59
-    system($ERRCODE_PATH . " " . $_REQUEST['e']);
60
-?>
61
-        </pre>
62
-<?
63
-}
64
-?>
65
-        <form action="" method="post">
66
-            <label for="e">Error code:</label>
67
-            <input type="text" name="e" id="e" value="0x12345678"></input>
68
-            <input type="submit" value="Lookup"></input>
69
-        </form>
70
-
71
-        <div>
72
-            <h2>Hint:</h2>
73
-            <p>
74
-            Firefox users can right-click on the <b>Error code</b>
75
-            text box and select <b>Add a Keyword for this Search...</b>.
76
-            Set <b>name</b> to <tt>iPXE Error Code Lookup</tt> and
77
-            <b>keyword</b> to <tt>gxpe</tt>  Then you can look up error
78
-            codes by typing something like the following in your address
79
-            bar: <tt>ipxe 0x3c018003</tt>
80
-            <p>
81
-        </div>
82
-    </body>
83
-</html>

+ 0
- 78
contrib/errcode/errcode.py Näytä tiedosto

@@ -1,78 +0,0 @@
1
-#!/usr/bin/env python
2
-# Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
3
-#
4
-# This program is free software; you can redistribute it and/or
5
-# modify it under the terms of the GNU General Public License as
6
-# published by the Free Software Foundation; either version 2 of the
7
-# License, or any later version.
8
-#
9
-# This program is distributed in the hope that it will be useful, but
10
-# WITHOUT ANY WARRANTY; without even the implied warranty of
11
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
-# General Public License for more details.
13
-#
14
-# You should have received a copy of the GNU General Public License
15
-# along with this program; if not, write to the Free Software
16
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
-import sys
18
-
19
-try:
20
-    import errcodedb
21
-except ImportError:
22
-    sys.stderr.write('Please run this first: ./build_errcodedb.py >errcodedb.py\n')
23
-    sys.exit(1)
24
-
25
-def to_pxenv_status(errno):
26
-    return errno & 0xff
27
-
28
-def to_uniq(errno):
29
-    return (errno >> 8) & 0x1f
30
-
31
-def to_errfile(errno):
32
-    return (errno >> 13) & 0x7ff
33
-
34
-def to_posix_errno(errno):
35
-    return (errno >> 24) & 0x7f
36
-
37
-def lookup_errno_component(defines, component):
38
-    if component in defines:
39
-        return defines[component]
40
-    else:
41
-        return '0x%x' % component
42
-
43
-class Errcode(object):
44
-    def __init__(self, errno):
45
-        self.pxenv_status = to_pxenv_status(errno)
46
-        self.uniq = to_uniq(errno)
47
-        self.errfile = to_errfile(errno)
48
-        self.posix_errno = to_posix_errno(errno)
49
-
50
-    def rawstr(self):
51
-        return 'pxenv_status=0x%x uniq=%d errfile=0x%x posix_errno=0x%x' % (self.pxenv_status, self.uniq, self.errfile, self.posix_errno)
52
-
53
-    def prettystr(self):
54
-        return 'pxenv_status=%s uniq=%d errfile=%s posix_errno=%s' % (
55
-                lookup_errno_component(errcodedb.pxenv_status, self.pxenv_status),
56
-                self.uniq,
57
-                lookup_errno_component(errcodedb.errfile, self.errfile),
58
-                lookup_errno_component(errcodedb.posix_errno, self.posix_errno)
59
-                )
60
-
61
-    def __str__(self):
62
-        return self.prettystr()
63
-
64
-def usage():
65
-    sys.stderr.write('usage: %s ERROR_NUMBER\n' % sys.argv[0])
66
-    sys.exit(1)
67
-
68
-if __name__ == '__main__':
69
-    if len(sys.argv) != 2:
70
-        usage()
71
-
72
-    try:
73
-        errno = int(sys.argv[1], 16)
74
-    except ValueError:
75
-        usage()
76
-
77
-    print Errcode(errno)
78
-    sys.exit(0)

+ 0
- 124
contrib/errcode/gpxebot.py Näytä tiedosto

@@ -1,124 +0,0 @@
1
-#!/usr/bin/env python
2
-# Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
3
-#
4
-# This program is free software; you can redistribute it and/or
5
-# modify it under the terms of the GNU General Public License as
6
-# published by the Free Software Foundation; either version 2 of the
7
-# License, or any later version.
8
-#
9
-# This program is distributed in the hope that it will be useful, but
10
-# WITHOUT ANY WARRANTY; without even the implied warranty of
11
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
-# General Public License for more details.
13
-#
14
-# You should have received a copy of the GNU General Public License
15
-# along with this program; if not, write to the Free Software
16
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
-import re
18
-import socket
19
-import errcode
20
-
21
-HOST = 'irc.freenode.net'
22
-PORT = 6667
23
-NICK = 'ipxebot'
24
-CHAN = '#etherboot'
25
-NICKSERV_PASSWORD = None
26
-IDENT = 'ipxebot'
27
-REALNAME = 'iPXE bot'
28
-
29
-ERRCODE_RE = re.compile(r'(errcode|Error)\s+((0x)?[0-9a-fA-F]{8})')
30
-
31
-NO_ARGS = -1
32
-
33
-handlers = {}
34
-
35
-def nick_from_mask(mask):
36
-    return (mask.find('!') > -1 and mask.split('!', 1)[0]) or mask
37
-
38
-def autojoin():
39
-    del handlers['376']
40
-    if NICKSERV_PASSWORD:
41
-        pmsg('nickserv', 'identify %s' % NICKSERV_PASSWORD)
42
-    if CHAN:
43
-        cmd('JOIN %s' % CHAN)
44
-
45
-def ping(_, arg):
46
-    cmd('PONG %s' % arg)
47
-
48
-def privmsg(_, target, msg):
49
-    if target == CHAN:
50
-        replyto = target
51
-        if msg.find(NICK) == -1:
52
-            return
53
-    elif target == NICK:
54
-        replyto = nick_from_mask(who)
55
-    m = ERRCODE_RE.search(msg)
56
-    if m:
57
-        try:
58
-            pmsg(replyto, str(errcode.Errcode(int(m.groups()[1], 16))))
59
-        except ValueError:
60
-            pass
61
-    if msg.find('help') > -1:
62
-        pmsg(replyto, 'I look up iPXE error codes.  Message me like this:')
63
-        pmsg(replyto, 'errcode 0x12345678  OR  Error 0x12345678')
64
-
65
-def add_handler(command, handler, nargs):
66
-    handlers[command] = (handler, nargs)
67
-
68
-def cmd(msg):
69
-    sock.sendall('%s\r\n' % msg)
70
-
71
-def pmsg(target, msg):
72
-    cmd('PRIVMSG %s :%s' % (target, msg))
73
-
74
-def dispatch(args):
75
-    command = args[0]
76
-    if command in handlers:
77
-        h = handlers[command]
78
-        if h[1] == NO_ARGS:
79
-            h[0]()
80
-        elif len(args) == h[1]:
81
-            h[0](*args)
82
-
83
-def parse(line):
84
-    if line[0] == ':':
85
-        who, line = line.split(None, 1)
86
-        who = who[1:]
87
-    else:
88
-        who = None
89
-    args = []
90
-    while line and line[0] != ':' and line.find(' ') != -1:
91
-        fields = line.split(None, 1)
92
-        if len(fields) == 1:
93
-            fields.append(None)
94
-        arg, line = fields
95
-        args.append(arg)
96
-    if line:
97
-        if line[0] == ':':
98
-            args.append(line[1:])
99
-        else:
100
-            args.append(line)
101
-    return who, args
102
-
103
-add_handler('376', autojoin, NO_ARGS)
104
-add_handler('PING', ping, 2)
105
-add_handler('PRIVMSG', privmsg, 3)
106
-
107
-sock = socket.socket()
108
-sock.connect((HOST, PORT))
109
-cmd('NICK %s' % NICK)
110
-cmd('USER %s none none :%s' % (IDENT, REALNAME))
111
-
112
-rbuf = ''
113
-while True:
114
-    r = sock.recv(4096)
115
-    if not r:
116
-        break
117
-    rbuf += r
118
-
119
-    while rbuf.find('\r\n') != -1:
120
-        line, rbuf = rbuf.split('\r\n', 1)
121
-        if not line:
122
-            continue
123
-        who, args = parse(line)
124
-        dispatch(args)

Loading…
Peruuta
Tallenna