Example #1
0
    if both:
        # clean_files()
        
        scenario_2 = text_to_scenario(data_2)
        psat_2 = report_to_psat(report, psat)
        report_2 = simulate_scenario(psat_2, scenario_2, clean)
        print "result 2 = '" + str(report_in_limits(report_2)) + "'"
        

def profile(run_this='generate_cases(1, 90, True, True)'):
    cProfile.run(run_this, 'foo.prof')
    print '-' * 80
    print '-' * 80
    print '-' * 80
    p = pstats.Stats('foo.prof')
    p.strip_dirs().sort_stats(-1).print_stats()


if __name__ == '__main__':
    
    grem(".", r"failure[0-9]*.txt")
    grem(".", r"outage[0-9]*.txt")
    grem(".", r"summary.txt")
    grem(".", r"stdout.txt")
    
    # generate_cases(1000, 0, True, False)
    # test_case(True)
    # profile()
    
Example #2
0
    print "result = '" + str(report_in_limits(report)) + "'"

    if both:
        # clean_files()

        scenario_2 = text_to_scenario(data_2)
        psat_2 = report_to_psat(report, psat)
        report_2 = simulate_scenario(psat_2, scenario_2, clean)
        print "result 2 = '" + str(report_in_limits(report_2)) + "'"


def profile(run_this='generate_cases(1, 90, True, True)'):
    cProfile.run(run_this, 'foo.prof')
    print '-' * 80
    print '-' * 80
    print '-' * 80
    p = pstats.Stats('foo.prof')
    p.strip_dirs().sort_stats(-1).print_stats()


if __name__ == '__main__':

    grem(".", r"failure[0-9]*.txt")
    grem(".", r"outage[0-9]*.txt")
    grem(".", r"summary.txt")
    grem(".", r"stdout.txt")

    # generate_cases(1000, 0, True, False)
    # test_case(True)
    # profile()
Example #3
0
def main():
    from optparse import OptionParser

    parser = OptionParser(
        "e.g. python main.py [test, clean, analyse, simulate, outage, failure, n-x]", version="1-Oct-09 by James Brooks"
    )
    (options, args) = parser.parse_args()

    if len(args) < 1:
        parser.error("expected more arguments")

    in_stream = sys.stdin
    out_stream = sys.stdout

    if args[0] == "outage":
        if len(args) != 2:
            parser.error("expected 2 arguments got " + str(len(args)))
        num = int(args[1])
        retval = main_outage(num, out_stream)

    elif args[0] == "n-x":
        no_input = False
        if len(args) == 3:
            if args[2] == "noInput":
                no_input = True
            else:
                parser.error("expected 2 arguments or 'noInput'.")
        elif len(args) != 2:
            parser.error("expected 2 arguments got " + str(len(args)))
        x = int(args[1])
        retval = main_n_minus_x(x, no_input, in_stream, out_stream)

    elif args[0] == "simulate":
        if len(args) != 1:
            parser.error("expected 1 argument got " + str(len(args)))
        retval = main_simulate(in_stream, out_stream)

    elif args[0] == "failure":
        no_input = False
        if len(args) == 3:
            if args[2] == "noInput":
                no_input = True
            else:
                parser.error("expected 2 arguments or 'noInput'.")
        elif len(args) != 2:
            parser.error("expected 2 arguments got " + str(len(args)))
        num = int(args[1])
        retval = main_failure(num, no_input, in_stream, out_stream)

    elif args[0] == "analyse":
        retval = main_analyse(in_stream, out_stream)

    elif args[0] == "test":
        retval = main_test(out_stream)

    elif args[0] == "clean":
        retval = 0
        grem(".", r".*\.pyc")
        grem(".", r".*\.prof")
        grem(".", r".*\.csv")

    elif args[0] == "profile":
        retval = 0
        if len(args) != 2:
            p = pstats.Stats("profile.prof")
        else:
            p = pstats.Stats(args[1])
        p.strip_dirs().sort_stats("time").print_stats()

    else:
        parser.error("expected [outage, simulate, failure] got " + str(args[0]))

    sys.exit(retval)
Example #4
0
def clean_files():
    """func clean_files          :: ->
       ----
       remove all the files from previous calcluations
    """
    grem(".", r"psat_.*\.m")
    grem(".", r"psat_.*\.txt")
    grem(".", r"matlab_.*\.m")
    grem(".", r".*\.pyc")
    grem(".", r".*\.bch")
    grem(".", r".*\.csv")
    grem(".", r".*_[1234567890]{2}\.txt")
Example #5
0
def clean_files():
    """func clean_files          :: ->
       ----
       remove all the files from previous calcluations
    """
    grem(".", r"psat_.*\.m")
    grem(".", r"psat_.*\.txt")
    grem(".", r"matlab_.*\.m")
    grem(".", r".*\.pyc")
    grem(".", r".*\.bch")
    grem(".", r".*\.csv")
    grem(".", r".*_[1234567890]{2}\.txt")
Example #6
0
def main():
    from optparse import OptionParser

    parser = OptionParser("e.g. python main.py [test, clean, analyse, simulate, outage, failure, n-x]",
                          version="1-Oct-09 by James Brooks")
    (options, args) = parser.parse_args()

    if len(args) < 1:
        parser.error("expected more arguments")

    in_stream = sys.stdin
    out_stream = sys.stdout

    if args[0] == "outage":
        if len(args) != 2:
            parser.error("expected 2 arguments got " + str(len(args)))
        num = int(args[1])
        retval = main_outage(num, out_stream)

    elif args[0] == "n-x":
        no_input = False
        if len(args) == 3:
            if args[2] == "noInput":
                no_input = True
            else:
                parser.error("expected 2 arguments or 'noInput'.")
        elif len(args) != 2:
            parser.error("expected 2 arguments got " + str(len(args)))
        x = int(args[1])
        retval = main_n_minus_x(x, no_input, in_stream, out_stream)

    elif args[0] == "simulate":
        if len(args) != 1:
            parser.error("expected 1 argument got " + str(len(args)))
        retval = main_simulate(in_stream, out_stream)

    elif args[0] == "failure":
        no_input = False
        if len(args) == 3:
            if args[2] == "noInput":
                no_input = True
            else:
                parser.error("expected 2 arguments or 'noInput'.")
        elif len(args) != 2:
            parser.error("expected 2 arguments got " + str(len(args)))
        num = int(args[1])
        retval = main_failure(num, no_input, in_stream, out_stream)

    elif args[0] == "analyse":
        retval = main_analyse(in_stream, out_stream)

    elif args[0] == "test":
        retval = main_test(out_stream)

    elif args[0] == 'clean':
        retval = 0
        grem(".", r".*\.pyc")
        grem(".", r".*\.prof")
        grem(".", r".*\.csv")

    elif args[0] == 'profile':
        retval = 0
        if len(args) != 2:
            p = pstats.Stats('profile.prof')
        else:
            p = pstats.Stats(args[1])
        p.strip_dirs().sort_stats('time').print_stats()

    else:
        parser.error("expected [outage, simulate, failure] got " + str(args[0]))

    sys.exit(retval)