Example #1
0
 def uptime(self):
     try:
         with open("/proc/uptime") as f:
             contents = f.read().split()
     except:
         return "Cannot open uptime file: /proc/uptime"
     return Utils.get_elapsed_time(float(contents[0]))
Example #2
0
 def Update(self, sensors):
     temp_diff = None
     if self.process_info["starttime"]:
         temp_diff = utils.get_elapsed_time(self.process_info["starttime"])
     self.sensor_area.update(sensors)
     self.setting_graph.update(self.setting_graph_time_list,
                               self.setting_graph_temp_list, temp_diff)
Example #3
0
    def showModel(self, start_time=None):

        if start_time:
            time_list = [0]
            self.update_start_time(start_time)  #add
            for i in range(self.setting_area.count()):
                target = self.setting_area.itemAt(i)
                time_list.append(time_list[-1] +
                                 int(target.itemAt(1).widget().text()))
                time_list.append(time_list[-1] +
                                 int(target.itemAt(2).widget().text()))
            # now = utils.make_current()
            # now = utils.change_current_to_seconds(now)
            now = utils.get_elapsed_time(start_time)
            # diff = int(now) - int(start_time)

            # count = self.setting_area.count()
            # for i in range(count):
            #     if time_list[i*2] <= diff:
            #         self.setting_area.itemAt(i).itemAt(0).widget().setEnabled(False)
            #         self.setting_area.itemAt(i).itemAt(1).widget().setEnabled(False)
            #         self.setting_area.itemAt(i).itemAt(2).widget().setEnabled(False)
            #         self.setting_area.itemAt(i).itemAt(3).widget().setEnabled(False)

        else:
            self.process_start_time = None  #add
            target_layout = self.setting_area
            for i in reversed(range(target_layout.count())):
                target_row = target_layout.itemAt(i)
                for j in reversed(range(target_row.count())):
                    target_layout.itemAt(i).itemAt(j).widget().setParent(None)
                target_layout.removeItem(target_row)
            target_layout.addLayout(self.CreateSettingRow())
        return super().exec_()
Example #4
0
    def FurnaceMain(self):
        while True:
            isLast = 'False'
            signal = self.recv_msg(self.sock)

            if signal == 'end signal':
                print('furnace.py 112 line, end signal recv')
                break 

            elif signal == 'fix signal':    
                print('furnace.py 116 line, fix singal recv')
                self.send_msg('fix confirm', self.sock)
                self.ModifyProcess()
   
            touch, temp1, temp2, temp3, temp4, temp5, temp6, flow, press, isLast = self.GetSensorValues()
            current_time = utils.get_elapsed_time(self.start_time)
            send_pkt = packet_sensor(current_time, touch, temp1, temp2, temp3, temp4, temp5, temp6, flow, press, isLast)
            self.send_msg(send_pkt, self.sock)

            if isLast == 'True':    #공정 시간 만료로 인한 마지막 센서값인 경우
                break

            self.current_time = int((datetime.datetime.now() - self.start_time).total_seconds())

            time.sleep(parameter.time_interval)
Example #5
0
 def testDiffBetween2Dates(self):
     dt1 = datetime.datetime.strptime("10-10-2020 17:31:57",
                                      "%m-%d-%Y %H:%M:%S")
     dt2 = datetime.datetime.strptime("10-10-2020 17:34:58",
                                      "%m-%d-%Y %H:%M:%S")
     total_secs = (dt2 - dt1).total_seconds()
     time_diff = "%s" % (Utils.get_elapsed_time(int(total_secs)))
     self.assertEqual("03:01", time_diff)
Example #6
0
    def door_CLOSED(self, door):
        message = ''
        curr_time = Utils.get_time()

        last_open_msg = "%s" % (Utils.get_elapsed_time(
            int(curr_time - door.tslo)))
        self.set_time_since_last_open(door.id)
        door.tslo = self.get_time_since_last_open(door.id)
        door.state = Utils.CLOSED

        ct = curr_time - door.tis.get(Utils.OPENING)
        etime = Utils.get_elapsed_time(int(ct))
        door.tis[door.state] = curr_time

        cur_dt = Utils.epoch_to_datetime(curr_time).strftime(Utils.TIMEFORMAT)
        self.publish_garage_event(door, Utils.CLOSED)

        if door.send_open_im == False:
            message = '%s was %s at %s (%s) away for(%s)' % (
                door.name, door.state, cur_dt, etime, last_open_msg)
        else:
            message = '%s was opened & %s at %s (%s) away for(%s)' % (
                door.name, door.state, cur_dt, etime, last_open_msg)
        return message
