Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Binux committed Aug 26, 2013
1 parent 5f761c2 commit efd927c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bot.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
};
ws.onclose = function() {
log.innerHTML += "<br /><span class=error>disconnected.</span>";
login(form);
setTimeout(function() { login(form); }, 60*1000);
};
ws.onmessage = function(event) {
log.innerHTML += "<br />"+event.data;
Expand Down
4 changes: 2 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def explore(self):

def run(self, login_id, password, area=None):
self.login(login_id, password)
self.choose_area(int(area))
self.choose_area(area)
while True:
self._print('current AP:%s/%s BC:%s/%s' % (self.ma.ap, self.ma.ap_max, self.ma.bc, self.ma.bc_max))
self.fairy()
Expand All @@ -189,7 +189,7 @@ def run(self, login_id, password, area=None):
bot = Bot()
while True:
try:
bot.run(config.loginId, config.password, sys.argv[1] if len(sys.argv) > 1 else None)
bot.run(config.loginId, config.password, int(sys.argv[1]) if len(sys.argv) > 1 else None)
except ma.HeaderError, e:
print e.code, e.message, 'sleep for 10min'
import traceback; traceback.print_exc()
Expand Down
6 changes: 4 additions & 2 deletions web_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def websocket_app(environ, start_response):
request = Request(environ)
if request.path == '/bot' and 'wsgi.websocket' in environ:
connected += 1
print "conn+%s=%d %s" % (environ.get('HTTP_X_Real_IP') or environ['REMOTE_ADDR'],
connected, environ['HTTP_USER_AGENT'])
print "conn+%s=%d %s" % (environ.get('HTTP_X_REAL_IP', environ['REMOTE_ADDR']),
connected, environ.get('HTTP_USER_AGENT', '-'))
ws = environ["wsgi.websocket"]
login_id = request.GET['id']
password = request.GET['password']
Expand All @@ -58,10 +58,12 @@ def websocket_app(environ, start_response):
print "current conn-1: %d" % connected
break
except ma.HeaderError, e:
print e.code, e.message
ws.send('%s %s %s' % (e.code, e.message, 'sleep for 10min'))
time.sleep(10*60)
continue
except Exception, e:
import traceback; traceback.print_exc()
ws.send('%r %s' % (e, 'sleep for 1min'))
time.sleep(60)
continue
Expand Down

0 comments on commit efd927c

Please sign in to comment.