How to use the humanize.intcomma function in humanize

To help you get started, we’ve selected a few humanize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hegusung / WebHashcat / WebHashcat / Utils / hashcat.py View on Github external
else:
            path = os.path.join(os.path.dirname(__file__), "..", "Files", "Wordlistfiles", "*")
            # use md5sum instead of python code for performance issues on a big file
            result = subprocess.run('md5sum %s' % path, shell=True, stdout=subprocess.PIPE).stdout.decode()

            for line in result.split("\n"):
                items = line.split()
                if len(items) == 2:
                    info = {
                        "name": items[1].split("/")[-1],
                        "md5": items[0],
                        "path": items[1],
                    }

                    try:
                        info["lines"] = humanize.intcomma(sum(1 for _ in open(items[1], errors="backslashreplace")))
                    except UnicodeDecodeError:
                        print("Unicode decode error in file %s" % items[1])
                        info["lines"] = "error"
                    res.append(info)


        return sorted(res, key=itemgetter('name'))
github artyshko / smd / GUI / spotify.py View on Github external
def getUserArtistsPrev(self):

            user_top_artists = self.__client.current_user_followed_artists(
                limit=50
            )
            
            artists = []

            for artist in user_top_artists['artists']['items']:

                followers = humanize.intword(artist['followers']['total'])
                followers_comma = humanize.intcomma(artist['followers']['total'])

                if str(followers).isdigit():

                    followers = followers_comma

                try:

                    data = {
                        'spotify':artist['external_urls']['spotify'],
                        'uri':artist['uri'],
                        'id':artist['id'],
                        'name':artist['name'],
                        'image':artist['images'][0]['url'],
                        'popularity':artist['popularity'],
                        'followers':artist['followers']['total'],
                        'followers_display':followers,
github terbo / sigmon / sigmon.py View on Github external
desc = '%s [%s]' % ( clients[client].vendor[:14], conf.fav[client][:8])
    
    desc = clients[client].vendor[:24]
    
    ## add to display
    if conf.fulldisplay == True:
              #mac  ven/desc  frst   last    savg smin sig   prob  ssids
      out += '%-18s (%-26s)   %18s   %18s    %-4s %-4s %-4s  %-6s  %s\n' % (client, desc, \
          dt.datetime.strftime(dt.datetime.fromtimestamp(float(clients[client].firstseen)), '%X %D'),  \
          pp.naturaltime(time.time()-float(clients[client].lastseen)),  \
          avg(clients[client].signal), min(clients[client].signal), ul(clients[client].signal[-1]), \
          pp.intcomma(clients[client].probes), ssids)
    else:
              #mac  ven/desc sig   prob  ssids
      out += '%-18s (%-26s)\t%-4s\t%-6s  %s\n' % (client, desc, \
          ul(clients[client].signal[-1]), pp.intcomma(clients[client].probes), \
          ssids)
   
    if conf.filterdisplay:
      # loud client
      if len(clients[client].ssids) > 4 and maxitems>0 and (conf.viewfilter == '' or re.search('loud',conf.viewfilter)):
        loud += 1
        output['loud'] += out
        maxitems -= 1
      # hasnt been seen in x seconds
      elif float(time.time() - conf.seen_thresh) > float(clients[client].lastseen) and maxitems>0 and \
          (conf.viewfilter == '' or re.search('old',conf.viewfilter)):
        old += 1
        output['old'] += out
        maxitems -= 1
      # near by clients
      elif int(clients[client].signal[-1]) > conf.signal_thresh and maxitems>0 and \
github hegusung / WebHashcat / WebHashcat / Hashcat / views.py View on Github external
def hashfile(request, hashfile_id, error_msg=''):
    context = {}
    context["Section"] = "Hashfile"

    hashfile = get_object_or_404(Hashfile, id=hashfile_id)

    context['hashfile'] = hashfile
    context['lines'] = humanize.intcomma(hashfile.line_count)
    context['recovered'] = "%s (%.2f%%)" % (humanize.intcomma(hashfile.cracked_count), hashfile.cracked_count/hashfile.line_count*100) if hashfile.line_count != 0 else "0"
    context['hash_type'] = "Plaintext" if hashfile.hash_type == -1 else Hashcat.get_hash_types()[hashfile.hash_type]["name"]

    template = loader.get_template('Hashcat/hashfile.html')
    return HttpResponse(template.render(context, request))
github hegusung / WebHashcat / WebHashcat / API / views.py View on Github external
running_session_count = 0
            total_session_count =  Session.objects.filter(hashfile_id=hashfile.id).count()
            for session in Session.objects.filter(hashfile_id=hashfile.id):
                try:
                    if session_status[session.name] == "Running":
                        running_session_count += 1
                except KeyError:
                    pass


            data.append({
                "DT_RowId": "row_%d" % hashfile.id,
                "name": "<a href="%s">%s</a><a>" % (reverse('Hashcat:hashfile', args=(hashfile.id,)), hashfile.name),
                "type": "Plaintext" if hashfile.hash_type == -1 else Hashcat.get_hash_types()[hashfile.hash_type]["name"],
                "line_count": humanize.intcomma(hashfile.line_count),
                "cracked": "%s (%.2f%%)" % (humanize.intcomma(hashfile.cracked_count), hashfile.cracked_count/hashfile.line_count*100) if hashfile.line_count &gt; 0 else "0",
                "username_included": "yes" if hashfile.username_included else "no",
                "sessions_count": "%d / %d" % (running_session_count, total_session_count),
                "buttons": buttons,
            })

    result["data"] = data
    result["recordsTotal"] = Hashfile.objects.all().count()
    result["recordsFiltered"] = Hashfile.objects.filter(name__contains=params["search[value]"]).count()

    for query in connection.queries[-4:]:
        print(query["sql"])
        print(query["time"])

    return HttpResponse(json.dumps(result), content_type="application/json")
</a>
github terbo / sigmon / sigmon.py View on Github external
def show_stats():
  threads = threading.activeCount()
  
  print 'conf.opts: %s ' % list(conf.opts)
   
  print 'Probes: %s' % pp.intcomma(conf.probes)
  print 'Packets: %s' % pp.intcomma(conf.packets)
  print 'Dropped: %s' % pp.intcomma(conf.dropped)
  print 'Signal Threshold: %s' % conf.signal_thresh
  print 'Clients seen: %s' % pp.intcomma(len(conf.c))
  print 'SSIDs seen: %s' % pp.intcomma(len(conf.ssids))
  print 'Vendors seen: %s' % len(conf.vendors)
  print 'Favorites list: %s' % list(conf.fav.items())
  print 'Interface list: %s' % list(conf.interfaces)
  print 'Start time: %s' % conf.uptime
  print 'Threads: %d' % threads
  
  print '\n\nPress q to exit, or choose an option:\n'
  print '[c]lients [a]ccess Points [S]ort [Q]uit [A]dd interface [D]ebug [T]hreads'
  #print '[ g ]  [ s ]  [ h ]  [ c ]  [ a ]  [ v ]  [ D ]  [ d ]  [ q ]'
  #print '                    Clients  APs  Vendors               quit'
  #print 'Graphs Statistics Help                    Debug  daemonize'
  print '\nsigmon %s' % conf.version
  
  waitkey()
github terbo / sigmon / sigmon.py View on Github external
def show_stats():
  threads = threading.activeCount()
  
  print 'conf.opts: %s ' % list(conf.opts)
   
  print 'Probes: %s' % pp.intcomma(conf.probes)
  print 'Packets: %s' % pp.intcomma(conf.packets)
  print 'Dropped: %s' % pp.intcomma(conf.dropped)
  print 'Signal Threshold: %s' % conf.signal_thresh
  print 'Clients seen: %s' % pp.intcomma(len(conf.c))
  print 'SSIDs seen: %s' % pp.intcomma(len(conf.ssids))
  print 'Vendors seen: %s' % len(conf.vendors)
  print 'Favorites list: %s' % list(conf.fav.items())
  print 'Interface list: %s' % list(conf.interfaces)
  print 'Start time: %s' % conf.uptime
  print 'Threads: %d' % threads
  
  print '\n\nPress q to exit, or choose an option:\n'
  print '[c]lients [a]ccess Points [S]ort [Q]uit [A]dd interface [D]ebug [T]hreads'
  #print '[ g ]  [ s ]  [ h ]  [ c ]  [ a ]  [ v ]  [ D ]  [ d ]  [ q ]'
  #print '                    Clients  APs  Vendors               quit'
  #print 'Graphs Statistics Help                    Debug  daemonize'
github terbo / sigmon / app / sigmon.py View on Github external
def commify(num):
  if not num:
    return
  if num &lt; 8000:
    return humanize.intcomma(num)
  
  return humanize.naturalsize(num,gnu=True,format='%.2f')
github newsdev / nyt-pyfec / pyfec / demo / __main__.py View on Github external
if not row:
            break

        try:
            linedict = fp.parse_form_line(row, filing_dict['version'])
            filing_dict['transactions'].append(linedict)

        except form.ParserMissingError:
            msg = 'process_filing_body: Unknown line type in filing %s line %s: type=%s Skipping.' % (filingnum, linenum, row[0])
            print msg
            continue

    payload.append(filing_dict)

    print Style.BRIGHT + Fore.MAGENTA + "Processed records: " + Style.BRIGHT + Fore.YELLOW +  "%s" % humanize.intcomma(len(filing_dict['transactions']))
    print Style.BRIGHT + Fore.YELLOW + filing_dict['formtype']
    print Style.BRIGHT + Fore.YELLOW + filing_dict['version']
    print Style.BRIGHT + Fore.YELLOW + filing_dict['filer_id']

end = datetime.datetime.now()
print Style.BRIGHT + Fore.MAGENTA + "Time to complete: " + Style.BRIGHT + Fore.YELLOW + "%s" % (end - start)