Example #7
0
def query_garage_open_close():
    sql = build_sql(["2 Car"], 30, "id", "desc")
    rows = query_db(sql)

    data = ""
    open_time = ""
    time_diff = ""

    for row in reversed(rows):
        time_diff = ""
        if row[3] == "closed" and open_time != "":
            dt1 = datetime.datetime.strptime(open_time, "%Y-%m-%d %H:%M:%S")
            dt2 = datetime.datetime.strptime(row[1], "%Y-%m-%d %H:%M:%S")
            tot_sec = (dt2-dt1).total_seconds()
            time_diff = " (%s)" % (Utils.get_elapsed_time(int(tot_sec)))

        open_time = ""
        if row[3] == "opening":
            open_time = row[1]

        data += "%s %s%s\n" % (str(row[1]), str(row[3]), time_diff)
    return (data)
Example #8
0
    def audio_read(self, slot, num_samples, perform_update=True, timeout=100):
        #   Timeout is in ms
        #   TODO: Make much smarter

        start_time = datetime.now()
        words_received = numpy.sum([
            x.shape[0] for x in self.backend.receive_state_slots[slot][
                DAPlatformBackend.AUD_FIFO_REPORT]
        ])
        samples_received = int(words_received / 2)
        #   print 'Samples previously received = %d' % samples_received

        if perform_update:
            time_float = 0
            while samples_received < num_samples and time_float < 1e-3 * timeout:

                samples_needed = num_samples - samples_received

                #   Now we have to send a command to the device to get it to send us audio
                msg = numpy.array([
                    slot, DAPlatformBackend.AUD_FIFO_READ,
                    samples_needed / 65536, samples_needed % 65536
                ],
                                  dtype=numpy.uint16)
                self.backend.write(msg)
                num_words = samples_needed * 2 + 6
                self.backend.update_receive_state(request_size=num_words,
                                                  timeout=timeout)
                time_float = get_elapsed_time(start_time)
                words_received = numpy.sum([
                    x.shape[0] for x in self.backend.receive_state_slots[slot][
                        DAPlatformBackend.AUD_FIFO_REPORT]
                ])
                samples_received = int(words_received / 2)
                #   print 'Got to %d samples from %d words in %.2f ms' % (samples_received, num_words, (time_float * 1e3))

        return self.get_available_audio(slot, num_samples)
Example #9
0
 def testelapsedTimes(self):
     self.assertEqual('43s', Utils.get_elapsed_time(43))
     self.assertEqual('60s', Utils.get_elapsed_time(60))
     self.assertEqual('01:05', Utils.get_elapsed_time(65))
     self.assertEqual('1 hr', Utils.get_elapsed_time(3600))
     self.assertEqual('1 hr, 16:03', Utils.get_elapsed_time(4563))
     self.assertEqual('1 day', Utils.get_elapsed_time(86400))
     self.assertEqual('1 day, 05s', Utils.get_elapsed_time(86405))
     self.assertEqual('2 days, 7 hrs, 12:00',
                      Utils.get_elapsed_time(198720))
     self.assertEqual('1 wk, 1 day, 1 hr, 04s',
                      Utils.get_elapsed_time(694804))
     self.assertEqual('1 wk, 1 day, 1 hr, 01:01',
                      Utils.get_elapsed_time(694861))
     self.assertEqual('3 wks, 3 days, 19 hrs, 42:40',
                      Utils.get_elapsed_time(2144560))
     self.assertEqual('1 yr, 1 wk, 1 day, 1 hr, 02:40',
                      Utils.get_elapsed_time(32230960))
Example #10
0
                ops=graph.optimizer
            elif(globalV.update_rule=='np'):
                ops=[globalV.squiggles, globalV.updates]

            # if(j%10==0):
            #     globalV.test_acc.append(sess.run(graph.accuracy, feed_dict = {graph.X:x_test, graph.Y:y_test}))
            #     print(globalV.test_acc[-1])
            #     for hl in range(globalV.n_hl+1):
            #         globalV.w_norm[str(hl)].append(sess.run(graph.w_norm[str(hl)]))
            #         globalV.b_sum[str(hl)].append(sess.run(graph.b_sum[str(hl)]))
            

            sess.run(ops, feed_dict = {graph.X:x_train[ind], graph.Y:y_train[ind]})
        
sess.close()   

elapsed_time=get_elapsed_time(time.time()-start)
print('SEED: ', globalV.seed)
print(elapsed_time)

if(globalV.writeFile):
    file_writer(dir_path, elapsed_time, write_norms=True)



# print('\nwidth : ', globalV.hl_size, '\ndepth : ', globalV.n_hl, '\nlearning rate : ', globalV.lr)
# print('\nwidth : ', globalV.hl_size, '\ndepth : ', globalV.n_hl, '\nlearning rate : ', globalV.lr)



Example #11
0
 def uptime(self):
     return utils.get_elapsed_time(self.launch_time)
Example #12
0
 def loop_gif_update(self):
     """ loops the current gif (just sets the frame_num), default behaviour """
     elapsed = utils.get_elapsed_time(start_time, datetime.datetime.now())
     num_frames = self.num_frames[self.gif_num]
     self.frame_num = Gif.get_frame_num(elapsed, self.frame_interval,
                                        num_frames)
Example #13
0
def test_speed(opts):
	t = utils.get_current_time()
	shell.call(opts['test'])
	return utils.get_elapsed_time(t)