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)
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))
def _isdst(cls, dt_): tt_ = (dt_.year, dt_.month, dt_.day, dt_.hour, dt_.minute, dt_.second, dt_.weekday(), 0, 0) stamp = time_mktime(tt_) tt_ = time_localtime(stamp) return tt_.tm_isdst > 0
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")