Elections 2022

Signed-off-by: Emmy D'Anello <ynerant@crans.org>
This commit is contained in:
Emmy D'Anello 2023-02-12 15:09:17 +01:00
commit 23ee6e74ef
15 changed files with 15181 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
__pycache__
*.sqlite3
migrations/versions/*

1237
app.py Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

577
circos Normal file
View File

@ -0,0 +1,577 @@
001-01
001-02
001-03
001-04
001-05
002-01
002-02
002-03
002-04
002-05
003-01
003-02
003-03
004-01
004-02
005-01
005-02
006-01
006-02
006-03
006-04
006-05
006-06
006-07
006-08
006-09
007-01
007-02
007-03
008-01
008-02
008-03
009-01
009-02
010-01
010-02
010-03
011-01
011-02
011-03
012-01
012-02
012-03
013-01
013-02
013-03
013-04
013-05
013-06
013-07
013-08
013-09
013-10
013-11
013-12
013-13
013-14
013-15
013-16
014-01
014-02
014-03
014-04
014-05
014-06
015-01
015-02
016-01
016-02
016-03
017-01
017-02
017-03
017-04
017-05
018-01
018-02
018-03
019-01
019-02
021-01
021-02
021-03
021-04
021-05
022-01
022-02
022-03
022-04
022-05
023-01
024-01
024-02
024-03
024-04
025-01
025-02
025-03
025-04
025-05
026-01
026-02
026-03
026-04
027-01
027-02
027-03
027-04
027-05
028-01
028-02
028-03
028-04
029-01
029-02
029-03
029-04
029-05
029-06
029-07
029-08
030-01
030-02
030-03
030-04
030-05
030-06
031-01
031-02
031-03
031-04
031-05
031-06
031-07
031-08
031-09
031-10
032-01
032-02
033-01
033-02
033-03
033-04
033-05
033-06
033-07
033-08
033-09
033-10
033-11
033-12
034-01
034-02
034-03
034-04
034-05
034-06
034-07
034-08
034-09
035-01
035-02
035-03
035-04
035-05
035-06
035-07
035-08
036-01
036-02
037-01
037-02
037-03
037-04
037-05
038-01
038-02
038-03
038-04
038-05
038-06
038-07
038-08
038-09
038-10
039-01
039-02
039-03
040-01
040-02
040-03
041-01
041-02
041-03
042-01
042-02
042-03
042-04
042-05
042-06
043-01
043-02
044-01
044-02
044-03
044-04
044-05
044-06
044-07
044-08
044-09
044-10
045-01
045-02
045-03
045-04
045-05
045-06
046-01
046-02
047-01
047-02
047-03
048-01
049-01
049-02
049-03
049-04
049-05
049-06
049-07
050-01
050-02
050-03
050-04
051-01
051-02
051-03
051-04
051-05
052-01
052-02
053-01
053-02
053-03
054-01
054-02
054-03
054-04
054-05
054-06
055-01
055-02
056-01
056-02
056-03
056-04
056-05
056-06
057-01
057-02
057-03
057-04
057-05
057-06
057-07
057-08
057-09
058-01
058-02
059-01
059-02
059-03
059-04
059-05
059-06
059-07
059-08
059-09
059-10
059-11
059-12
059-13
059-14
059-15
059-16
059-17
059-18
059-19
059-20
059-21
060-01
060-02
060-03
060-04
060-05
060-06
060-07
061-01
061-02
061-03
062-01
062-02
062-03
062-04
062-05
062-06
062-07
062-08
062-09
062-10
062-11
062-12
063-01
063-02
063-03
063-04
063-05
064-01
064-02
064-03
064-04
064-05
064-06
065-01
065-02
066-01
066-02
066-03
066-04
067-01
067-02
067-03
067-04
067-05
067-06
067-07
067-08
067-09
068-01
068-02
068-03
068-04
068-05
068-06
069-01
069-02
069-03
069-04
069-05
069-06
069-07
069-08
069-09
069-10
069-11
069-12
069-13
069-14
070-01
070-02
071-01
071-02
071-03
071-04
071-05
072-01
072-02
072-03
072-04
072-05
073-01
073-02
073-03
073-04
074-01
074-02
074-03
074-04
074-05
074-06
075-01
075-02
075-03
075-04
075-05
075-06
075-07
075-08
075-09
075-10
075-11
075-12
075-13
075-14
075-15
075-16
075-17
075-18
076-01
076-02
076-03
076-04
076-05
076-06
076-07
076-08
076-09
076-10
077-01
077-02
077-03
077-04
077-05
077-06
077-07
077-08
077-09
077-10
077-11
078-01
078-02
078-03
078-04
078-05
078-06
078-07
078-08
078-09
078-10
078-11
078-12
079-01
079-02
079-03
080-01
080-02
080-03
080-04
080-05
081-01
081-02
081-03
082-01
082-02
083-01
083-02
083-03
083-04
083-05
083-06
083-07
083-08
084-01
084-02
084-03
084-04
084-05
085-01
085-02
085-03
085-04
085-05
086-01
086-02
086-03
086-04
087-01
087-02
087-03
088-01
088-02
088-03
088-04
089-01
089-02
089-03
090-01
090-02
091-01
091-02
091-03
091-04
091-05
091-06
091-07
091-08
091-09
091-10
092-01
092-02
092-03
092-04
092-05
092-06
092-07
092-08
092-09
092-10
092-11
092-12
092-13
093-01
093-02
093-03
093-04
093-05
093-06
093-07
093-08
093-09
093-10
093-11
093-12
094-01
094-02
094-03
094-04
094-05
094-06
094-07
094-08
094-09
094-10
094-11
095-01
095-02
095-03
095-04
095-05
095-06
095-07
095-08
095-09
095-10
097-01
097-02
097-03
097-04
097-05
097-06
097-07
097-08
097-09
097-10
097-11
201-01
201-02
202-01
202-02
971-01
971-02
971-03
971-04
972-01
972-02
972-03
972-04
973-01
973-02
974-01
974-02
974-03
974-04
974-05
974-06
974-07
975-01
976-01
976-02
977-01
986-01
987-01
987-02
987-03
988-01
988-02

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
migrations/README Normal file
View File

@ -0,0 +1 @@
Single-database configuration for Flask.

50
migrations/alembic.ini Normal file
View File

@ -0,0 +1,50 @@
# A generic, single database configuration.
[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic,flask_migrate
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[logger_flask_migrate]
level = INFO
handlers =
qualname = flask_migrate
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

91
migrations/env.py Normal file
View File

@ -0,0 +1,91 @@
from __future__ import with_statement
import logging
from logging.config import fileConfig
from flask import current_app
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env')
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
config.set_main_option(
'sqlalchemy.url',
str(current_app.extensions['migrate'].db.get_engine().url).replace(
'%', '%%'))
target_metadata = current_app.extensions['migrate'].db.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
connectable = current_app.extensions['migrate'].db.get_engine()
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

24
migrations/script.py.mako Normal file
View File

@ -0,0 +1,24 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

40
refresh_all.py Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env python3
from time import sleep, time
import requests
def main():
with open('circos') as f:
circos = f.read().split()
got_results = {}
while True:
for circo in circos:
if circo in got_results:
pass
# continue
resp = requests.get(f'http://localhost/refresh/{circo}')
if resp.status_code != 200:
print(circo)
print(resp.status_code)
continue
data = resp.json()
if data['status'] == 'OK':
# print("Résultats accessibles pour", circo)
got_results[circo] = time()
for circo, t in list(got_results.items()):
if time() - t >= 90:
del got_results[circo]
print("Sleeping...")
sleep(600)
if __name__ == '__main__':
main()

BIN
static/france.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB