当前位置: 首页>>代码示例>>Python>>正文


Python ascii_graph.Pyasciigraph类代码示例

本文整理汇总了Python中ascii_graph.Pyasciigraph的典型用法代码示例。如果您正苦于以下问题:Python Pyasciigraph类的具体用法?Python Pyasciigraph怎么用?Python Pyasciigraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Pyasciigraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: output

    def output(self, args, begin_ns, end_ns, final=0):
        count = 0
        limit = args.top
        graph = Pyasciigraph()
        values = []
        print('%s to %s' % (ns_to_asctime(begin_ns), ns_to_asctime(end_ns)))
        for tid in sorted(self.state.tids.values(),
                          key=operator.attrgetter('allocated_pages'),
                          reverse=True):
            values.append(("%s (%d)" % (tid.comm, tid.tid),
                          tid.allocated_pages))
            count = count + 1
            if limit > 0 and count >= limit:
                break
        for line in graph.graph("Per-TID Memory Allocations", values,
                                unit=" pages"):
            print(line)

        values = []
        count = 0
        for tid in sorted(self.state.tids.values(),
                          key=operator.attrgetter('freed_pages'),
                          reverse=True):
            values.append(("%s (%d)" % (tid.comm, tid.tid), tid.freed_pages))
            count = count + 1
            if limit > 0 and count >= limit:
                break
        for line in graph.graph("Per-TID Memory Deallocation", values,
                                unit=" pages"):
            print(line)
        print("\nTotal memory usage:\n- %d pages allocated\n- %d pages freed" %
              (self.state.mm["allocated_pages"], self.state.mm["freed_pages"]))
开发者ID:greenscientist,项目名称:lttng-analyses,代码行数:32,代码来源:memtop.py

示例2: output

    def output(self, args, begin_ns, end_ns, final=0):
        count = 0
        limit = args.top
        total_ns = end_ns - begin_ns
        graph = Pyasciigraph()
        values = []
        print('%s to %s' % (ns_to_asctime(begin_ns), ns_to_asctime(end_ns)))
        for tid in sorted(self.state.tids.values(),
                          key=operator.attrgetter('cpu_ns'), reverse=True):
            if len(args.proc_list) > 0 and tid.comm not in args.proc_list:
                continue
            pc = float("%0.02f" % ((tid.cpu_ns * 100) / total_ns))
            if tid.migrate_count > 0:
                migrations = ", %d migrations" % (tid.migrate_count)
            else:
                migrations = ""
            values.append(("%s (%d)%s" % (tid.comm, tid.tid, migrations), pc))
            count = count + 1
            if limit > 0 and count >= limit:
                break
        for line in graph.graph("Per-TID CPU Usage", values, unit=" %"):
            print(line)

        values = []
        total_cpu_pc = 0
        for cpu in sorted(self.state.cpus.values(),
                          key=operator.attrgetter('cpu_ns'), reverse=True):
            cpu_pc = float("%0.02f" % cpu.cpu_pc)
            total_cpu_pc += cpu_pc
            values.append(("CPU %d" % cpu.cpu_id, cpu_pc))
        for line in graph.graph("Per-CPU Usage", values, unit=" %"):
            print(line)
        print("\nTotal CPU Usage: %0.02f%%\n" %
              (total_cpu_pc / len(self.state.cpus.keys())))
开发者ID:greenscientist,项目名称:lttng-analyses,代码行数:34,代码来源:cputop.py

示例3: output

    def output(self, args, begin_ns, end_ns, final=0):
        count = 0
        limit = args.top
        total_ns = end_ns - begin_ns
        graph = Pyasciigraph()
        values = []
        print('%s to %s' % (ns_to_asctime(begin_ns), ns_to_asctime(end_ns)))
        for tid in sorted(self.tids.values(),
                key=operator.attrgetter('cpu_ns'), reverse=True):
            if len(args.proc_list) > 0 and tid.comm not in args.proc_list:
                continue
            pc = float("%0.02f" % ((tid.cpu_ns * 100) / total_ns))
            values.append(("%s (%d)" % (tid.comm, tid.tid), pc))
            count = count + 1
            if limit > 0 and count >= limit:
                break
        for line in  graph.graph("Per-TID CPU Usage", values):
            print(line)

        values = []
        nb_cpu = len(self.cpus.keys())
        for cpu in sorted(self.cpus.values(),
                key=operator.attrgetter('cpu_ns'), reverse=True):
            cpu_total_ns = cpu.cpu_ns
            cpu_pc = float("%0.02f" % cpu.cpu_pc)
            values.append(("CPU %d" % cpu.cpu_id, cpu_pc))
        for line in  graph.graph("Per-CPU Usage", values):
            print(line)
