mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
cleanup
This commit is contained in:
@@ -36,7 +36,7 @@ def fetch_page(url):
|
|||||||
logger('info', 'fetching page ' + url)
|
logger('info', 'fetching page ' + url)
|
||||||
try:
|
try:
|
||||||
response = urllib.urlopen(url)
|
response = urllib.urlopen(url)
|
||||||
html = response.read(BUFSIZ)
|
html = response.read(BUFSIZ) # ignore more than BUFSIZ
|
||||||
response.close()
|
response.close()
|
||||||
return html
|
return html
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
@@ -52,6 +52,9 @@ def extract_title(url):
|
|||||||
return result.groups()[0]
|
return result.groups()[0]
|
||||||
|
|
||||||
def chat_write(message):
|
def chat_write(message):
|
||||||
|
if debug_enabled():
|
||||||
|
print message
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
fd = open(fifo_path, 'wb')
|
fd = open(fifo_path, 'wb')
|
||||||
fd.write('/say ' + message)
|
fd.write('/say ' + message)
|
||||||
@@ -86,10 +89,6 @@ def extract_url(data):
|
|||||||
message = 'some error occured when fetching %s' % e(r)
|
message = 'some error occured when fetching %s' % e(r)
|
||||||
|
|
||||||
logger('info', 'printing ' + message)
|
logger('info', 'printing ' + message)
|
||||||
|
|
||||||
if debug_enabled():
|
|
||||||
print message
|
|
||||||
else:
|
|
||||||
chat_write(message)
|
chat_write(message)
|
||||||
|
|
||||||
def parse_commands(data):
|
def parse_commands(data):
|
||||||
@@ -105,9 +104,9 @@ def parse_commands(data):
|
|||||||
def parse_delete(filepath):
|
def parse_delete(filepath):
|
||||||
try:
|
try:
|
||||||
fd = open(filepath, 'rb')
|
fd = open(filepath, 'rb')
|
||||||
except:
|
except IOError:
|
||||||
logger('err', 'file has vanished: ' + filepath)
|
logger('err', 'file has vanished: ' + filepath)
|
||||||
return -1
|
return False
|
||||||
|
|
||||||
content = fd.read(BUFSIZ) # ignore more than BUFSIZ
|
content = fd.read(BUFSIZ) # ignore more than BUFSIZ
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user