Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
adding nicer messages to the request program
Browse files Browse the repository at this point in the history
  • Loading branch information
BuzzTroll committed Sep 3, 2010
1 parent 3e0a105 commit a50cf45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
13 changes: 11 additions & 2 deletions lantorrent/install.sh
@@ -1,8 +1,18 @@
#!/bin/bash

if [ "X$1" == "X-h" ]; then
echo "<install dir> <user to run the service under>"
exit 0
fi
if [ "X$1" == "X" ]; then
echo "please specify a target directory"
exit
exit 1
fi
if [ "X$2" == "X" ]; then
who=`whoami`
exit 1
else
who=$2
fi
installdir=$1

Expand All @@ -26,7 +36,6 @@ if [ $rc -ne 0 ]; then
exit $rc
fi

who=`whoami`
sed -e "s/@PORT@/2893/" -e "s/@SERVICENAME@/lantorrent/" -e "s/@WHO@/$who/" -e "s^@LANTORRENT_HOME@^$LANTORRENT_HOME^" etc/lantorrent.inet.in > lantorrent.inet

rm etc/req.db
Expand Down
22 changes: 13 additions & 9 deletions lantorrent/pylantorrent/request.py
Expand Up @@ -65,7 +65,7 @@ def do_it_live(con, group_id):
c.execute(u, data)
state = 0
degree = degree + 1
if degree == maxd:
if degree > maxd:
state = 2
rc = 0
es = client.get_incomplete()
Expand All @@ -79,8 +79,8 @@ def do_it_live(con, group_id):
pylantorrent.log(logging.ERROR, "error trying to send %s" % (str(e)))
rid = e['id']
bad_rid.append(rid)
u = "update requests set state = ? where rid = ? and group_id = ?"
data = (state,rid,group_id,)
u = "update requests set state = ?, message = ? where rid = ? and group_id = ?"
data = (state,str(e),rid,group_id,)
c.execute(u, data)
con.commit()
return rc
Expand All @@ -89,18 +89,18 @@ def do_it_live(con, group_id):
def wait_until_sent(con, host, port, group_id):
done = False
while not done:
s = "select state from requests where group_id = ? and hostname = ? and port = ?"
s = "select state,messsage from requests where group_id = ? and hostname = ? and port = ?"
data = (group_id,host,port,)
c = con.cursor()
c.execute(s, data)
rs = c.fetchone()
con.commit()
state = int(rs[0])
pylantorrent.log(logging.INFO, "my state %d" % (state))
message = rs[1]
if state == 0:
time.sleep(1)
else:
return state
return (state, message)

def main(argv=sys.argv[1:]):
"""
Expand Down Expand Up @@ -131,8 +131,8 @@ def main(argv=sys.argv[1:]):
host = ha[0]
if host == "":
hostport = os.environ['SSH_CLIENT']
ha = hostport.split(" ")
host = ha[0]
ha2 = hostport.split(" ")
host = ha2[0]
if len(ha) > 1:
port = int(ha[1])
else:
Expand Down Expand Up @@ -160,7 +160,11 @@ def main(argv=sys.argv[1:]):
if cnt == group_count:
do_it_live(con, group_id)

rc = wait_until_sent(con, host, port, group_id)
(rc, message) = wait_until_sent(con, host, port, group_id)
if rc == 0:
print "Success"
else:
print "Failure: %s" % (message)

return rc

Expand Down

0 comments on commit a50cf45

Please sign in to comment.