def _timelockClicked(self): title = "The resolve is timelocked" body = str(self.time_lock_tbtn.toolTip()).capitalize() secs = int(time.time()) - self.context().requested_timestamp t_str = readable_time_duration(secs) body += "\n(%s ago)" % t_str QtGui.QMessageBox.information(self, title, body)
def refresh(self): context = self.context() if not context: self.timer.stop() self.setText("") return minutes = (int(time.time()) - context.created) / 60 if minutes: time_txt = readable_time_duration(minutes * 60) else: time_txt = "moments" self.setText("resolved %s ago" % time_txt) self.timer.start()
def _list_processes(self): entries = self.get_processes() now = int(time.time()) items = [] for proc, start_time in entries: age = now - start_time items.append((age, proc.pid)) if items: items = sorted(items) lines = [] for age, pid in items: t_str = readable_time_duration(age) line = "Process #%d has been running for %s" % (pid, t_str) lines.append(line) txt = "\n".join(lines) else: txt = "There are no running processes." QtWidgets.QMessageBox.information(self, "Processes", txt)
def _list_processes(self): entries = self.get_processes() now = int(time.time()) items = [] for proc, start_time in entries: age = now - start_time items.append((age, proc.pid)) if items: items = sorted(items) lines = [] for age, pid in items: t_str = readable_time_duration(age) line = "Process #%d has been running for %s" % (pid, t_str) lines.append(line) txt = "\n".join(lines) else: txt = "There are no running processes." QtGui.QMessageBox.information(self, "Processes", txt)
def _secondsHover(self, seconds): if seconds == -1: self.label.setText("") else: secs_txt = readable_time_duration(seconds) self.label.setText("%s ago" % secs_txt)
def get_timestamp_str(timestamp): now = int(time.time()) release_time = time.localtime(timestamp) release_time_str = time.strftime('%d %b %Y %H:%M:%S', release_time) ago = readable_time_duration(now - timestamp) return "%s (%s ago)" % (release_time_str, ago)
def command(opts, parser, extra_arg_groups=None): from rez.config import config from rez.packages_ import iter_package_families, iter_packages from rez.utils.yaml import dump_yaml from rez.utils.memcached import Client from rez.utils.formatting import columnise, readable_time_duration, \ readable_memory_size import sys memcache_client = Client(servers=config.memcached_uri, debug=config.debug_memcache) if not memcache_client: print("memcaching is not enabled.", file=sys.stderr) sys.exit(1) if opts.poll: poll(memcache_client, opts.interval) return if opts.flush: memcache_client.flush(hard=True) print("memcached servers are flushed.") return if opts.warm: seen = set() paths = config.nonlocal_packages_path for family in iter_package_families(paths=paths): if family.name in seen: continue for package in iter_packages(family.name, paths=paths): if opts.verbose: print("warming: %s" % package.qualified_name) # forces package definition load, which puts in memcache _ = package.data # noqa seen.add(family.name) print("memcached servers are warmed.") return if opts.reset_stats: memcache_client.reset_stats() print("memcached servers are stat reset.") return def _fail(): print("memcached servers are not responding.", file=sys.stderr) sys.exit(1) stats = memcache_client.get_stats() if opts.stats: if stats: txt = dump_yaml(stats) print(txt) else: _fail() return # print stats summary if not stats: _fail() rows = [["CACHE SERVER", "UPTIME", "HITS", "MISSES", "HIT RATIO", "MEMORY", "USED"], ["------------", "------", "----", "------", "---------", "------", "----"]] for server_id, stats_dict in stats: server_uri = server_id.split()[0] uptime = int(stats_dict.get("uptime", 0)) hits = int(stats_dict.get("get_hits", 0)) misses = int(stats_dict.get("get_misses", 0)) memory = int(stats_dict.get("limit_maxbytes", 0)) used = int(stats_dict.get("bytes", 0)) hit_ratio = float(hits) / max(hits + misses, 1) hit_percent = int(hit_ratio * 100.0) used_ratio = float(used) / max(memory, 1) used_percent = int(used_ratio * 100.0) row = (server_uri, readable_time_duration(uptime), str(hits), str(misses), "%d%%" % hit_percent, readable_memory_size(memory), "%s (%d%%)" % (readable_memory_size(used), used_percent)) rows.append(row) print('\n'.join(columnise(rows)))
def command(opts, parser, extra_arg_groups=None): from rez.config import config from rez.utils.yaml import dump_yaml from rez.utils.memcached import Client from rez.utils.formatting import columnise, readable_time_duration, \ readable_memory_size import sys memcache_client = Client(servers=config.memcached_uri, debug=config.debug_memcache) if not memcache_client: print >> sys.stderr, "memcaching is not enabled." sys.exit(1) if opts.poll: poll(memcache_client, opts.interval) return if opts.flush: memcache_client.flush(hard=True) print "memcached servers are flushed." return if opts.reset_stats: memcache_client.reset_stats() print "memcached servers are stat reset." return def _fail(): print >> sys.stderr, "memcached servers are not responding." sys.exit(1) stats = memcache_client.get_stats() if opts.stats: if stats: txt = dump_yaml(stats) print txt else: _fail() return # print stats summary if not stats: _fail() rows = [["CACHE SERVER", "UPTIME", "HITS", "MISSES", "HIT RATIO", "MEMORY", "USED"], ["------------", "------", "----", "------", "---------", "------", "----"]] for server_id, stats_dict in stats: server_uri = server_id.split()[0] uptime = int(stats_dict.get("uptime", 0)) hits = int(stats_dict.get("get_hits", 0)) misses = int(stats_dict.get("get_misses", 0)) memory = int(stats_dict.get("limit_maxbytes", 0)) used = int(stats_dict.get("bytes", 0)) hit_ratio = float(hits) / max(hits + misses, 1) hit_percent = int(hit_ratio * 100.0) used_ratio = float(used) / max(memory, 1) used_percent = int(used_ratio * 100.0) row = (server_uri, readable_time_duration(uptime), str(hits), str(misses), "%d%%" % hit_percent, readable_memory_size(memory), "%s (%d%%)" % (readable_memory_size(used), used_percent)) rows.append(row) print '\n'.join(columnise(rows))
def command(opts, parser, extra_arg_groups=None): from rez.config import config from rez.utils.yaml import dump_yaml from rez.utils.memcached import Client from rez.utils.formatting import columnise, readable_time_duration, \ readable_memory_size import sys memcache_client = Client(servers=config.memcached_uri, debug=config.debug_memcache) if not memcache_client: print >> sys.stderr, "memcaching is not enabled." sys.exit(1) if opts.poll: poll(memcache_client, opts.interval) return if opts.flush: memcache_client.flush(hard=True) print "memcached servers are flushed." return if opts.reset_stats: memcache_client.reset_stats() print "memcached servers are stat reset." return def _fail(): print >> sys.stderr, "memcached servers are not responding." sys.exit(1) stats = memcache_client.get_stats() if opts.stats: if stats: txt = dump_yaml(stats) print txt else: _fail() return # print stats summary if not stats: _fail() rows = [[ "CACHE SERVER", "UPTIME", "HITS", "MISSES", "HIT RATIO", "MEMORY", "USED" ], [ "------------", "------", "----", "------", "---------", "------", "----" ]] for server_id, stats_dict in stats: server_uri = server_id.split()[0] uptime = int(stats_dict.get("uptime", 0)) hits = int(stats_dict.get("get_hits", 0)) misses = int(stats_dict.get("get_misses", 0)) memory = int(stats_dict.get("limit_maxbytes", 0)) used = int(stats_dict.get("bytes", 0)) hit_ratio = float(hits) / max(hits + misses, 1) hit_percent = int(hit_ratio * 100.0) used_ratio = float(used) / max(memory, 1) used_percent = int(used_ratio * 100.0) row = (server_uri, readable_time_duration(uptime), str(hits), str(misses), "%d%%" % hit_percent, readable_memory_size(memory), "%s (%d%%)" % (readable_memory_size(used), used_percent)) rows.append(row) print '\n'.join(columnise(rows))