From 11d3ffd0c7e77be82f04dc724c1b91b3f7961636 Mon Sep 17 00:00:00 2001 From: guimoz Date: Thu, 26 Jan 2017 23:42:28 +0100 Subject: [PATCH] Correction des indentations + .gitignore --- .gitignore | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ roulette.py | 24 +++++++------- 2 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a05e2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,91 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +.venv/ +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject diff --git a/roulette.py b/roulette.py index 3a49173..e266de6 100644 --- a/roulette.py +++ b/roulette.py @@ -13,7 +13,7 @@ import random # configuration DEBUG = True -SECRET_KEY = "\xf3'\xd2\xf7\xa4[.h\x8e\x11|\xda\x00\x9fyS\xfe\xb3(!\x91'6\x16" +SECRET_KEY = "\xf3'\xd2\xf7\xa4[.h\x8e\x11|\xda\x00\x9fyS\xfe\xb3(!\x91'6\x16" USERNAME = 'admin' PASSWORD = 'pipo' @@ -27,7 +27,7 @@ MYSQL_DB = 'rezo_admin' BAN_DURATION = 30. * 60. -IMMUNITY_FILE = '/var/www/roulette/immunity' +IMMUNITY_FILE = '/var/www/roulette/immunity' ASSHOLES_FILE = '/var/www/roulette/assholes' IMMUNITY = [ @@ -77,7 +77,7 @@ def init_db(): and typeUtilisateur='membre'""") rows = cur_mysql.fetchall() for row in rows: - if row['prenom'] + ' ' + row['nom'] in IMMUNITY: + if row['prenom'] + ' ' + row['nom'] in IMMUNITY: print(row) cur_sqlite.execute("""insert into players values (?,?,?,?)""", \ ((row["id"]), row["prenom"], row["nom"], 0)) @@ -213,30 +213,30 @@ def get_players_not_banned(): def cheat(player_id, target_id): success = random.choice([True, False]) - try: + try: ok = [line.strip().partition(' ') for line in IMMUNITY] ok = [get_player_from_full_name(names[0], names[2])['id'] for names in ok] ko = [line.strip().partition(' ') for line in ASSHOLES] ko = [get_player_from_full_name(names[0], names[2])['id'] for names in ko] - + if target_id in ko: success = True elif player_id in ko: success = False elif target_id in ok: - success = False + success = False except TypeError: - pass + pass return success - + def ban(player_id, target_id, success): player = get_player(player_id) target = get_player(target_id) - + banned_player = success and target or player con = connect_sqlite() @@ -264,7 +264,7 @@ def unban(player_id): cur.execute("""update players set ban_end=(?) where id=(?)""", [time() - BAN_DURATION, player_id]) - + con.commit() con.close() @@ -299,7 +299,7 @@ def banned(): return render_template('banned.html', \ explanation=explanation, timeleft=timeleft) - + @app.route('/banned_ip') def banned_ip(): @@ -373,7 +373,7 @@ def play(): if is_banned(target_id): flash(u'Utilisateur déjà banni, il faut en choisir un autre.') else: - success = cheat(player['id'], target_id) + success = cheat(player['id'], target_id) if success: target = get_player(target_id) ban(player['id'], target_id, True)