Une API permettant à des manifestants d'enregistrer et de s'inscrire à une manifestation dans le but de s'auto-compter.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

73 lines
3.2 KiB

#!/usr/bin/env python3
# -*- coding: utf-8
import os
import configparser
from logger import Logger
from dbclient import ReallyThreadedConnectionPool
from demo.Protester import Protesters
from demo.Protest import Protests
from demo.Subscription import Subscriptions
if __name__ == '__main__':
LOCAL_CONFIG_FILENAME = 'config.local.ini'
if not os.path.exists(LOCAL_CONFIG_FILENAME):
print("\033[91mError: Config file not found: %s\033[0m" % LOCAL_CONFIG_FILENAME)
exit(1)
config = configparser.ConfigParser()
config.read(LOCAL_CONFIG_FILENAME)
llogger = Logger(config['logging']['level'])
try:
tz = config['global']['timezone']
db_host = config['database']['host']
db_port = config['database']['port']
db_name = config['database']['name']
db_user = config['database']['user']
db_password = config['database']['password']
db_min_pool_size = config['database']['min_pool_size']
db_max_pool_size = config['database']['max_pool_size']
api_scheme = config['api']['scheme']
api_host = config['api']['host']
api_port = config['api']['port']
api_base_url = '%s://%s:%s' % (api_scheme, api_host, api_port)
connection_pool = ReallyThreadedConnectionPool(llogger,
tz,
int(db_min_pool_size),
int(db_max_pool_size),
database=db_name,
password=db_password,
host=db_host,
user=db_user)
protesters = Protesters(api_base_url, connection_pool, llogger)
protests = Protests(api_base_url, connection_pool, llogger)
subscriptions = Subscriptions(api_base_url, connection_pool, llogger)
num = 0
while num < 5000:
llogger.info("[+] protesters.add_protester() [%d]" % num)
protesters.add_protester()
#~ llogger.info("[+] protests.add_protest() [%d]" % num)
#~ protests.add_protest()
llogger.info("[+] protesters.get_protester() [%d]" % num)
protesters.get_protester()
llogger.info("[+] protesters.delete_protester() [%d]" % num)
protesters.delete_protester()
llogger.info("[+] protesters.patch_protester() [%d]" % num)
protesters.patch_protester()
llogger.info("[+] protests.get_protest() [%d]" % num)
protests.get_protest()
llogger.info("[+] protests.get_protests() [%d]" % num)
protests.get_protests()
llogger.info("[+] protests.patch_protest() [%d]" % num)
protests.patch_protest()
llogger.info("[+] protests.delete_protest() [%d]" % num)
protests.delete_protest()
llogger.info("[+] subscriptions.add_subscription() [%d]" % num)
subscriptions.add_subscription()
llogger.info("[+] subscriptions.get_subscriptions() [%d]" % num)
subscriptions.get_subscriptions()
llogger.info("[+] subscriptions.delete_subscription() [%d]" % num)
subscriptions.delete_subscription()
num += 1
except Exception as e:
llogger.critical("Error: %s" % str((e.__class__.__name__, e)))
exit(1)