Example #1
0
def _testFilename(inputname, outputname):
    import AUTOclui, AUTOutil, runAUTO
    old_path = os.getcwd()
    log = open("log", "w")

    os.environ["LANG"] = "C"
    console = AUTOInteractiveConsole(AUTOclui.exportFunctions(log=log))
    console.execfile(inputname)
    console.close()
    log.close()
    os.chdir(old_path)
    cmd = [
        "diff", "-b", "--ignore-matching-lines='.*ab\.o.*'",
        "--ignore-matching-lines='.*cir\.o.*'",
        "--ignore-matching-lines='.*wav\.o.*'",
        "--ignore-matching-lines='   [0-9][0-9 ]  .*'",
        "--ignore-matching-lines='Finished running:.*'",
        "--ignore-matching-lines='.*Location of special point.*'",
        "--ignore-matching-lines='[uU]sing .*'",
        "--ignore-matching-lines='.*Total Time.*'", "log", outputname
    ]
    status, output = AUTOutil.getstatusoutput(cmd)
    if status != 0:
        raise AUTOExceptions.AUTORegressionError(
            "Error: log files differ:\n%s" % output)
    os.system("rm -f log")
Example #2
0
    def demofile(self, name):
        """Execute an AUTO CLUI script, line by line (demo mode).

    Type demofile('xxx.auto') to step through the script xxx.auto, which
    will proceed each time you press Enter.

Aliases: demofile dmf"""
        import AUTOclui
        AUTOInteractiveConsole(AUTOclui.exportFunctions())._demofile(name)
Example #3
0
    def auto(self, name=None):
        """Execute an AUTO CLUI script.

    Type auto('xxx.auto') to run the script xxx.auto.

Aliases: auto ex"""
        import AUTOclui
        if name is not None:
            AUTOInteractiveConsole(AUTOclui.exportFunctions()).execfile(name)
        else:
            self.execfile()
Example #4
0
def automain(name=None):
    import AUTOclui
    sys.ps1 = "AUTO> "
    opts_list, args = getopt.getopt(sys.argv[1:], "c:diqtT:L:")
    opts = {}
    for x in opts_list:
        opts[x[0]] = x[1]
    demo_mode = 'no'

    use_ipython = 0
    if "-t" in opts:
        test()
        sys.exit()
    elif "-q" in opts:
        _quicktest()
        sys.exit()
    elif "-i" in opts:
        use_ipython = 1
    elif "-T" in opts:
        adjust_sys_path()
        _testFilename(opts["-T"], opts["-L"])
        sys.exit()
    elif "-d" in opts:
        demo_mode = 'yes'

    try:
        import readline
    except:
        pass

    adjust_sys_path()
    funcs = AUTOclui.exportFunctions()
    runner = AUTOInteractiveConsole(funcs)

    if len(args) > 0:
        for arg in args:
            if demo_mode == 'no':
                runner.execfile(arg)
            else:
                sys.stdout.write("Python %s on %s\n%s\n(%s)\n" %
                                 (sys.version, sys.platform, sys.copyright,
                                  runner.__class__.__name__))
                runner._demofile(arg)
    elif use_ipython:
        autoipython(funcs)
    elif "-c" in opts:
        source = ""
        for line in opts["-c"].split("\n"):
            source = source + runner.processShorthand(line) + "\n"
        runner.runsource(source, "-c", "exec")
    else:
        runner.interact()
Example #5
0
def _testFilename(inputname, outputname):
    import commands, os

    old_path = os.getcwd()
    log = open("log", "w")
    import AUTOclui

    runner = AUTOInteractiveConsole(AUTOclui.exportFunctions(log))
    runner.execfile(inputname)
    log.close()
    os.chdir(old_path)
    status, output = commands.getstatusoutput(
        "diff --ignore-matching-lines='gcc.*' --ignore-matching-lines='.*Total Time.*' log %s" % outputname
    )
    if status != 0:
        raise AUTORegressionError("Error: log files differ")
    os.system("rm -f log")
Example #6
0
        _quicktest()
        sys.exit()
    elif opts.has_key("-T"):
        _testFilename(opts["-T"], opts["-L"])
        sys.exit()
    elif opts.has_key("-d"):
        demo_mode = "yes"

    import AUTOclui

    try:
        import readline
    except:
        pass

    runner = AUTOInteractiveConsole(AUTOclui.exportFunctions())
    __builtins__.execfile = runner.execfile
    __builtins__.demofile = runner.demofile

    if len(args) > 0:
        for arg in args:
            if demo_mode == "no":
                runner.execfile(arg)
            else:
                sys.stdout.write(
                    "Python %s on %s\n%s\n(%s)\n"
                    % (sys.version, sys.platform, sys.copyright, runner.__class__.__name__)
                )
                runner.demofile(arg)
    else:
        runner.interact()
Example #7
0
#! /usr/bin/env python

# Some ways to run AUTO:
# a) python auto.py
# b) import auto
#    auto.auto()
# c) from auto import *

if __name__ == "__main__":
    import AUTOclui
    AUTOclui.auto()
else:
    from AUTOclui import *
Example #8
0
def test(demos, versions=None, log_file=None, parse=True):
    sys.stdin = nostdin()
    if demos == "selec":
        demos = DIR1
    if demos == "hom":
        demos = DIR2
    if demos == "all97":
        demos = DIR3
    if demos == "all":
        demos = DIR4

    if log_file is None:
        hostname = platform.node()
        if '.' in hostname:
            hostname = hostname.split('.')[0]
        log_file = hostname + '_log'

    if versions is None:
        versions = ['07p']

    log_files = []
    log = {}
    err = {}
    runner = {}
    for version in versions:
        if len(log_file) != 0:
            log_files.append(log_file + version)
            log[version] = open(log_file + version, "w")
            err[version] = open(log_file + version + "errors", "w")
        else:
            log[version] = None
            err[version] = None
        runner[version] = AUTOInteractiveConsole(
            AUTOclui.exportFunctions(log[version], err[version]))

    autofiles = []
    for d in demos:
        print("Doing " + d)
        for version in versions:
            print("Version " + version)
            auto_dir = os.path.join(os.environ["AUTO_DIR"], "..", version)
            demo_dir = os.path.join(auto_dir, "demos", d)
            autofiles = []
            if os.path.exists(os.path.join(demo_dir, "%s.auto" % d)):
                autofiles = ["%s.auto" % d]
            else:
                autofiles = [
                    dirname for dirname in os.listdir(demo_dir)
                    if dirname[-5:] == '.auto'
                ]
                autofiles.sort()
            if len(autofiles) > 0:
                oldcwd = os.getcwd()
                tmpdir = os.path.join(oldcwd, 'tmp')
                try:
                    shutil.rmtree(tmpdir)
                except OSError:
                    pass
                try:
                    os.mkdir(tmpdir)
                except OSError:
                    pass
                os.chdir(tmpdir)
                AUTOclui.copydemo(d)
                log[version].write("Demo %s is started\n" % d)
                for autofile in autofiles:
                    os.chdir(tmpdir)
                    runner[version].auto(autofile)
                os.chdir(oldcwd)
                log[version].write("Demo %s is done\n" % d)
            else:
                runDemo.runDemo(d,
                                verbose="yes",
                                log=log[version],
                                err=err[version],
                                auto_dir=auto_dir)
    if len(autofiles) > 0:
        try:
            shutil.rmtree(tmpdir)
        except OSError:
            pass

    if len(log_file) != 0:
        for version in versions:
            runner[version].close()
            err[version].close()
            log[version].close()

    if parse:
        parse_test.parse(log_files, demos=demos)