开发者ID:mehran-47,项目名称:lttngAnalysesForOpenSAF,代码行数:28,代码来源:cputop.py

示例4: twitterstat

def twitterstat(account, tweetid):
	
	d = webdriver.Remote(command_executor="http://127.6.138.129:15002", desired_capabilities=webdriver.DesiredCapabilities.PHANTOMJS)
	L = "https://twitter.com/"+account+"/status/"+tweetid
	d.get(L)

	soup = BeautifulSoup(d.page_source)
	try:
		tweet = soup.find('p', {'class':'TweetTextSize TweetTextSize--26px js-tweet-text tweet-text'}).text
		retweets = soup.find('ul', {'class':'stats'}).find('li', {'class':'js-stat-count js-stat-retweets stat-count'}).find('a').find('strong').text
		likes = soup.find('ul', {'class':'stats'}).find('li', {'class':'js-stat-count js-stat-favorites stat-count'}).find('a').find('strong').text
		if "," in retweets:
			retweets = retweets.replace(',', '')
		if "," in likes:
			likes = likes.replace(',', '')
		chart = [('retweets', int(retweets)), ('likes', int(likes))]
		gr = Pyasciigraph()
		show = gr.graph(tweet,chart)
		return "\033[1;31m%s\n\033[1;34m%s\n%s\033[m\n" %(show[0], show[2], show[3])
	except:
		try:
			tweet = soup.find('p', {'class':'TweetTextSize TweetTextSize--26px js-tweet-text tweet-text'}).text
			return "\033[1;31m%s\033[m\n" %tweet
		except:
			return "\033[1;31mCould not find tweet\033[m\n"
开发者ID:Logic-gate,项目名称:datasig,代码行数:25,代码来源:__init__.py

示例5: getPorts

def getPorts():
  print "Distinct ports attacked: " + executeQuery("db.session.distinct('destination_port').length")

  if verbose or veryVerbose:
    portList = executeQuery("db.session.aggregate({\$group:{_id:'\$destination_port','count':{\$sum:1}}},{\$sort:{count:-1}}).forEach(function(x){printjson(x)})").split('\n')
    for pair in portList:
      match = re.search(r'"_id" : (\d+), "count" : (\d+) }',pair)
      if match:
        countByPort[match.group(1)] = int(match.group(2))
    print figlet_format('Ports', font='small')
    graph = Pyasciigraph()
    for line in  graph.graph('', sorted(countByPort.items(), key=operator.itemgetter(1), reverse=True)):
      print(line)
    print
  else:
    portList = executeQuery("db.session.aggregate({\$group:{_id:'\$destination_port','count':{\$sum:1}}},{\$sort:{count:-1}},{\$limit:10}).forEach(function(x){printjson(x)})").split('\n')
    for pair in portList:
      match = re.search(r'"_id" : (\d+), "count" : (\d+) }',pair)
      if match:
        countByPort[match.group(1)] = int(match.group(2))
    print figlet_format('Ports ( Top 10 )', font='small')
    graph = Pyasciigraph()
    for line in  graph.graph('', sorted(countByPort.items(), key=operator.itemgetter(1), reverse=True)):
      print(line)
    print
开发者ID:haylesr,项目名称:mhn-scripts,代码行数:25,代码来源:stats.py

示例6: output_file_read

 def output_file_read(self, args):
     count = 0
     limit = args.top
     graph = Pyasciigraph()
     values = []
     files = {}
     for tid in self.tids.values():
         for fd in tid.fds.values():
             if not fd.filename in files.keys():
                 files[fd.filename] = {}
                 files[fd.filename]["read"] = fd.read
                 files[fd.filename]["write"] = fd.write
                 if fd.filename.startswith("pipe") or \
                         fd.filename.startswith("socket") or \
                         fd.filename.startswith("anon_inode"):
                     files[fd.filename]["name"] = "%s (%s)" % (fd.filename, tid.comm)
                 else:
                     files[fd.filename]["name"] = fd.filename
                 files[fd.filename]["other"] = "(%d %d)" % (fd.fd, tid.tid)
             else:
                 files[fd.filename]["read"] += fd.read
                 files[fd.filename]["write"] += fd.write
     for f in files.values():
         if f["read"] == 0:
             continue
         values.append(("%s %s %s" % (f["name"],
             convert_size(f["read"]), f["other"]), f["read"]))
         count = count + 1
         if limit > 0 and count >= limit:
             break
     for line in graph.graph('Files Read', values, sort=2):
         print(line)
