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


Python utils.color函数代码示例

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


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

示例1: RunSmbFinger

def RunSmbFinger(host):
	try:
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.connect(host)
		s.settimeout(0.7)

		h = SMBHeader(cmd="\x72",flag1="\x18",flag2="\x53\xc8")
		n = SMBNego(data = SMBNegoFingerData())
		n.calculate()
		
		Packet = str(h)+str(n)
		Buffer = struct.pack(">i", len(''.join(Packet)))+Packet
		s.send(Buffer)
		data = s.recv(2048)
		
		if data[8:10] == "\x72\x00":
			Header = SMBHeader(cmd="\x73",flag1="\x18",flag2="\x17\xc8",uid="\x00\x00")
			Body = SMBSessionFingerData()
			Body.calculate()

			Packet = str(Header)+str(Body)
			Buffer = struct.pack(">i", len(''.join(Packet)))+Packet  

			s.send(Buffer) 
			data = s.recv(2048)

		if data[8:10] == "\x73\x16":
			return OsNameClientVersion(data)
	except:
		print color("[!] ", 1, 1) +" Fingerprint failed"
		return None
开发者ID:akpotter,项目名称:Responder,代码行数:31,代码来源:fingerprint.py

示例2: compare_run_times

    def compare_run_times(self):
        print 'checking run times'

        def read_run_times(stype):
            times[stype] = {}
            with open(self.dirs[stype] + '/run-times.csv') as timefile:
                reader = csv.DictReader(timefile)
                for line in reader:
                    times[stype][line['name']] = float(line['seconds'])
        times = {}
        for stype in self.stypes:
            read_run_times(stype)

        for name in times['ref']:
            if args.quick and name not in self.quick_tests:
                continue
            if args.only_ref and '-ref-' not in name:
                continue
            if args.skip_ref and '-ref-' in name:
                continue
            print '  %30s   %7.1f' % (name, times['ref'][name]),
            if name not in times['new']:
                print '  no new time for %s' % utils.color('red', name)
                continue
            fractional_change = (times['new'][name] - times['ref'][name]) / times['ref'][name]
            if abs(fractional_change) > 0.2:
                print '--> %-5.1f %s' % (times['new'][name], utils.color('red', '(%+.3f)' % fractional_change)),
            elif abs(fractional_change) > 0.1:
                print '--> %-5.1f %s' % (times['new'][name], utils.color('yellow', '(%+.3f)' % fractional_change)),
            else:
                print '    ok   ',
            print ''
开发者ID:psathyrella,项目名称:partis,代码行数:32,代码来源:test.py

示例3: compare_performance

    def compare_performance(self):
        # NOTE does *not* regenerate the reference performance file based on the reference outputs  UPDATE hm, wait, do I still use the performance files?
        print "comparing to reference performance"

        refkeys = set(self.perf_info["ref"].keys())
        newkeys = set(self.perf_info["new"].keys())
        if len(refkeys - newkeys) > 0 or len(newkeys - refkeys) > 0:
            print "  %d keys only in ref" % len(refkeys - newkeys)
            print "  %d keys only in new" % len(newkeys - refkeys)
            print "  %d in common" % len(refkeys & newkeys)
            raise Exception("")

        for name in self.perf_info["ref"]:  # don't use the sets above so we get the nice ordering
            ref_val = self.perf_info["ref"][name]
            new_val = self.perf_info["new"][name]
            val_type = name.split("-")[-1]
            print "  %-28s %-15s       %-5.3f" % (name.replace("-" + val_type, ""), val_type, ref_val),
            fractional_change = (new_val - ref_val) / ref_val  # NOTE not the abs value yet
            if abs(fractional_change) > self.eps_vals[val_type]:
                print "--> %-5.3f %s" % (new_val, utils.color("red", "(%+.3f)" % fractional_change)),
            elif abs(fractional_change) > self.tiny_eps:
                print "--> %-5.3f %s" % (new_val, utils.color("yellow", "(%+.3f)" % fractional_change)),
            else:
                print "    ok   ",
            print ""
开发者ID:stevenweaver,项目名称:partis,代码行数:25,代码来源:test.py

