renamed function from backgrounder to backend

This commit is contained in:
neersighted 2012-02-29 11:12:23 -08:00
parent 068f97005d
commit 7d545fd100
2 changed files with 13 additions and 13 deletions

View file

@ -25,7 +25,7 @@ daemoncheck = subprocess.check_output("locate /usr/bin/daemon", shell=True)
daemon = re.match(r'^/usr/bin/daemon$', daemoncheck) daemon = re.match(r'^/usr/bin/daemon$', daemoncheck)
screencheck = subprocess.check_output("locate /usr/bin/screen", shell=True) screencheck = subprocess.check_output("locate /usr/bin/screen", shell=True)
screen = re.match(r'^/usr/bin/screen$', screencheck) screen = re.match(r'^/usr/bin/screen$', screencheck)
backgrounder = config.get("wrapper", {}).get("backgrounder", "daemon") backend = config.get("wrapper", {}).get("backend", "daemon")
try: try:
runningcheck = subprocess.check_output("ps ax|grep cloudbot|"\ runningcheck = subprocess.check_output("ps ax|grep cloudbot|"\
@ -40,7 +40,7 @@ error2 = red + "Could not find bot.py! Are you in the wrong folder? "\
"(" + pwd + ") {ERROR 2}" + nocol "(" + pwd + ") {ERROR 2}" + nocol
error3 = red + "Invalid choice, exiting! {ERROR 3}" + nocol error3 = red + "Invalid choice, exiting! {ERROR 3}" + nocol
error4 = red + "Program killed by user! {ERROR 4}" + nocol error4 = red + "Program killed by user! {ERROR 4}" + nocol
error5 = red + "Invalid backgrounder in config! {ERROR 5}" + nocol error5 = red + "Invalid backend in config! {ERROR 5}" + nocol
error6 = red + "Author error! We be derpin'! {ERROR 6}" + nocol error6 = red + "Author error! We be derpin'! {ERROR 6}" + nocol
start = "echo " + error1 start = "echo " + error1
@ -49,13 +49,13 @@ restart = "echo " + error1
pid = "echo 'Cannot get pid'" pid = "echo 'Cannot get pid'"
if daemon: if daemon:
if backgrounder == "daemon": if backend == "daemon":
start = "daemon -n cloudbot -O " + pwd + \ start = "daemon -n cloudbot -O " + pwd + \
"/bot.log -r python " + pwd + "/bot.py" "/bot.log -r python " + pwd + "/bot.py"
stop = clearlog + "daemon -n cloudbot --stop" stop = clearlog + "daemon -n cloudbot --stop"
restart = stop + " && " + start restart = stop + " && " + start
pid = "pidof /usr/bin/daemon" pid = "pidof /usr/bin/daemon"
elif backgrounder == "screen": elif backend == "screen":
start = "screen -S cloudbot -dm python" + pwd +\ start = "screen -S cloudbot -dm python" + pwd +\
"/bot.py >>" + pwd + "/bot.log 2>&1" "/bot.py >>" + pwd + "/bot.log 2>&1"
stop = clearlog + "kill `pidof /usr/bin/screen`" stop = clearlog + "kill `pidof /usr/bin/screen`"
@ -64,13 +64,13 @@ if daemon:
else: else:
print error5 print error5
elif screen: elif screen:
if backgrounder == "daemon": if backend == "daemon":
start = "daemon -n cloudbot -O " + pwd + \ start = "daemon -n cloudbot -O " + pwd + \
"/bot.log -r python " + pwd + "/bot.py" "/bot.log -r python " + pwd + "/bot.py"
stop = clearlog + "daemon -n cloudbot --stop" stop = clearlog + "daemon -n cloudbot --stop"
restart = stop + " && " + start restart = stop + " && " + start
pid = "pidof /usr/bin/daemon" pid = "pidof /usr/bin/daemon"
elif backgrounder == "screen": elif backend == "screen":
start = "screen -S cloudbot -dm python" + pwd +\ start = "screen -S cloudbot -dm python" + pwd +\
"/bot.py >>" + pwd + "/bot.log 2>&1" "/bot.py >>" + pwd + "/bot.log 2>&1"
stop = clearlog + "kill `pidof /usr/bin/screen`" stop = clearlog + "kill `pidof /usr/bin/screen`"
@ -102,10 +102,10 @@ try:
print "Bot is alread running, cannot start!" print "Bot is alread running, cannot start!"
elif (sys.argv[1] == 'stop'): elif (sys.argv[1] == 'stop'):
command = stop command = stop
print "Stopping... (" + backgrounder + ")" print "Stopping... (" + backend + ")"
elif (sys.argv[1] == 'restart'): elif (sys.argv[1] == 'restart'):
command = restart command = restart
print "Restarting... (" + backgrounder + ")" print "Restarting... (" + backend + ")"
elif (sys.argv[1] == 'status'): elif (sys.argv[1] == 'status'):
command = pid command = pid
print green + "Bot is running! " + nocol print green + "Bot is running! " + nocol
@ -119,10 +119,10 @@ try:
print "Bot is alread running, cannot start!" print "Bot is alread running, cannot start!"
elif read == 2: elif read == 2:
command = stop command = stop
print "Stopping... (" + backgrounder + ")" print "Stopping... (" + backend + ")"
elif read == 3: elif read == 3:
command = restart command = restart
print "Restarting... (" + backgrounder + ")" print "Restarting... (" + backend + ")"
elif read == 4: elif read == 4:
command = pid command = pid
print green + "Bot is running! " + nocol print green + "Bot is running! " + nocol
@ -134,7 +134,7 @@ try:
if (len(sys.argv) > 1): if (len(sys.argv) > 1):
if (sys.argv[1] == 'start'): if (sys.argv[1] == 'start'):
command = start command = start
print "Starting... (" + backgrounder + ")" print "Starting... (" + backend + ")"
elif (sys.argv[1] == 'stop'): elif (sys.argv[1] == 'stop'):
print "Bot is not running, cannot stop!" print "Bot is not running, cannot stop!"
elif (sys.argv[1] == 'restart'): elif (sys.argv[1] == 'restart'):
@ -149,7 +149,7 @@ try:
read = int(raw_input('Please choose a option: ')) read = int(raw_input('Please choose a option: '))
if read == 1: if read == 1:
command = start command = start
print "Starting... (" + backgrounder + ")" print "Starting... (" + backend + ")"
elif read == 2: elif read == 2:
print "Bot is not running, cannot stop!" print "Bot is not running, cannot stop!"
elif read == 3: elif read == 3:

View file

@ -43,7 +43,7 @@ if not os.path.exists('config'):
}, },
"wrapper": "wrapper":
{ {
"backgrounder": "screen" "backend": "screen"
}, },
"censored_strings": "censored_strings":
[ [