开发者ID:mehran-47,项目名称:lttngAnalysesForOpenSAF,代码行数:32,代码来源:proc-info.py

示例7: plot_testsuite_time

def plot_testsuite_time(json_data, top_k=TOP_K, ascii_graph=False, report_file=None):
	suite_time = {}
	
	overall_time = 0.0
	for suite in json_data:
		name = suite['testsuite']['@name'].rsplit(".",1)[-1]
		time = float(suite['testsuite']['@time'].replace(',',''))
		overall_time += time
		if name in suite_time:
			total_time = suite_time[name]
			suite_time[name] = total_time + time
		else:
			suite_time[name] = time

	d_descending = OrderedDict(sorted(suite_time.items(), 
                                  key=lambda kv: kv[1], reverse=True))

	gdata = []
	for k,v in take(d_descending.iteritems(), top_k):
		gdata.append((k, v))

	print '\nTop ' + str(top_k) + ' testsuite in terms of execution time (in seconds).. [Total time: ' + str(overall_time) + ' seconds]'
	if ascii_graph:
		graph = Pyasciigraph()
		for line in  graph.graph('', gdata):
			print line
	else:
		for line in gdata:
			print line[0] + "\t" + str(line[1])

		if report_file != None:
			with open(report_file, "w") as f:
				f.write('Top ' + str(top_k) + ' testsuite in terms of execution time (in seconds).. [Total time: ' + str(overall_time) + ' seconds]\n')
				for line in gdata:
					f.write(line[0] + "\t" + str(line[1]) + "\n")
开发者ID:LifengWang,项目名称:hive,代码行数:35,代码来源:gen-report.py

示例8: getPasswords

def getPasswords():
  print "Unique passwords: " + executeQuery("db.session.distinct('auth_attempts.password').length")

  if verbose or veryVerbose:
    passwordList = executeQuery("db.session.aggregate([{\$unwind:'\$auth_attempts'},{\$group:{_id:'\$auth_attempts.password','count':{\$sum:1}}},{\$sort:{count:-1}}]).forEach(function(x){printjson(x)})").split('\n')
    for pair in passwordList:
      match = re.search(r'"_id" : "(.*)", "count" : (\d+) }',pair)
      if match:
        countByPassword[match.group(1)] = int(match.group(2))
    print figlet_format('Passwords', font='small')
    graph = Pyasciigraph()
    for line in  graph.graph('', sorted(countByPassword.items(), key=operator.itemgetter(1), reverse=True)):
      print(line)
    print
  else:
    passwordList = executeQuery("db.session.aggregate([{\$unwind:'\$auth_attempts'},{\$group:{_id:'\$auth_attempts.password','count':{\$sum:1}}},{\$sort:{count:-1}},{\$limit:10}]).forEach(function(x){printjson(x)})").split('\n')
    for pair in passwordList:
      match = re.search(r'"_id" : "(.*)", "count" : (\d+) }',pair)
      if match:
        countByPassword[match.group(1)] = int(match.group(2))
    print figlet_format('Passwords ( Top 10 )', font='small')
    graph = Pyasciigraph()
    for line in  graph.graph('', sorted(countByPassword.items(), key=operator.itemgetter(1), reverse=True)):
      print(line)
    print
开发者ID:haylesr,项目名称:mhn-scripts,代码行数:25,代码来源:stats.py

示例9: print_distribution_graph

def print_distribution_graph(data, title):
    y = np.bincount(data)
    ii = np.nonzero(y)[0]
    dist = [(str(x[0]), x[1]) for x in zip(ii,y[ii])]
    graph = Pyasciigraph(human_readable='si')
    for line in graph.graph(title, dist):
        print line
    print ""
开发者ID:danielktaylor,项目名称:PyStrategies,代码行数:8,代码来源:utils.py

示例10: output_latencies

 def output_latencies(self, args):
     graph = Pyasciigraph()
     for proc in self.latency_hist.keys():
         values = []
         for v in self.latency_hist[proc]:
             values.append(("%s" % (v[0]), v[1]))
         for line in graph.graph('%s requests latency (ms)' % proc, values,
                                 unit=" ms"):
             print(line)
