Correction des indentations + .gitignore

This commit is contained in:
guimoz 2017-01-26 23:42:28 +01:00
parent b8664c1af2
commit 11d3ffd0c7
2 changed files with 103 additions and 12 deletions

91
.gitignore vendored Normal file
View file

@ -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

View file

@ -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)