Repair ftp timeout error
This commit is contained in:
parent
fd84cf7f44
commit
6166d50580
9
main.py
9
main.py
@ -1,3 +1,4 @@
|
|||||||
|
import ftplib
|
||||||
import importlib
|
import importlib
|
||||||
import json
|
import json
|
||||||
import logging
|
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):
|
if os.environ.get("FTP_ADDRESS", False) and os.environ.get("FTP_USER", False) and os.environ.get("FTP_PASS", False):
|
||||||
print("FTP")
|
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:
|
else:
|
||||||
print("OS")
|
print("OS")
|
||||||
fileSystem = OSFS(os.getcwd())
|
fileSystem = OSFS(os.getcwd())
|
||||||
|
|
||||||
|
|
||||||
# json decoder for int keys
|
# json decoder for int keys
|
||||||
class Decoder(json.JSONDecoder):
|
class Decoder(json.JSONDecoder):
|
||||||
def decode(self, s, **kwargs):
|
def decode(self, s, **kwargs):
|
||||||
@ -206,8 +208,13 @@ class FoBot(discord.Client):
|
|||||||
info("foBot is resumed.")
|
info("foBot is resumed.")
|
||||||
|
|
||||||
async def on_error(self, event, *args, **kwargs):
|
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)
|
error("foBot encounter an error.", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
async def on_message(self, msg):
|
async def on_message(self, msg):
|
||||||
await self.guilds_class[msg.guild.id].on_message(msg)
|
await self.guilds_class[msg.guild.id].on_message(msg)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user