From 232c208882047210b0054d3d939ae5d45ab214f7 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Sun, 11 Jul 2010 08:52:57 +0100 Subject: [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 Signed-off-by: Michael Brown --- contrib/errcode/README | 35 ----------- contrib/errcode/build_errcodedb.py | 93 ---------------------------- contrib/errcode/errcode.php | 83 ------------------------- contrib/errcode/errcode.py | 78 ----------------------- contrib/errcode/gpxebot.py | 124 ------------------------------------- 5 files changed, 413 deletions(-) delete mode 100644 contrib/errcode/README delete mode 100755 contrib/errcode/build_errcodedb.py delete mode 100644 contrib/errcode/errcode.php delete mode 100755 contrib/errcode/errcode.py delete mode 100755 contrib/errcode/gpxebot.py (limited to 'contrib') diff --git a/contrib/errcode/README b/contrib/errcode/README deleted file mode 100644 index eb66d069..00000000 --- a/contrib/errcode/README +++ /dev/null @@ -1,35 +0,0 @@ -Error Code Lookup for iPXE -========================== -This program looks up iPXE error codes so you can locate the line of source -code which produced the error. - -Setup ------ -You must run: -./build_errcodedb.py >errcodedb.py - -This extracts error code definitions from the iPXE source code and produces a -"database" which is used by the main program. - -Once you have done this errcode.py and errcodedb.py are the only files you -need. They are now independent of the iPXE source code and can be moved -anywhere. - -[OPTIONAL] -A PHP script is provided as a web interface. First edit errcode.php to point -$ERRCODE_PATH to the errcode.py script. Then move errcode.php to a location -visible from your web server. - -[OPTIONAL] -A simple IRC bot is provided. Edit ipxebot.py to fill in the IRC details. - -Usage ------ -Looking up error codes on the command-line: -./errcode.py 0x12345678 - -Further information -------------------- -See http://etherboot.org/. - -Released under the GPL and written by Stefan Hajnoczi . diff --git a/contrib/errcode/build_errcodedb.py b/contrib/errcode/build_errcodedb.py deleted file mode 100755 index 99072922..00000000 --- a/contrib/errcode/build_errcodedb.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2008 Stefan Hajnoczi . -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import sys -import re - -pxenv_status_files = ('../../src/include/errno.h', ) -errfile_files = ('../../src/include/ipxe/errfile.h', - '../../src/arch/i386/include/bits/errfile.h') -posix_errno_files = ('../../src/include/errno.h', ) - -PXENV_STATUS_RE = re.compile(r'^#define\s+(PXENV_STATUS_[^\s]+)\s+(.+)$', re.M) -ERRFILE_RE = re.compile(r'^#define\s+(ERRFILE_[^\s]+)\s+(.+)$', re.M) -POSIX_ERRNO_RE = re.compile(r'^#define\s+(E[A-Z0-9]+)\s+(?:\\\n)?.*(0x[0-9a-f]+).*$', re.M) - -def err(msg): - sys.stderr.write('%s: %s\n' % (sys.argv[0], msg)) - sys.exit(1) - -def to_pxenv_status(errno): - return errno & 0xff - -def to_errfile(errno): - return (errno >> 13) & 0x7ff - -def to_posix_errno(errno): - return (errno >> 24) & 0x7f - -def load_header_file(filename, regexp): - defines = {} - data = open(filename, 'r').read() - for m in regexp.finditer(data): - key, val = m.groups() - defines[key] = val - return defines - -def evaluate(defines, expr): - pyexpr = '' - for token in expr.split(): - if token in '()': - pass - elif token.startswith('/*') or token.startswith('//'): - break - elif token.startswith('0x') or token == '|': - pyexpr += token - else: - if token in defines: - pyexpr += '0x%x' % defines[token] - else: - return -1 - if not re.match(r'^[0-9a-zA-Z_|]+$', pyexpr): - err('invalid expression') - return eval(pyexpr) - -def build(filenames, regexp, selector): - unevaluated = {} - for filename in filenames: - unevaluated.update(load_header_file(filename, regexp)) - - evaluated = {} - changed = True - while changed: - changed = False - for key in list(unevaluated.keys()): - val = evaluate(evaluated, unevaluated[key]) - if val != -1: - del unevaluated[key] - evaluated[key] = val - changed = True - if unevaluated: - err('unable to evaluate all #defines') - - lookup = {} - for key, val in evaluated.iteritems(): - lookup[selector(val)] = key - return lookup - -print 'pxenv_status =', repr(build(pxenv_status_files, PXENV_STATUS_RE, to_pxenv_status)) -print 'errfile =', repr(build(errfile_files, ERRFILE_RE, to_errfile)) -print 'posix_errno =', repr(build(posix_errno_files, POSIX_ERRNO_RE, to_posix_errno)) diff --git a/contrib/errcode/errcode.php b/contrib/errcode/errcode.php deleted file mode 100644 index f4774f03..00000000 --- a/contrib/errcode/errcode.php +++ /dev/null @@ -1,83 +0,0 @@ -. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -// The path to the errcode.py script. -$ERRCODE_PATH = './errcode.py'; -?> - - - - iPXE Error Code Lookup - - - - -
-
-        
- -
- - - -
- -
-

Hint:

-

- Firefox users can right-click on the Error code - text box and select Add a Keyword for this Search.... - Set name to iPXE Error Code Lookup and - keyword to gxpe Then you can look up error - codes by typing something like the following in your address - bar: ipxe 0x3c018003 -

-

- - diff --git a/contrib/errcode/errcode.py b/contrib/errcode/errcode.py deleted file mode 100755 index 7bc8d9e1..00000000 --- a/contrib/errcode/errcode.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2008 Stefan Hajnoczi . -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import sys - -try: - import errcodedb -except ImportError: - sys.stderr.write('Please run this first: ./build_errcodedb.py >errcodedb.py\n') - sys.exit(1) - -def to_pxenv_status(errno): - return errno & 0xff - -def to_uniq(errno): - return (errno >> 8) & 0x1f - -def to_errfile(errno): - return (errno >> 13) & 0x7ff - -def to_posix_errno(errno): - return (errno >> 24) & 0x7f - -def lookup_errno_component(defines, component): - if component in defines: - return defines[component] - else: - return '0x%x' % component - -class Errcode(object): - def __init__(self, errno): - self.pxenv_status = to_pxenv_status(errno) - self.uniq = to_uniq(errno) - self.errfile = to_errfile(errno) - self.posix_errno = to_posix_errno(errno) - - def rawstr(self): - return 'pxenv_status=0x%x uniq=%d errfile=0x%x posix_errno=0x%x' % (self.pxenv_status, self.uniq, self.errfile, self.posix_errno) - - def prettystr(self): - return 'pxenv_status=%s uniq=%d errfile=%s posix_errno=%s' % ( - lookup_errno_component(errcodedb.pxenv_status, self.pxenv_status), - self.uniq, - lookup_errno_component(errcodedb.errfile, self.errfile), - lookup_errno_component(errcodedb.posix_errno, self.posix_errno) - ) - - def __str__(self): - return self.prettystr() - -def usage(): - sys.stderr.write('usage: %s ERROR_NUMBER\n' % sys.argv[0]) - sys.exit(1) - -if __name__ == '__main__': - if len(sys.argv) != 2: - usage() - - try: - errno = int(sys.argv[1], 16) - except ValueError: - usage() - - print Errcode(errno) - sys.exit(0) diff --git a/contrib/errcode/gpxebot.py b/contrib/errcode/gpxebot.py deleted file mode 100755 index 4db4033c..00000000 --- a/contrib/errcode/gpxebot.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2008 Stefan Hajnoczi . -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import re -import socket -import errcode - -HOST = 'irc.freenode.net' -PORT = 6667 -NICK = 'ipxebot' -CHAN = '#etherboot' -NICKSERV_PASSWORD = None -IDENT = 'ipxebot' -REALNAME = 'iPXE bot' - -ERRCODE_RE = re.compile(r'(errcode|Error)\s+((0x)?[0-9a-fA-F]{8})') - -NO_ARGS = -1 - -handlers = {} - -def nick_from_mask(mask): - return (mask.find('!') > -1 and mask.split('!', 1)[0]) or mask - -def autojoin(): - del handlers['376'] - if NICKSERV_PASSWORD: - pmsg('nickserv', 'identify %s' % NICKSERV_PASSWORD) - if CHAN: - cmd('JOIN %s' % CHAN) - -def ping(_, arg): - cmd('PONG %s' % arg) - -def privmsg(_, target, msg): - if target == CHAN: - replyto = target - if msg.find(NICK) == -1: - return - elif target == NICK: - replyto = nick_from_mask(who) - m = ERRCODE_RE.search(msg) - if m: - try: - pmsg(replyto, str(errcode.Errcode(int(m.groups()[1], 16)))) - except ValueError: - pass - if msg.find('help') > -1: - pmsg(replyto, 'I look up iPXE error codes. Message me like this:') - pmsg(replyto, 'errcode 0x12345678 OR Error 0x12345678') - -def add_handler(command, handler, nargs): - handlers[command] = (handler, nargs) - -def cmd(msg): - sock.sendall('%s\r\n' % msg) - -def pmsg(target, msg): - cmd('PRIVMSG %s :%s' % (target, msg)) - -def dispatch(args): - command = args[0] - if command in handlers: - h = handlers[command] - if h[1] == NO_ARGS: - h[0]() - elif len(args) == h[1]: - h[0](*args) - -def parse(line): - if line[0] == ':': - who, line = line.split(None, 1) - who = who[1:] - else: - who = None - args = [] - while line and line[0] != ':' and line.find(' ') != -1: - fields = line.split(None, 1) - if len(fields) == 1: - fields.append(None) - arg, line = fields - args.append(arg) - if line: - if line[0] == ':': - args.append(line[1:]) - else: - args.append(line) - return who, args - -add_handler('376', autojoin, NO_ARGS) -add_handler('PING', ping, 2) -add_handler('PRIVMSG', privmsg, 3) - -sock = socket.socket() -sock.connect((HOST, PORT)) -cmd('NICK %s' % NICK) -cmd('USER %s none none :%s' % (IDENT, REALNAME)) - -rbuf = '' -while True: - r = sock.recv(4096) - if not r: - break - rbuf += r - - while rbuf.find('\r\n') != -1: - line, rbuf = rbuf.split('\r\n', 1) - if not line: - continue - who, args = parse(line) - dispatch(args) -- cgit v1.2.3-55-g7522