def Info(self, dirsource): filename = dirsource.getFilename() sourceDir = dirsource.getCurrentDirectory() #self.SOURCELIST.getCurrentDirectory() mytest = dirsource.canDescent() if dirsource.canDescent(): if dirsource.getSelectionIndex()!=0: if (not sourceDir) and (not filename): return pname else: sourceDir = filename if os_path_isdir(sourceDir): mode = os.stat(sourceDir).st_mode else: return ("") mode = oct(mode) curSelDir = sourceDir dir_stats = os_stat(curSelDir) dir_infos = " " + _("Size") + str(self.Humanizer(dir_stats.st_size))+" " dir_infos = dir_infos + _("Date") + " " + time_strftime("%d.%m.%Y - %H:%M:%S",time_localtime(dir_stats.st_mtime))+" " dir_infos = dir_infos + _("Mode") + " " + str(mode[-3:]) return (dir_infos) else: return ("") else: longname = sourceDir + filename if fileExists(longname): mode = os.stat(longname).st_mode else: return ("") mode = oct(mode) file_stats = os_stat(longname) file_infos = filename + " " + _("Size") + " " + str(self.Humanizer(file_stats.st_size))+" " file_infos = file_infos + _("Date") + " " + time_strftime("%d.%m.%Y - %H:%M:%S",time_localtime(file_stats.st_mtime))+" " file_infos = file_infos + _("Mode") + " " + str(mode[-3:]) return (file_infos)
def showInfo(self): if self["filelist"].canDescent(): if self["filelist"].getSelectionIndex()!=0: curSelDir = self["filelist"].getSelection()[0] dir_stats = os_stat(curSelDir) dir_infos = "size "+str(self.formatSize(dir_stats.st_size))+" " dir_infos = dir_infos+"last-mod "+time_strftime("%d.%m.%Y %H:%M:%S",time_localtime(dir_stats.st_mtime))+" " dir_infos = dir_infos+"mode "+str(dir_stats.st_mode) self.setTitle(_(dir_infos)) else: try: ret = "" out_line = os_popen("uptime").readline() ret = ret + "at" + out_line + "\n" out_lines = [] out_lines = os_popen("cat /proc/meminfo").readlines() for lidx in range(len(out_lines)-1): tstLine = out_lines[lidx].split() if "MemTotal:" in tstLine: ret = ret + out_lines[lidx] elif "MemFree:" in tstLine: ret = ret + out_lines[lidx] + "\n" out_lines = [] out_lines = os_popen("cat /proc/stat").readlines() for lidx in range(len(out_lines)-1): tstLine = out_lines[lidx].split() if "procs_running" in tstLine: ret = ret + _("Running processes: ") + tstLine[1] except: ret = "N/A" msg = self.session.open(MessageBox, _("Dreambox model: " + self.boxtype + "\n\n" + ret), MessageBox.TYPE_INFO, windowTitle=_("Dream-Explorer")) else: curSelFile = self["filelist"].getCurrentDirectory() + self["filelist"].getFilename() file_stats = os_stat(curSelFile) file_infos = "size "+str(self.formatSize(file_stats.st_size))+" " file_infos = file_infos+"last-mod "+time_strftime("%d.%m.%Y %H:%M:%S",time_localtime(file_stats.st_mtime))+" " file_infos = file_infos+"mode "+str(file_stats.st_mode) self.setTitle(_(file_infos)) if curSelFile.endswith(".ts"): serviceref = eServiceReference("1:0:0:0:0:0:0:0:0:0:" + curSelFile) serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(serviceref) evt = info.getEvent(serviceref) if evt: self.session.open(EventViewSimple, evt, ServiceReference(serviceref))
def clickBtn_output(self): now = time_strftime("%Y-%m-%d-%H-%M-%S", time_localtime()) log_file, _ = QFileDialog.getSaveFileName(self, '保存结果文件', '%s.html' % now) if len(log_file.strip()) != 0: with open(log_file, 'w+') as f: f.write(self.output.toHtml()) try: os.system(f'"{confAct.BROWSER_PATH}" {os.path.abspath(log_file)}') except Exception as e: log.warn(f'浏览器打开失败 - Error: {e}')
def mergeExcel_Location(self): now = time_strftime("%Y-%m-%d-%H-%M-%S", time_localtime()) self.excelOutputPath, _ = QFileDialog.getSaveFileName( self, "选择Excel保存路径", '每日健康打卡位置汇总(%s)' % now, "Excel files(*.xlsx , *.xls)") self.excelDir, self.excelName = os_path_split(self.excelOutputPath) if len(self.excelOutputPath.strip()) != 0: self.mergeExcelStart() self.mergeExcel() self.mergeExcelEnd()
def timeformat(source, format): # # Convert the function source input parameter into its relevant couterpart excepted = "failed to convert specified source time into a time structure" if isinstance(source, (int, float)): try: object = time_localtime(source) except Exception as reason: raise Exception(excepted) from reason elif isinstance(source, str): try: object = time_strptime(source, format) except Exception as reason: raise Exception(excepted) from reason # # Determine the Unix epoch time and format the timestamp using time object excepted = "failed to calculate base Unix epoch time using time structure" try: epoch = round(time_mktime(object), 3) except Exception as reason: raise Exception(excepted) from reason excepted = "failed to construct the timestamp string using time structure" try: timestamp = time_strftime(format, object) except Exception as reason: raise Exception(excepted) from reason # # Returns Unix epoch and timestamp string for the provided input parameter return (epoch, timestamp)
tracked_dir = opt.results_dir # define inputs path videoPath = opt.source # define type of file to save - images or videos dataset_mode = opt.save_type # crop images i_should_crop_images = opt.crop_images crop_dir = opt.crop_directory # Extract video type video_format = videoPath[-3:] ## warnings.filterwarnings('ignore') # to disable warnings # Date and time of starting point starting_time = time_strftime("%H-%M-%S - %d.%m.%Y") # Check if input is correct. # TODO - This part needs to support streaming. if (not is_video_file(videoPath)) and (not is_video_stream(videoPath)): raise Exception( "Using a wrong input format '{video_format}'. Please use 'AVI', 'MP4' for video files,\n or 'RTSP', 'HTTP', 'RTMP' for video streams!" .format(video_format=videoPath[-3:])) # Initialize some important directory variables video_dir, video_name = os.path.split(videoPath) dirs = Dirs(video_name, tracked_dir, starting_time, trackerType) # Initialize VideoCapture object cam = cv2.VideoCapture(videoPath) # Initialize VideoWriter
('p',' Locale’s equivalent of either AM or PM. (1)'), ('S',' Second as a decimal number [00,61]. (2)'), ('U',' Week number of the year (Sunday as the first day of the week)'), ('w',' Weekday as a decimal number [0(Sunday),6].'), ('W',' Week number of the year (Monday as the first day of the week)'), ('x',' Locale’s appropriate date representation.'), ('X',' Locale’s appropriate time representation.'), ('y',' Year without century as a decimal number [00,99].'), ('Y',' Year with century as a decimal number.'), ('Z',' Time zone name (no characters if no time zone exists).') ] from time import strftime as time_strftime print "Pat. | native | ours | description" print "----------------------------------------------" for pat, descr in test_exs: nat = time_strftime('%' + pat) ours = strftime('%' + pat) print "%%%s %s | %10s | %10s | %s" % \ ( pat,(nat == ours) and 'OK ' or 'FAIL' ,nat, ours , descr) for yr in range(2000,2015): for mo in (1,2,6,8,11): for dy in range(1,24): tim = strptime('%04d-%02d-%02d' % (yr, mo, dy), '%Y-%m-%d', lang='C')[0] nat = time_strftime('%W', tim) ours = strftime('%W', tim) if nat != ours: print "Nat/ours %d/%d/%d:" % (yr, mo,dy), nat, ours
def log(*args): print('SPD>', time_strftime('%Y-%m-%d %H:%M:%S:'), *args)
def formatTime(t): # commented out #return time.strftime(config.usage.date.daylong.value + " " + config.usage.time.long.value, time.localtime(t)) return time_strftime("%d.%m.%Y - %H:%M:%S", time_localtime(t))
('S', ' Second as a decimal number [00,61]. (2)'), ('U', ' Week number of the year (Sunday as the first day of the week)'), ('w', ' Weekday as a decimal number [0(Sunday),6].'), ('W', ' Week number of the year (Monday as the first day of the week)'), ('x', ' Locale’s appropriate date representation.'), ('X', ' Locale’s appropriate time representation.'), ('y', ' Year without century as a decimal number [00,99].'), ('Y', ' Year with century as a decimal number.'), ('Z', ' Time zone name (no characters if no time zone exists).') ] from time import strftime as time_strftime print "Pat. | native | ours | description" print "----------------------------------------------" for pat, descr in test_exs: nat = time_strftime('%' + pat) ours = strftime('%' + pat) print "%%%s %s | %10s | %10s | %s" % \ ( pat,(nat == ours) and 'OK ' or 'FAIL' ,nat, ours , descr) for yr in range(2000, 2015): for mo in (1, 2, 6, 8, 11): for dy in range(1, 24): tim = strptime('%04d-%02d-%02d' % (yr, mo, dy), '%Y-%m-%d', lang='C')[0] nat = time_strftime('%W', tim) ours = strftime('%W', tim) if nat != ours: print "Nat/ours %d/%d/%d:" % (yr, mo, dy), nat, ours
def logger(message): date = time_strftime("[%Y-%m-%d %H:%M:%S]:", time_localtime()) with open("./img-dl-threads/log.txt", "a+", encoding="utf-8") as f: f.write(date + message + "\n")