示例4: get_indel_info

    def get_indel_info(self, query_name, cigarstr, qrseq, glseq, gene):
        cigars = re.findall('[0-9][0-9]*[A-Z]', cigarstr)  # split cigar string into its parts
        cigars = [(cstr[-1], int(cstr[:-1])) for cstr in cigars]  # split each part into the code and the length

        codestr = ''
        qpos = 0  # position within query sequence
        indelfo = utils.get_empty_indel()  # replacement_seq: query seq with insertions removed and germline bases inserted at the position of deletions
        tmp_indices = []
        for code, length in cigars:
            codestr += length * code
            if code == 'I':  # advance qr seq but not gl seq
                indelfo['indels'].append({'type' : 'insertion', 'pos' : qpos, 'len' : length, 'seqstr' : ''})  # insertion begins at <pos>
                tmp_indices += [len(indelfo['indels']) - 1  for _ in range(length)]# indel index corresponding to this position in the alignment
            elif code == 'D':  # advance qr seq but not gl seq
                indelfo['indels'].append({'type' : 'deletion', 'pos' : qpos, 'len' : length, 'seqstr' : ''})  # first deleted base is <pos> (well, first base which is in the position of the first deleted base)
                tmp_indices += [len(indelfo['indels']) - 1  for _ in range(length)]# indel index corresponding to this position in the alignment
            else:
                tmp_indices += [None  for _ in range(length)]  # indel index corresponding to this position in the alignment
            qpos += length

        qrprintstr, glprintstr = '', ''
        iqr, igl = 0, 0
        for icode in range(len(codestr)):
            code = codestr[icode]
            if code == 'M':
                qrbase = qrseq[iqr]
                if qrbase != glseq[igl]:
                    qrbase = utils.color('red', qrbase)
                qrprintstr += qrbase
                glprintstr += glseq[igl]
                indelfo['reversed_seq'] += qrseq[iqr]  # add the base to the overall sequence with all indels reversed
            elif code == 'S':
                continue
            elif code == 'I':
                qrprintstr += utils.color('light_blue', qrseq[iqr])
                glprintstr += utils.color('light_blue', '*')
                indelfo['indels'][tmp_indices[icode]]['seqstr'] += qrseq[iqr]  # and to the sequence of just this indel
                igl -= 1
            elif code == 'D':
                qrprintstr += utils.color('light_blue', '*')
                glprintstr += utils.color('light_blue', glseq[igl])
                indelfo['reversed_seq'] += glseq[igl]  # add the base to the overall sequence with all indels reversed
                indelfo['indels'][tmp_indices[icode]]['seqstr'] += glseq[igl]  # and to the sequence of just this indel
                iqr -= 1
            else:
                raise Exception('unhandled code %s' % code)

            iqr += 1
            igl += 1

        if self.debug:
            print '\n      indels in %s' % query_name
            print '          %20s %s' % (gene, glprintstr)
            print '          %20s %s' % ('query', qrprintstr)
            for idl in indelfo['indels']:
                print '          %10s: %d bases at %d (%s)' % (idl['type'], idl['len'], idl['pos'], idl['seqstr'])
        # utils.undo_indels(indelfo)
        # print '                       %s' % self.input_info[query_name]['seq']

        return indelfo
开发者ID:apurvaraman,项目名称:partis,代码行数:60,代码来源:waterer.py

示例5: compare_performance

    def compare_performance(self, input_stype):
        performance_metric_list = [n for n in self.perf_info['ref'] if input_stype in n]
        if len(performance_metric_list) == 0:
            return

        print '  performance with %s simulation and parameters' % input_stype

        # make sure there's a new performance value for each reference one, and vice versa
        refkeys = set(self.perf_info['ref'].keys())
        newkeys = set(self.perf_info['new'].keys())
        if len(refkeys - newkeys) > 0 or len(newkeys - refkeys) > 0:
            print '  %d keys only in ref' % len(refkeys - newkeys)
            print '  %d keys only in new' % len(newkeys - refkeys)
            print '  %d in common' % len(refkeys & newkeys)
            raise Exception('')

        for name in performance_metric_list:  # don't use the sets above so we get the nice ordering
            ref_val = self.perf_info['ref'][name]
            new_val = self.perf_info['new'][name]
            val_type = name.split('-')[-1]
            print '    %-28s %-15s       %-5.3f' % (name.replace('-' + val_type, ''), val_type, ref_val),
            fractional_change = (new_val - ref_val) / ref_val  # NOTE not the abs value yet
            if abs(fractional_change) > self.eps_vals[val_type]:
                print '--> %-5.3f %s' % (new_val, utils.color('red', '(%+.3f)' % fractional_change)),
            elif abs(fractional_change) > self.tiny_eps:
                print '--> %-5.3f %s' % (new_val, utils.color('yellow', '(%+.3f)' % fractional_change)),
            else:
                print '    ok   ',
            print ''
