def send_stats(message): """Estatisticas do cadastro por estado""" if protecao_apenas_privado(message, "stats"): return stats = db.get_stats() mensagem = STAT_CAB for estado in stats[0]: mensagem += STAT_ESTADO.format(estado) mensagem += STAT_ROD.format(stats[1]) bot_responda(message, mensagem)
def send_stats(message): """Estatisticas do cadastro por estadp""" if protecao_spam_do_grupo(message, "stats"): return stats = db.get_stats() mensagem = STAT_CAB for estado in stats[0]: mensagem += STAT_ESTADO.format(estado) mensagem += STAT_ROD.format(stats[1]) bot_responda(message, mensagem, parse_mode="Markdown")
'Enter 1 for merch, 2 for shows, 3 for sales, 4 to view statistics, or 5 to quit:\n' ) if check_int(table_choice): if 5 >= int(table_choice) >= 1: # Next ask what we should do with the table: view it, add to it, delete from it, or edit it # (and check validity of user entry again) if user chose a table to work with if table_choice == '1' or table_choice == '2' or table_choice == '3': action_choice = input( 'What action would you like to perform? Enter 1 to view all entries, ' '2 to add an entry, or 3 to search for an entry:\n') # Print statistics (must ignore a warning given which alerts that slight rounding errors may occur) elif table_choice == '4': with warnings.catch_warnings(): warnings.simplefilter("ignore", category=exc.SAWarning) print(db.get_stats()) # Set action choice to invalid number so user is rerouted back to main options action_choice = '6' # Quit program elif table_choice == '5': print("Goodbye!") break if check_int(action_choice): if 3 >= int(action_choice) >= 1: # View block if action_choice == '1': if table_choice == '1':
def get_stats(): if request.method == 'POST': return jsonify(db.get_stats()) return redirect(url_for('index'))
def stats(): stats = db.get_stats() return json_response(stats)
# Initialize DB db.init_sqlite(c) # Step 2: Attempt to load a list of unscanned webpages or start with the "Philosophy" page print('Checking for unscanned webpages') unscanned = db.get_unscanned_pages(conn) if unscanned: print('Adding unscanned pages to processing queue') # Add unscanned pages to processing queue (useful if resuming scan from a previous run) for href in unscanned: fetch_q.put(href) # Update stats stats = db.get_stats(conn) else: db.add_page(c, './Philosophy', 'Philosophy') conn.commit() fetch_q.put('./Philosophy') # step 3: Initialize worker threads # Initialize fetch threads print('Kicking off fetch threads') fetch_threads = [] for i in range(num_fetch_threads): _startFetchWorker(fetch_threads, fetch_q, db_q, killer) # Initialize db threads