diff --git a/junbi.cgi b/junbi.cgi index 27d5c62..041d0f3 100755 --- a/junbi.cgi +++ b/junbi.cgi @@ -24,6 +24,7 @@ intent = _metadata['intentName'] date = _params.get('date', "") period = _params.get('date-period', "") + machine_name = _params.get('machine-name', "") except: pass @@ -155,11 +156,9 @@ ][int(name)] # }}} def location(name): #{{{ - with open('ff.txt','w') as f: - f.write(name) - room, col, n = _search(name) + s = "" if room == "f": s += "前側の部屋," elif room == "b": @@ -179,6 +178,19 @@ return s # }}} +def log(name): # {{{ + url = 'http://ist.ksc.kwansei.ac.jp/~tutimura/cgi-bin/lab/?room=HSJ-' + name.rjust(2,'0') + user = 'whaov' + password = 'Tey12ufw' + headers ={} + headers["authorization"] = "Basic " + (_dec(user) + ":" + _dec(password)).encode("base64")[:-1] + req = urllib2.Request(url=url, headers=headers) + res = urllib2.urlopen(req) + + tree = lxml.html.etree.HTML(res.read().decode('utf-8')) + return "わかりません" +#}}} + get_parameters() answer = "" @@ -188,6 +200,8 @@ answer += machine(date, period) elif intent == "locationIntent": answer += location(machine_name) +elif intent == "logIntent": + answer += log(machine_name) if answer == "": from random import choice