This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added all scripts I found on markusproject.org
- Loading branch information
1 parent
9477a0f
commit acb83e8
Showing
4 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/python | ||
|
||
# See documentation at ~/MarkUsBot/MarkUsBot.README | ||
|
||
import getopt | ||
import os | ||
import signal | ||
import sys | ||
|
||
|
||
HOME = os.environ['HOME'] | ||
BOT_DIR = HOME + "/MarkUsBot" | ||
PID_FILE = BOT_DIR + "/pid.MarkUsBot" | ||
RUN_COMMAND = "./eggdrop MarkUsBot.conf" | ||
|
||
|
||
def bot_running(): | ||
"""Returns whether or not the bot is already running""" | ||
return os.path.exists(PID_FILE) | ||
|
||
|
||
def bot_pid(): | ||
"""Returns pid of a running bot. Returns None if | ||
no bot is running.""" | ||
if not bot_running(): | ||
return None | ||
|
||
pid_file_handle = open(PID_FILE) | ||
pid = pid_file_handle.readline().strip() | ||
|
||
assert pid.isdigit() | ||
|
||
return int(pid) | ||
|
||
|
||
def attempt_boot(): | ||
"""Attempts to boot the bot""" | ||
if bot_running(): | ||
#print "MarkUsBot already running." | ||
return | ||
|
||
print "Booting MarkUsBot..." | ||
os.chdir(BOT_DIR) | ||
os.system(RUN_COMMAND) | ||
|
||
|
||
def attempt_kill(): | ||
"""Attempts to kill a running bot""" | ||
if not bot_running(): | ||
print "MarkUsBot is not running." | ||
return | ||
|
||
pid = bot_pid() | ||
print "Attempting to kill the MarkUsBot (PID: %s)" % pid | ||
os.kill(pid, signal.SIGKILL) | ||
os.remove(PID_FILE) | ||
print "MarkUsBot should be shut down now." | ||
|
||
def usage(): | ||
print "usage: ./%s options" % sys.argv[0] | ||
print "OPTIONS:" | ||
print " -h Show this message" | ||
print " -k Kill the bot" | ||
print " -r Restart the bot" | ||
print "Running without arguments will attempt to boot the bot." | ||
|
||
|
||
def main(): | ||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], "hkr", ["help", "kill", "restart"]) | ||
except getopt.GetoptError, err: | ||
print str(err) | ||
usage() | ||
sys.exit(2) | ||
|
||
killing = False | ||
starting = True | ||
|
||
for o, a in opts: | ||
if o == "-h": | ||
usage() | ||
sys.exit() | ||
elif o == "-k": | ||
killing = True | ||
starting = False | ||
elif o == "-r": | ||
killing = True | ||
starting = True | ||
|
||
if killing: | ||
attempt_kill() | ||
if starting: | ||
attempt_boot() | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# set -v | ||
|
||
# set environment | ||
PATH="/bin:/usr/bin:/var/lib/gems/1.8/bin" | ||
#GEM_PATH="/home/markuspr/ruby/gems" | ||
export PATH | ||
|
||
# other config | ||
MARKUS_APP_PATH="/home/markus/rcov" | ||
RCOV_LOG="$MARKUS_APP_PATH/log/generate_coverage.log" | ||
|
||
# cleanup from previous runs | ||
rm -rf $MARKUS_APP_PATH/coverage/* | ||
rm -rf $MARKUS_APP_PATH/log/* | ||
|
||
# change dir to markus app | ||
cd $MARKUS_APP_PATH | ||
svn up | ||
rake db:reset "RAILS_ENV=test" >> /dev/null 2>&1 | ||
sleep 1 | ||
rake db:migrate "RAILS_ENV=test" > /dev/null 2>&1 # run migrations | ||
sleep 1 | ||
# generate coverage for unit and functional tests | ||
rcov --no-html -T -x "/home/markuspr/ruby/.*,rcov.*,lib/.*" --rails -I"lib:test" "/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" `ls test/unit/*.rb` --aggregate $MARKUS_APP_PATH/coverage.data > $RCOV_LOG 2>&1 | ||
rcov -o "$MARKUS_APP_PATH/coverage" -T -x "/home/markuspr/ruby/.*,rcov.*,lib/.*" --rails -I"lib:test" "/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" `ls test/functional/*.rb` --aggregate $MARKUS_APP_PATH/coverage.data > $RCOV_LOG 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters