From: Yoan Le Clanche Date: Wed, 12 Jul 2023 12:39:30 +0000 (+0200) Subject: Show alert message when a ccontent is in the error folder : https://trackers.pilotsys... X-Git-Tag: 2.8.1-pro~32 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b8799a809c12d3cea5531c74bf08c34374a604cd;p=teleforma.git Show alert message when a ccontent is in the error folder : https://trackers.pilotsystems.net/prebarreau/0583 --- diff --git a/teleforma/management/commands/teleforma-export-avis.py b/teleforma/management/commands/teleforma-export-avis.py index eb098bbc..cb090d81 100644 --- a/teleforma/management/commands/teleforma-export-avis.py +++ b/teleforma/management/commands/teleforma-export-avis.py @@ -172,6 +172,12 @@ class Command(BaseCommand): # convert StringIO to BytesIO bytes_output = io.BytesIO(output.getvalue().encode('utf-8')) ftp.storbinary("STOR export-orders%s.csv" % str(date.today()), bytes_output) + + # check existence of file in "errors" folder + ftp.cwd(self.FTP_PATH + '/error') + files = ftp.nlst() + if files: + self.log("Error : there's a file in the FTP 'error' directory. Something went wrong in the last export. Please check the error file on the FTP.") ftp.quit() except: ftp.close() @@ -185,4 +191,4 @@ class Command(BaseCommand): settings.DEFAULT_FROM_EMAIL, settings.REPORT_TO_EMAIL, fail_silently=False, - ) + ) \ No newline at end of file