开发者ID:greenscientist,项目名称:lttng-analyses,代码行数:9,代码来源:iotop.py

示例11: validate

def validate(pred, min_period, max_period):
    graph = Pyasciigraph()

    num_count = 0
    hit_count = 0
    spend_count = 0
    earned_count = 0
    earned_cash = 0
    earned_set = list()
    graph_data = defaultdict(int)

    for target_period in xrange(min_period, max_period + 1):
        dataset_begin = min_period
        dataset_end = target_period - 1

        if dataset_begin > dataset_end:
            continue

        result = p.predict(target_period=target_period, dataset_begin=dataset_begin, dataset_end=dataset_end)

        actual_numbers = set(all_data[target_period]['numbers'])
        predicted_numbers = set(result['numbers'])
        hit_numbers = actual_numbers & predicted_numbers

        m_count = len(predicted_numbers)
        h_count = len(hit_numbers)
        num_count += m_count
        hit_count += h_count

        if m_count > 0 and m_count <= 10:
            spend_count += 1
            if (h_count, m_count) in reward_table:
                earned_count += 1
                earned_cash += reward_table[(h_count, m_count)]
                earned_set.append((h_count, m_count))
                hour = '%s:00' % all_data[target_period]['time'].split(':')[0]
                graph_data[hour] += 1

    print 'predictor: %s' % p.get_name()

    for line in graph.graph('', graph_data.items(), sort=2):
        print line.encode('UTF-8')

    if num_count == 0:
        print 'hit rate: N/A'
    else:
        print 'hit rate: %.6f  (%d / %d)' % ((float(hit_count) / num_count), hit_count, num_count)

    if spend_count == 0:
        print 'C/P: N/A'
    else:
        print 'C/P: %.6f  (%d / %d)' % ((float(earned_count) / spend_count), earned_count, spend_count)
        print 'earned set: %s' % earned_set
        print 'spend: %d NTD' % (spend_count * 25)
        print 'earned cash: %d NTD' % earned_cash
    print
开发者ID:penvirus,项目名称:bingo2,代码行数:56,代码来源:predictor_validator.py

示例12: output_net_sent_bytes

 def output_net_sent_bytes(self, args):
     count = 0
     graph = Pyasciigraph()
     values = []
     for iface in sorted(self.ifaces.values(),
             key=operator.attrgetter('send_bytes'), reverse=True):
         values.append(("%s %s" % (convert_size(iface.send_bytes), iface.name),
             iface.send_bytes))
     for line in graph.graph('Network sent_bytes', values):
         print(line)
开发者ID:mehran-47,项目名称:lttngAnalysesForOpenSAF,代码行数:10,代码来源:proc-info.py

示例13: iotop_output_nr_sector

 def iotop_output_nr_sector(self, args):
     graph = Pyasciigraph()
     values = []
     for disk in sorted(self.state.disks.values(),
                        key=operator.attrgetter('nr_sector'), reverse=True):
         if disk.nr_sector == 0:
             continue
         values.append((disk.prettyname, disk.nr_sector))
     for line in graph.graph('Disk nr_sector', values, unit=" sectors"):
         print(line)
开发者ID:greenscientist,项目名称:lttng-analyses,代码行数:10,代码来源:iotop.py

示例14: test_type_output

 def test_type_output(self):
     test = [('long_labe☭', 423), ('sl', 1234), ('line3', 531), ('line4', 200), ('line5', 834)]
     graph = Pyasciigraph()
     res = graph.graph('test print', test)
     if sys.version < '3':
         expected = unicode
     else:
         expected = str
     for line in res:
         assert type(line) == expected
开发者ID:kakwa,项目名称:py-ascii-graph,代码行数:10,代码来源:test_lib.py

示例15: print_histogram

def print_histogram(data, label=''):
   # Work around a bug in ascii_graph.
   # https://github.com/kakwa/py-ascii-graph/issues/3
   histogram = [(str(key), value) \
                for (key, value) \
                in data]
   graph = Pyasciigraph()
   for line in graph.graph(label, histogram):
      # Encode explicitly to get around this bug:
      # https://github.com/kakwa/py-ascii-graph/issues/4
      print line.encode('utf-8')
开发者ID:pombredanne,项目名称:github-pr-stats,代码行数:11,代码来源:github_pr_stats.py


注:本文中的ascii_graph.Pyasciigraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。