Created
November 13, 2020 17:10
-
-
Save bDrwx/6ae69363c8985f0cf002f6687c45e82a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
last_cdr: str = '' | |
def callback(info): | |
ls_out = info.split() | |
if re.match(r'CF\d{4}.D00', ls_out[-1]): | |
td = datetime.now() - datetime.strptime(" ".join(ls_out[:2]), '%H.%M:%S %d.%m.%Y') | |
if td <= timedelta(minutes=15): | |
global last_cdr | |
last_cdr = ls_out[-1] | |
return None | |
ftp = ftplib.FTP(IP) | |
ftp.login(name, pass) | |
ftp.cwd('VIDAST') | |
ls = ftp.retrlines('LIST ' + 'CF*', callback) | |
print(f'last_cdr is {last_cdr}') | |
local_cdr = open(last_cdr, 'wb') | |
ftp.retrbinary('RETR ' + last_cdr, local_cdr.write) | |
ftp.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment