home
·
contact
·
privacy
projects
/
plomlombot-irc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Re-try on TimeoutError on socket connect.
[plomlombot-irc.git]
/
plomlombot.py
diff --git
a/plomlombot.py
b/plomlombot.py
index f81c05ed31aa5f2e94db66d5d6589a6c3d3707b9..61da87140fca80d902042d933b0b235fe25dcd0c 100755
(executable)
--- a/
plomlombot.py
+++ b/
plomlombot.py
@@
-53,7
+53,10
@@
class IO:
def __init__(self, server, port, timeout):
self.timeout = timeout
self.socket = socket.socket()
def __init__(self, server, port, timeout):
self.timeout = timeout
self.socket = socket.socket()
- self.socket.connect((server, port))
+ try:
+ self.socket.connect((server, port))
+ except TimeoutError:
+ raise ExceptionForRestart
self.socket.setblocking(0)
self.line_buffer = []
self.rune_buffer = ""
self.socket.setblocking(0)
self.line_buffer = []
self.rune_buffer = ""
@@
-366,9
+369,12
@@
class Session:
self.io.send_line("JOIN " + self.channel)
hash_channel = hashlib.md5(self.channel.encode("utf-8")).hexdigest()
self.chandir = self.dbdir + "/" + hash_channel + "/"
self.io.send_line("JOIN " + self.channel)
hash_channel = hashlib.md5(self.channel.encode("utf-8")).hexdigest()
self.chandir = self.dbdir + "/" + hash_channel + "/"
+ self.rawlogdir = self.chandir + "raw_logs/"
self.logdir = self.chandir + "logs/"
if not os.path.exists(self.logdir):
os.makedirs(self.logdir)
self.logdir = self.chandir + "logs/"
if not os.path.exists(self.logdir):
os.makedirs(self.logdir)
+ if not os.path.exists(self.rawlogdir):
+ os.makedirs(self.rawlogdir)
self.markovfile = self.chandir + "markovfeed"
self.quotesfile = self.chandir + "quotes"
self.markovfile = self.chandir + "markovfeed"
self.quotesfile = self.chandir + "quotes"
@@
-379,7
+385,7
@@
class Session:
line = Line(":" + self.nickname + "!~" + self.username +
"@localhost" + " " + line)
now = datetime.datetime.utcnow()
line = Line(":" + self.nickname + "!~" + self.username +
"@localhost" + " " + line)
now = datetime.datetime.utcnow()
- logfile = open(self.
logdir + now.strftime("%Y-%m-%d") + ".raw_log
", "a")
+ logfile = open(self.
rawlogdir + now.strftime("%Y-%m-%d") + ".txt
", "a")
form = "%Y-%m-%d %H:%M:%S UTC\t"
logfile.write(now.strftime(form) + " " + line.line + "\n")
logfile.close()
form = "%Y-%m-%d %H:%M:%S UTC\t"
logfile.write(now.strftime(form) + " " + line.line + "\n")
logfile.close()