Repair ftp timeout error

This commit is contained in:
louis chauvet 2018-08-22 16:34:34 +02:00
parent fd84cf7f44
commit 6166d50580

View File

@ -1,3 +1,4 @@
import ftplib
import importlib
import json
import logging
@ -14,11 +15,12 @@ fileSystem = None
if os.environ.get("FTP_ADDRESS", False) and os.environ.get("FTP_USER", False) and os.environ.get("FTP_PASS", False):
print("FTP")
fileSystem = FTPFS(os.environ["FTP_ADDRESS"], user=os.environ["FTP_USER"], passwd=os.environ["FTP_PASS"])
fileSystem = FTPFS(os.environ["FTP_ADDRESS"], user=os.environ["FTP_USER"], passwd=os.environ["FTP_PASS"], timeout=600)
else:
print("OS")
fileSystem = OSFS(os.getcwd())
# json decoder for int keys
class Decoder(json.JSONDecoder):
def decode(self, s, **kwargs):
@ -206,8 +208,13 @@ class FoBot(discord.Client):
info("foBot is resumed.")
async def on_error(self, event, *args, **kwargs):
if sys.exc_type == ftplib.error_temp:
global fileSystem
fileSystem = FTPFS(os.environ["FTP_ADDRESS"], user=os.environ["FTP_USER"], passwd=os.environ["FTP_PASS"],
timeout=600)
error("foBot encounter an error.", exc_info=True)
async def on_message(self, msg):
await self.guilds_class[msg.guild.id].on_message(msg)