开发者ID:Irrationone,项目名称:partis,代码行数:29,代码来源:test.py

示例6: __init__

    def __init__(self, **kwargs):
        self.border_width = kwargs.pop('border_width', 1)
        self.cell_size = kwargs.pop('cell_size', 7)

        self.color_empty = kwargs.pop('color_empty', color(255, 255, 255))
        self.color_filled = kwargs.pop('color_filled', color())
        self.color_border = kwargs.pop('color_border', color(100, 100, 100))

        self.cell_plus_border = self.border_width + self.cell_size
开发者ID:tonyshkurenko,项目名称:Bots,代码行数:9,代码来源:gameoflife_renderer.py

示例7: handle_colors

  def handle_colors(self, world, text):
    """ Prints out all the colors we know about."""
    response = ''
    for background in range(40,48):
      for foreground in range(30,38):
        response += color(str(foreground), foreground, background)
        response += color(str(foreground), foreground, background, 1)
      response += "\33[0m\n"

    self.write(response)
开发者ID:v-legoff,项目名称:accertin,代码行数:10,代码来源:connection.py

示例8: print_key_differences

 def print_key_differences(vtype, refkeys, newkeys):
     print '    %s keys' % vtype
     if len(refkeys - newkeys) > 0 or len(newkeys - refkeys) > 0:
         if len(refkeys - newkeys) > 0:
             print utils.color('red', '      %d only in ref version' % len(refkeys - newkeys))
         if len(newkeys - refkeys) > 0:
             print utils.color('red', '      %d only in new version' % len(newkeys - refkeys))
         print '      %d in common' % len(refkeys & newkeys)
     else:
         print '        %d identical keys in new and ref cache' % len(refkeys)
开发者ID:Irrationone,项目名称:partis,代码行数:10,代码来源:test.py

示例9: compare_data_annotation

 def compare_data_annotation(self, input_stype):
     ptest = 'annotate-' + input_stype + '-data'
     if args.quick and ptest not in self.quick_tests:
         return
     print '  %s data annotation' % input_stype
     infnames = [self.dirs[version_stype] + '/' + ptest + '.csv' for version_stype in self.stypes]
     cmd = 'diff -u ' + ' '.join(infnames) + ' | grep "^+[^+]" | wc -l'
     n_diff_lines = int(check_output(cmd, shell=True))
     if n_diff_lines == 0:
         print '      ok'
     else:
         print utils.color('red', '      %d lines differ' % n_diff_lines),
         print '   (%s)' % cmd
开发者ID:Irrationone,项目名称:partis,代码行数:13,代码来源:test.py

示例10: change_merged

def change_merged(event):
    change = event["change"]

    branch = change["branch"]
    if branch in branch_ignore: return

    owner = username_from_person(change["owner"])

    msg_owner = color(GREEN) + owner + "'s" + color()
    msg_description = describe_patchset(change)

    message = "Applied %s change on %s" % (msg_owner, msg_description)
    emit_message(message)
开发者ID:PeterJCLaw,项目名称:gerritbot,代码行数:13,代码来源:irc_handlers.py

示例11: comment_added

def comment_added(event):
    change = event["change"]

    branch = change["branch"]
    if branch in branch_ignore: return

    author = event["author"]
    author = username_from_person(author)

    msg_author = color(GREEN) + author + color()
    msg_description = describe_patchset(change)

    message = "%s reviewed %s" % (msg_author, msg_description)
    emit_message(message)
开发者ID:PeterJCLaw,项目名称:gerritbot,代码行数:14,代码来源:irc_handlers.py

