Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/fastdl/fastdl.py", line 33, in check_fastdl_files()
ftp.storbinary(f'STOR {file}', file)
File "../addons/source-python/Python3/ftplib.py", line 502, in storbinary
with self.transfercmd(cmd, rest) as conn:
File "../addons/source-python/Python3/ftplib.py", line 397, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "../addons/source-python/Python3/ftplib.py", line 363, in ntransfercmd
resp = self.sendcmd(cmd)
File "../addons/source-python/Python3/ftplib.py", line 271, in sendcmd
return self.getresp()
File "../addons/source-python/Python3/ftplib.py", line 244, in getresp
raise error_perm(resp)
ftplib.error_perm: 550 <_io.BufferedReader name=Path('csgo/maps/$2000$.nav')>: No such file or directory
Here is the code:
Syntax: Select all
import os
import ftplib
from path import Path
from core import GAME_NAME
from listeners import OnLevelInit
BASE_PATH = Path(f'{GAME_NAME}/maps')
FTP_HOST = ''
FTP_USER = ''
FTP_PASSWORD = ''
FTP_WEB_FOLDER_PATH = ''
@OnLevelInit
def map_start(current_map):
check_fastdl_files()
def check_fastdl_files():
ftp = ftplib.FTP(timeout=10)
ftp.connect(FTP_HOST, 21)
ftp.login(FTP_USER, FTP_PASSWORD)
ftp.cwd(f'{FTP_WEB_FOLDER_PATH}/{GAME_NAME}/maps')
files = ftp.nlst()
for maps in os.listdir(f'{GAME_NAME}/maps/'):
if maps.endswith('.nav'):
map_to_check = maps + '.bz2'
if not map_to_check in files:
with open(BASE_PATH.joinpath(maps), 'rb') as file:
ftp.storbinary(f'STOR {file}', file)
print(f'[FTP]: Uploaded {file}')
ftp.quit()
I don't understand why it gives me that error, what is wrong of my code?
I checked that the map file does exists in the server