Refactor code to remove alerts as per lgtm and #1176.

This commit is contained in:
Griatch 2017-01-29 19:02:00 +01:00
parent dcde526f6d
commit 74eebfed6d
54 changed files with 226 additions and 264 deletions

View file

@ -161,13 +161,13 @@ ERROR_SETTINGS = \
1) You are not running this command from your game directory.
Change directory to your game directory and try again (or
create a new game directory using evennia --init <dirname>)
2) The settings file contains a syntax error. If you see a
2) The ettings file contains a syntax error. If you see a
traceback above, review it, resolve the problem and try again.
3) Django is not correctly installed. This usually shows as
errors mentioning 'DJANGO_SETTINGS_MODULE'. If you run a
virtual machine, it might be worth to restart it to see if
this resolves the issue.
""".format(settingsfile=SETTINGFILE, settingspath=SETTINGS_PATH)
""".format(settingspath=SETTINGS_PATH)
ERROR_INITSETTINGS = \
"""
@ -402,7 +402,6 @@ def evennia_version():
"""
version = "Unknown"
try:
import evennia
version = evennia.__version__
except ImportError:
# even if evennia is not found, we should not crash here.
@ -594,7 +593,6 @@ def check_database():
tables = [tableinfo.name for tableinfo in tables]
if tables and u'players_playerdb' in tables:
# database exists and seems set up. Initialize evennia.
import evennia
evennia._init()
# Try to get Player#1
from evennia.players.models import PlayerDB
@ -668,6 +666,7 @@ def get_pid(pidfile):
with open(pidfile, 'r') as f:
pid = f.read()
return pid
return None
def del_pid(pidfile):
@ -684,7 +683,7 @@ def del_pid(pidfile):
os.remove(pidfile)
def kill(pidfile, signal=SIG, succmsg="", errmsg="",
def kill(pidfile, killsignal=SIG, succmsg="", errmsg="",
restart_file=SERVER_RESTART, restart=False):
"""
Send a kill signal to a process based on PID. A customized
@ -693,7 +692,7 @@ def kill(pidfile, signal=SIG, succmsg="", errmsg="",
Args:
pidfile (str): The path of the pidfile to get the PID from.
signal (int, optional): Signal identifier.
killsignal (int, optional): Signal identifier for signal to send.
succmsg (str, optional): Message to log on success.
errmsg (str, optional): Message to log on failure.
restart_file (str, optional): Restart file location.
@ -728,7 +727,7 @@ def kill(pidfile, signal=SIG, succmsg="", errmsg="",
else:
# Linux can send the SIGINT signal directly
# to the specified PID.
os.kill(int(pid), signal)
os.kill(int(pid), killsignal)
except OSError:
print("Process %(pid)s cannot be stopped. "\
@ -751,10 +750,8 @@ def show_version_info(about=False):
version_info (str): A complete version info string.
"""
import os
import sys
import twisted
import django
return VERSION_INFO.format(
version=EVENNIA_VERSION, about=ABOUT_INFO if about else "",