示例12: compare_production_results

 def compare_production_results(self):
     if args.quick:
         return
     print 'diffing production results'
     for fname in ['test/parameters/data', 'test/simu.csv', 'test/parameters/simu']:
         print '    %-30s' % fname,
         cmd = 'diff -qbr ' + ' '.join(self.dirs[st] + '/' + fname for st in self.stypes)
         proc = Popen(cmd.split(), stdout=PIPE, stderr=PIPE)
         out, err = proc.communicate()
         if proc.returncode == 0:
             print '       ok'
         else:
             differlines = [ l for l in out.split('\n') if 'differ' in l]
             onlylines = [ l for l in out.split('\n') if 'Only' in l]
             print ''
             if len(differlines) > 0:
                 n_total_files = int(check_output('find ' + self.dirs['ref'] + '/' + fname + ' -type f | wc -l', shell=True))
                 if n_total_files == 1:
                     assert len(differlines) == 1
                     print utils.color('red', '      file differs'),
                 else:
                     print utils.color('red', '      %d / %d files differ' % (len(differlines), n_total_files)),
             if len(onlylines) > 0:
                 for st in self.stypes:
                     theseonlylines = [l for l in onlylines if self.dirs[st] + '/' + fname in l]
                     if len(theseonlylines) > 0:
                         print utils.color('red', '      %d files only in %s' % (len(theseonlylines), st)),
             if differlines == 0 and onlylines == 0:
                 print utils.color('red', '      not sure why, but diff returned %d' % proc.returncode),
             print '  (%s)' % cmd
             if err != '':
                 print err
开发者ID:psathyrella,项目名称:partis,代码行数:32,代码来源:test.py

示例13: remove_reference_results

 def remove_reference_results(self, expected_content):
     print '  remove ref files'
     dir_content = set([os.path.basename(f) for f in glob.glob(self.dirs['ref'] + '/*')])
     if len(dir_content - expected_content) > 0 or len(expected_content - dir_content) > 0:
         if len(dir_content - expected_content) > 0:
             print 'in ref dir but not expected\n    %s' % (utils.color('red', ' '.join(dir_content - expected_content)))
         if len(expected_content - dir_content) > 0:
             print 'expected but not in ref dir\n    %s' % (utils.color('red', ' '.join(expected_content - dir_content)))
         raise Exception('unexpected or missing content in reference dir')
     for fname in [self.dirs['ref'] + '/' + ec for ec in expected_content]:
         print '    rm %s' % fname
         if os.path.isdir(fname):
             shutil.rmtree(fname)
         else:
             os.remove(fname)
开发者ID:Irrationone,项目名称:partis,代码行数:15,代码来源:test.py

示例14: compare_data_annotation

 def compare_data_annotation(self, input_stype):
     # NOTE don't really need to do this for simulation, since for simulation we already compare the performance info
     ptest = 'annotate-' + input_stype + '-data'
     if args.quick and ptest not in self.quick_tests:
         return
     print '  %s data annotation' % input_stype
     infnames = [self.dirs[version_stype] + '/' + ptest + '.csv' for version_stype in self.stypes]
     cmd = 'diff -u ' + ' '.join(infnames) + ' | grep "^+[^+]" | wc -l'
     n_diff_lines = int(check_output(cmd, shell=True))
     if n_diff_lines == 0:
         print '      ok'
     else:
         n_total_lines = int(check_output(['wc', '-l', infnames[0]]).split()[0])
         print utils.color('red', '      %d / %d lines differ' % (n_diff_lines, n_total_lines)),
         print '   (%s)' % cmd
开发者ID:psathyrella,项目名称:partis,代码行数:15,代码来源:test.py

示例15: _process

 def _process(self, value):
     """Process a value from theme.json and returns the color code."""
     if self.hex:
         try:
             code = int(value)
         except ValueError:
             pass
         else:
             if code > 15:
                 raise ValueError('Using extended color along with hex')
     # Quick note about extended color codes:
     # 0-7 are standard, binary: 0bBGR with 0% or 68% color
     # 8-15 are somehow standard, binary: 0bBGR with 0% or 100% color
     # 16-231 are RGB with components between 0 and 5 (216 values)
     # 232-255 are B&W colors from black to white (24 values)
     code = utils.color(value)
     if code is None or code > 15:
         if code is None:
             red, green, blue = utils.colorx(value)
         elif code < 232:
             code = code - 16
             red, green, blue = code // 36, (code % 36) // 6, code % 6
             red, green, blue = [x * 1000 // 6 for x in (red, green, blue)]
         else:
             red, green, blue = [(code - 232) * 1000 // 23] * 3
         code = self.add_rgb(red, green, blue)
     return code
开发者ID:TomG777,项目名称:DiscordZ,代码行数:27,代码来源:theme.py


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