Beispiel #1
0
def flag_msg(msg):
    if config.logfileopen:
        # if open - write to log file
        config.writeLOG(msg + '\n')
    else:
        # otherwise - print to console
        print(msg)
    return
Beispiel #2
0
def rise_set_error(y, lats, t0):
    # unexpected rise/set values - format message line
    msg = "rise_set {} values for {}: {}".format(len(y), lats, y[0])
    if len(y) > 1:
        msg = msg + " {}".format(y[1])
    if len(y) > 2:
        msg = msg + " {}".format(y[2])
    if len(y) > 3:
        msg = msg + " {}".format(y[3])
    dt = t0.utc_datetime() + datetime.timedelta(seconds=t0.dut1)

    if config.logfileopen:
        # write to log file
        config.writeLOG("\n{}".format(dt.isoformat()))
        config.writeLOG("   " + msg)
    else:
        # print to console
        print "{}   {}".format(dt.isoformat(), msg)
    return
Beispiel #3
0
def timer_end(start, x = 0):
    stop = time.time()
    #print("start = {}".format(time.localtime(start)))
    #print("stop  = {}".format(time.localtime(stop)))
    msg = "execution time = {:0.2f} seconds".format(stop-start)
    if x < 0:
        msg += "\n"     # newline after "execution time = ..."
        x = abs(x)
    print(msg)
    if config.logfileopen: config.writeLOG("\n\n" + msg)
    if x == 0: return

    pct = 100 * config.stopwatch/(stop-start)
    msg4 = " ({:0.1f}%)".format(pct) if not config.MULTIpr else ""
    msg2 = "stopwatch      = {:0.2f} seconds".format(config.stopwatch) + msg4
    print(msg2)                 # 00000
    if config.logfileopen: config.writeLOG(msg2 + "\n")
    msg3 = "(stopwatch = time spent getting moonrise and/or moonset times)"
    #if x == 2: msg3 += "\n"
    if config.logfileopen: config.writeLOG(msg3 + "\n")
    print(msg3)                 # 00000

    if x == 1: return   # following is not required for Event Time tables
    msg5 = "stopwatch2     = {:0.2f} seconds".format(config.stopwatch2)
    print(msg5)                 # 00000
    msg6 = "(stopwatch2 = time spent searching if moon above/below horizon)"
    if x == 2: msg6 += "\n"
    print(msg6)
    return
Beispiel #4
0
def rise_set_error(y, lats, t0):
    if config.logfileopen:
        # unexpected rise/set values - write to log file
        config.writeLOG("\n\nrise_set {} values for {}: {} {} ".format(len(y),lats,y[0],y[1]))
        if len(y) > 2:
            config.writeLOG("{}".format(y[2]))
        if len(y) > 3:
            config.writeLOG("{}".format(y[3]))
        config.writeLOG("\n{}".format(t0.utc_iso()))
    else:
        # unexpected rise/set values - print to console
        msg = "rise_set {} values for {}: {} {}".format(len(y),lats.encode("utf-8"), y[0], y[1])
        print unicode(msg, "utf-8"),
        if len(y) > 2:
            print "{}".format(y[2])
        if len(y) > 3:
            print "{}".format(y[3])
        print "{}".format(t0.utc_iso())
    return