⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mtest.py

📁 这个是内存数据库中的一个管理工具
💻 PY
📖 第 1 页 / 共 5 页
字号:
#!/usr/bin/python# The contents of this file are subject to the MonetDB Public License# Version 1.1 (the "License"); you may not use this file except in# compliance with the License. You may obtain a copy of the License at# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html## Software distributed under the License is distributed on an "AS IS"# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the# License for the specific language governing rights and limitations# under the License.## The Original Code is the MonetDB Database System.## The Initial Developer of the Original Code is CWI.# Portions created by CWI are Copyright (C) 1997-2007 CWI.# All Rights Reserved.#TODO:#=====# - check all TODO's below# - tidy -up HTML-generation by "keeping in mind" during testing,#   which OUT/ERR differ or not and which tests were skipped.#   dump HTML-stuff only at end#   print an ascii summary at end, too# - if no diffs, but warnings, say so at end# - produce, keep & reference LOG# - add a "grep-like" function and replace "inlined" grep#   contains(<file>,<string>)# - do multi-level prompting?# - normalize all path's used# - remove one of milM, milStry:    Trueexcept NameError:    # provide values for old Python versions    False, True = 0, 1import osimport sysimport fileinputimport popen2import shutilimport reimport randomimport timeimport socketimport structimport select#import signal#import getpassimport Mfilterimport profimport stringF_SKIP = -1F_OK = 0F_WARN = 1F_ERROR = 2FAILURES = {    F_SKIP  : "F_SKIP",    F_OK    : "F_OK",    F_WARN  : "F_WARN",    F_ERROR : "F_ERROR"}CONDITIONALS = {    # X == true   =>  @X_TRUE@='',  @X_FALSE@='#'    # X == false  =>  @X_TRUE@='#', @X_FALSE@=''    # MonetDB:    'CROSS_COMPILING'  : "",    'DOCTOOLS'         : "#",    'HAVE_JAVA'        : "#",    'HAVE_PCRE'        : "#",    'HAVE_PERL'        : "#",    'HAVE_PERL_DEVEL'  : "#",    'HAVE_PERL_SWIG'   : "#",    'HAVE_PHP'         : "#",    'HAVE_PYTHON'      : "#",    'HAVE_PYTHON_DEVEL': "#",    'HAVE_PYTHON_SWIG' : "#",    'HAVE_SWIG'        : "#",    'LINK_STATIC'      : "",    'NOT_WIN32'        : "#",    'PROFILING'        : "",    # SQL:    'NATIVE_WIN32'     : "",    # unknown at compile time, as Mtest.py is compiled with MonetDB(4);    # hence, we set them at runtime in main() below    'HAVE_MONETDB5'    : "@HAVE_MONETDB5_FALSE@",    'HAVE_MONETDB4'    : "@HAVE_MONETDB4_FALSE@",    'MONET4'           : "@MONET4_FALSE@",    'MONET5'           : "@MONET5_FALSE@",}# a bunch of classes to help with generating (X)HTML filesclass _Encode:    # mix-in class for encoding text and attribute values so that they    # don't get interpreted as something else by the browser    def encode(self, data, attr):        map = [('&', '&amp;'),          # MUST be first               ('<', '&lt;'),               ('>', '&gt;'),               (None, None),               # following chars only translated in attr values (attr is True)               ('"', '&quot;'),               ('\t', '&#9;'),               ('\n', '&#10;'),               ('\r', '&#13;'),               ]        for c, tr in map:            if c is None:                if not attr:                    break                continue            data = data.replace(c, tr)        return dataclass Element(_Encode):    # class to represent an (X)HTML element with its attributes and    # children    # inline elements, we do not add newlines to the contents of these    # elements    inline = ['tt','i','b','big','small','em','strong','dfn','code',              'samp','kbd','var','cite','abbr','acronym','a','img',              'object','br','script','map','q','sub','sup','span',              'bdo','input','select','textarea','label','button','font']    # empty elements    empty = ['link', 'basefont', 'br', 'area', 'img', 'param', 'hr',             'input', 'col', 'frame', 'isindex', 'base', 'meta', ]    xml = True                          # write XHTML instead of HTML    def __init__(self, tag, attrdict = None, *children):        self.tag = tag        if attrdict is None:            attrdict = {}        self.attrdict = attrdict        if children is None:            children = []        self.isempty = tag.lower() in self.empty        if self.isempty:            if children:                raise ValueError("empty element can't have children")            self.children = None        else:            self.children = list(children)    def __str__(self):        # string representation of the element with its children        s = ['<%s' % self.tag]        attrlist = self.attrdict.items()        attrlist.sort()        for name, value in attrlist:            s.append(' %s="%s"' % (name, self.encode(value, True)))        if self.children or (not self.xml and not self.isempty):            s.append('>')            for c in self.children:                s.append(str(c))            s.append('</%s>' % self.tag)        elif self.xml:            s.append('/>')        else:            s.append('>')               # empty HTML element        return ''.join(s)    def write(self, f, newline = False):        # write the element with its children to a file        # if newline is set, add newlines at strategic points        if self.tag.lower() == 'html':            # before we write the DOCTYPE we should really check            # whether the document conforms...            if self.xml:                f.write('<!DOCTYPE html PUBLIC '                        '"-//W3C//DTD XHTML 1.0 Transitional//EN"\n'                        '                      '                        '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n')            else:                f.write('<!DOCTYPE html PUBLIC '                        '"-//W3C//DTD HTML 4.01 Transitional//EN"\n'                        '                      '                        '"http://www.w3.org/TR/html4/loose.dtd">\n')        inline = self.tag.lower() in self.inline        f.write('<%s' % self.tag)        attrlist = self.attrdict.items()        attrlist.sort()        for name, value in attrlist:            f.write(' %s="%s"' % (name, self.encode(value, True)))        if self.children or (not self.xml and not self.isempty):            if not inline:                for c in self.children:                    if not isinstance(c, Element):                        inline = True                        break            f.write('>')            if newline and not inline:                f.write('\n')            for c in self.children:                c.write(f, newline and not inline)            f.write('</%s>' % self.tag)        elif self.xml:            f.write('/>')        else:            f.write('>')                # empty HTML element        if newline:            f.write('\n')    def addchild(self, child):        self.children.append(child)    def addchildren(self, children):        for child in children:            self.children.append(child)    def inschild(self, index, child):        self.children.insert(index, child)class Text(_Encode):    # class to represent text in (X)HTML    def __init__(self, text = '', raw = False):        self.text = text        self.raw = raw    def __str__(self):        if self.raw:            return self.text        return self.encode(self.text, False)    def write(self, f, newline = False):        f.write(str(self))        if newline and not self.raw:            f.write('\n')class Comment:    # class to represent an (X)HTML comment (not currently used)    def __init__(self, text):        self.text = text    def __str__(self):        return '<!--%s-->' % self.text    def write(self, f, newline = False):        f.write(str(self))def _configure(str):    # expand configure variables in str and return result    config = [        ('${source}', '/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB'),        ('${build}', '/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/Fedora4'),        ('${bindir}', '${exec_prefix}/bin'),##        ('${sbindir}', '@QXsbindir@'),        ('${libexecdir}', '${exec_prefix}/libexec'),        ('${datarootdir}', ''),        ('${datadir}', '${prefix}/share'),        ('${sysconfdir}', '${prefix}/etc'),##        ('${sharedstatedir}', '@QXsharedstatedir@'),        ('${localstatedir}', '${prefix}/var'),        ('${libdir}', '${prefix}/lib64'),        ('${includedir}', '${prefix}/include'),##        ('${oldincludedir}', '@QXoldincludedir@'),        ('${infodir}', '${prefix}/info'),        ('${mandir}', '${prefix}/man'),        ('${Qbindir}', '${exec_prefix}/bin'),##        ('${Qsbindir}', '@QXsbindir@'),        ('${Qlibexecdir}', '${exec_prefix}/libexec'),        ('${Qdatarootdir}', ''),        ('${Qdatadir}', '${prefix}/share'),        ('${Qsysconfdir}', '${prefix}/etc'),##        ('${Qsharedstatedir}', '@QXsharedstatedir@'),        ('${Qlocalstatedir}', '${prefix}/var'),        ('${Qlibdir}', '${prefix}/lib64'),        ('${Qincludedir}', '${prefix}/include'),##        ('${Qoldincludedir}', '@QXoldincludedir@'),        ('${Qinfodir}', '${prefix}/info'),        ('${Qmandir}', '${prefix}/man'),        # put these at end (in this order!) for efficiency        ('${exec_prefix}', '${prefix}'),        ('${Qexec_prefix}', '${prefix}'),        ('${prefix}', '/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/.GNU.64.64.d-Fedora4'),        ('${Qprefix}', '/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/.GNU.64.64.d-Fedora4'),        ]    changed = True    while '$' in str and changed:        changed = False        for key, val in config:            nstr = str.replace(key, val)            changed = changed or str != nstr            str = nstr    return str# add dir where monet_options is installed to sys.path# we must expand configure variables in the processsys.path.append(_configure(os.path.join('${prefix}/share','MonetDB','python')))import monet_optionsSTDOUT = sys.stdoutSTDERR = sys.stdout     # errblack = 'black'                         # #000000white = 'white'                         # #ffffffred = 'red'                             # #ff0000lime = 'lime'                           # #00ff00green = '#00aa00'darkgreen = '#005500'orange = '#ffaa00'stylesheet = Element('style', None, Text('''.error   { font-weight: bold; font-style: italic; color: red; }.warning { font-weight: bold; color: orange; }.good    {  }.header  { font-family: helvetica, arial; text-align: center; }.black   { color: black; }'''))TIMES = []random.seed(time.time())def Usage (options) :    try:        monet_options.usage(options, '%s [options] ( [<dir>] [<tests>] | [<dirs>] )' % THISFILE)    except monet_options.Error:        pass    sys.stderr.write(""" <dir>   : if present, %(prog)s behaves as if called in <dir>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -