Example #1
0
def run_python_demo(prefix, demo, rootdir, timing, failed):
    print("----------------------------------------------------------------------")
    print("Running Python demo %s%s" % (prefix, demo))
    print("")

    demodir = demo if os.path.isdir(demo) else os.path.dirname(demo)
    demofile = get_executable_name(demo, "python") + '.py'

    t1 = time()
    os.chdir(demodir)
    status, output = get_status_output("%s %s -u %s" % (prefix, sys.executable, demofile))
    os.chdir(rootdir)
    t2 = time()
    timing += [(t2 - t1, prefix+" "+demo)]

    if status == 0:
        print("OK")
    elif status == 10: # Failing but exiting gracefully
        print("ok (graceful exit on fail)")
    else:
        print("*** Failed")
        print(output)

        # Add contents from Instant's compile.log to output
        instant_compile_log = os.path.join(get_default_error_dir(), "compile.log")
        if os.path.isfile(instant_compile_log):
            instant_error = file(instant_compile_log).read()
            output += "\n\nInstant compile.log for %s:\n\n" % demo
            output += instant_error
        failed += [(demo, "Python", prefix, output)]
Example #2
0
def run_python_demo(prefix, demo, rootdir, timing, failed):
    print(
        "----------------------------------------------------------------------"
    )
    print("Running Python demo %s%s" % (prefix, demo))
    print("")

    demofile = get_executable_name(demo, "python") + '.py'

    t1 = time()
    os.chdir(demo)
    status, output = get_status_output("%s %s -u %s" %
                                       (prefix, sys.executable, demofile))
    os.chdir(rootdir)
    t2 = time()
    timing += [(t2 - t1, demo)]

    if status == 0:
        print("OK")
    elif status == 10:  # Failing but exiting gracefully
        print("ok (graceful exit on fail)")
    else:
        print("*** Failed")
        print(output)

        # Add contents from Instant's compile.log to output
        instant_compile_log = os.path.join(instant.get_default_error_dir(),
                                           "compile.log")
        if os.path.isfile(instant_compile_log):
            instant_error = file(instant_compile_log).read()
            output += "\n\nInstant compile.log for %s:\n\n" % demo
            output += instant_error
        failed += [(demo, "Python", prefix, output)]
Example #3
0
File: test.py Project: alogg/dolfin
        demofile = get_executable_name(demo, "python") + '.py'
        if os.path.isfile(os.path.join(demo, demofile)):
            t1 = time()
            status, output = getstatusoutput("cd %s && %s python %s" % (demo, prefix, demofile))
            t2 = time()
            timing += [(t2 - t1, demo)]
            if status == 0:
                print "OK"
            elif status == 10: # Failing but exiting gracefully
                print "ok (graceful exit on fail)"
            else:
                print "*** Failed"
                print output

                # Add contents from Instant's compile.log to output
                instant_compile_log = os.path.join(instant.get_default_error_dir(), "compile.log")
                if os.path.isfile(instant_compile_log):
                    instant_error = file(instant_compile_log).read()
                    output += "\n\nInstant compile.log for %s:\n\n" % demo
                    output += instant_error
                failed += [(demo, "Python", prefix, output)]
        else:
            print "*** Warning: missing demo"

# Print summary of time to run demos
timing.sort()
print ""
print "Time to run demos:"
print "\n".join("%.2fs: %s" % t for t in timing)

total_no_demos = len(pydemos)
Example #4
0
            t1 = time()
            os.chdir(demo)
            status, output = get_status_output("%s python %s" % (prefix, demofile))
            os.chdir(rootdir)
            t2 = time()
            timing += [(t2 - t1, demo)]
            if status == 0:
                print "OK"
            elif status == 10: # Failing but exiting gracefully
                print "ok (graceful exit on fail)"
            else:
                print "*** Failed"
                print output

                # Add contents from Instant's compile.log to output
                instant_compile_log = os.path.join(instant.get_default_error_dir(), "compile.log")
                if os.path.isfile(instant_compile_log):
                    instant_error = file(instant_compile_log).read()
                    output += "\n\nInstant compile.log for %s:\n\n" % demo
                    output += instant_error
                failed += [(demo, "Python", prefix, output)]
        else:
            print "*** Warning: missing demo"

# Print summary of time to run demos
timing.sort()
print ""
print "Time to run demos:"
print "\n".join("%.2fs: %s" % t for t in timing)

total_no_demos = len(pydemos)
Example #5
0
tmp = instant.get_temp_dir()
tmp_dir_prefix = os.path.split(tmp)[0]
# FIXME: Is it safe to assume that the prefix to tempdirs is constant on a platform?
s = re.search(r"(.*)%s[^%s]*instant_%s" % (os.path.pathsep, os.path.pathsep, \
                                           instant_tmp_dir_suffix), tmp)
instant.delete_temp_dir()
tmp_dirs = glob.glob(
    os.path.join(tmp_dir_prefix, '*instant_' + instant_tmp_dir_suffix))
for d in tmp_dirs:
    if os.path.isdir(d):
        print("Deleting temp directory", d)
        shutil.rmtree(d, ignore_errors=True)

# Get default cache dir (won't and can't touch userdefined cache dirs in this script)
cache_dir = instant.get_default_cache_dir()
error_dir = instant.get_default_error_dir()

# Check if directory exists (it always should after calling get_default_cache_dir)
assert os.path.isdir(cache_dir)
assert os.path.isdir(error_dir)

# Get list of cached forms
modules = os.listdir(cache_dir)
error_logs = os.listdir(error_dir)
if len(modules + error_logs) == 0:
    print("Instant cache is empty")
    sys.exit(0)

# Remove cached forms
lockfiles = [m for m in modules if m.endswith(".lock")]
modules = [m for m in modules if not m.endswith(".lock")]