Exemple #1
0
    def __init__(self, settings, cmdoptions, q):
        threading.Thread.__init__(self)
        self.finished = threading.Event()

        self.q = q
        self.settings = settings
        self.cmdoptions = cmdoptions

        self.filter = re.compile(
            r"[\\\/\:\*\?\"\<\>\|]+"
        )  #regexp filter for the non-allowed characters in windows filenames.

        self.createLogger()
        #self.settings['General']['Log Directory'] = os.path.normpath(self.settings['General']['Log Directory'])

        # initialize self.log to None, so that we dont attempt to flush it until it exists, and so we know to open it when it's closed.
        self.log = None

        # todo: no need for float() typecasting, since that is now taken care by config validation

        # initialize the automatic zip and email timer, if enabled in .ini
        if self.settings['E-mail']['SMTP Send Email'] == True:
            self.emailtimer = mytimer.MyTimer(
                float(self.settings['E-mail']['Email Interval']) * 60 * 60, 0,
                self.SendZipByEmail)
            self.emailtimer.start()

        # initialize automatic old log deletion timer
        if self.settings['Log Maintenance']['Delete Old Logs'] == True:
            self.oldlogtimer = mytimer.MyTimer(
                float(self.settings['Log Maintenance']['Age Check Interval']) *
                60 * 60, 0, self.DeleteOldLogs)
            self.oldlogtimer.start()

        # initialize the automatic log flushing timer
        self.flushtimer = mytimer.MyTimer(
            float(self.settings['Log Maintenance']['Flush Interval']), 0,
            self.FlushLogWriteBuffers,
            ["Flushing file write buffers due to timer"])
        self.flushtimer.start()

        #~ # start the event queue processing
        #~ self.queuetimer = mytimer.MyTimer(1, 1, self.start)
        #~ self.queuetimer.start()

        # initialize some automatic zip stuff
        #self.settings['Zip']['ziparchivename'] = "log_[date].zip"
        if self.settings['Zip']['Zip Enable'] == True:
            self.ziptimer = mytimer.MyTimer(
                float(self.settings['Zip']['Zip Interval']) * 60 * 60, 0,
                self.ZipLogFiles)
            self.ziptimer.start()

        # initialize the log rotation job
        self.logrotatetimer = mytimer.MyTimer(
            float(self.settings['Log Maintenance']['Log Rotation Interval']) *
            60 * 60, 0, self.RotateLogs)
        self.logrotatetimer.start()
Exemple #2
0
 def test_ten_times(self):
     myt = mytimer.MyTimer(0.005, 10, sprint)
     self.assertIsNotNone(myt)
     myt.start()
     self.assertEqual(screen, '')
     time.sleep(0.005 * 11)
     myt.cancel()
     self.assertEqual(screen, 'string' * 10)
Exemple #3
0
 def test_one_time(self):
     myt = mytimer.MyTimer(0.005, 1, sprint)
     self.assertIsNotNone(myt)
     myt.start()
     self.assertEqual(screen, '')
     time.sleep(0.005 * 2)
     myt.cancel()
     self.assertEqual(screen, 'string')
Exemple #4
0
 def test_infinite_times(self):
     myt = mytimer.MyTimer(0.0005, 0, sprint)
     self.assertIsNotNone(myt)
     myt.start()
     self.assertEqual(screen, '')
     time.sleep(1)
     myt.cancel()
     times = screen.count("string")
     self.assertGreaterEqual(times, 10)
Exemple #5
0
            if passFId < FId:
                FId = passFId
            clear_gmsfile.clearfile()
            shiftLeftNum = shiftLeftNum - len(passVertex)
            print(f"Block[{n+1}] pass FId: {passFId}")
            print(f"Block[{n+1}] critical vertex: {passVertex}")
            #input()
            n += 1

        for n in range(self.Nz):
            self.BlockList[n].showBlockData()
        return FId


if __name__ == "__main__":
    clear_gmsfile.clearfile()
    timer = timer.MyTimer()
    cstr_test = AlcoholicCSTR(20)
    cstr_test.setStartDirect(-1)
    cstr_test.setMVnumber(2)
    #cstr_test.getData(vertex=[167,179],startDirect=-1)
    resultFId = cstr_test.solve(3)
    print("  ")
    print("Result FId:", resultFId)
    print("total calculate vertex:", cstr_test.cal_vertex_num)
    print("other possible vertex:")
    for dic in cstr_test.similar_vertex:
        print(dic)
    timer.getTime(kind="process")
    timer.getTime(kind="real")
Exemple #6
0
import time
import picamera
import mytimer
import sys

with picamera.PiCamera() as camera:
    filename = sys.argv[1]
    timer = mytimer.MyTimer()

    camera.resolution = (640, 480)
    camera.framerate = 15
    camera.start_preview()
    time.sleep(2)

    timer.stamp()
    camera.capture(filename, format='jpeg', use_video_port=False)
    timer.stamp("capture")

timer.printStamps()
print "saved to", filename
        #input()

    return current_node.get_state().get_cumulative_choices()


if __name__ == "__main__":
    op_cmd = str(input())
    print(op_cmd)

    if op_cmd == "mcts":
        round_num = 1
        round_num = int(input("plz input MCTS test round:"))

        result_list = []
        for i in range(round_num):
            timer1 = timer.MyTimer()
            MCTS_result = main()
            print("suc")
            t = timer1.getTime(kind='real')
            """solver = problem.DoubleTank(proble_Nz)
            solver.setStartDirect(direct)
            FId = solver.getData(MCTS_result)"""

            result_list.append({
                'time': i,
                'using_time': t,
                'vertex': MCTS_result
            })

        for result in result_list:
            print(result)
Exemple #8
0
import picamera
import picamera.array
import mytimer
import time

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 30
    camera.start_preview()
    time.sleep(2)

    t = mytimer.MyTimer()
    t.stamp()
    i = 0
    with picamera.array.PiRGBArray(camera) as rawCapture:
        t.stamp("open rawCapture")
        for foo in camera.capture_continuous(rawCapture, format='bgr', use_video_port=True):
            t.stamp("%d" % i)
            i += 1
            if (i >= 120): break
            rawCapture.seek(0)

    t.printStamps()

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 30
    camera.start_preview()
    time.sleep(2)

    t = mytimer.MyTimer()