wylark
/
infoex-autowx.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
39fe90b
)
Add a timeout to the FTP operation
author
Alexander Vasarab <alexander@wylark.com>
Sat, 22 Mar 2025 16:51:29 +0000
(09:51 -0700)
committer
Alexander Vasarab <alexander@wylark.com>
Sat, 22 Mar 2025 16:51:29 +0000
(09:51 -0700)
infoex-autowx.py
patch
|
blob
|
history
diff --git
a/infoex-autowx.py
b/infoex-autowx.py
index 8cab0c35cfdd94144d6ed074260be0266c9d9ddb..2cfd46ea55c8b529205c633077512f5353bd9c4d 100755
(executable)
--- a/
infoex-autowx.py
+++ b/
infoex-autowx.py
@@
-27,6
+27,7
@@
import csv
import datetime
import logging
import os
import datetime
import logging
import os
+import socket
import sys
import time
import urllib3
import sys
import time
import urllib3
@@
-384,7
+385,10
@@
def main():
return 1
if not options.dry_run:
return 1
if not options.dry_run:
- upload_csv(infoex['csv_filename'], infoex)
+ try:
+ upload_csv(infoex['csv_filename'], infoex)
+ except socket.timeout:
+ LOG.critical("FTP timed out")
LOG.debug('DONE')
return 0
LOG.debug('DONE')
return 0
@@
-852,7
+856,7
@@
def upload_csv(path_to_file, infoex_data):
with open(path_to_file, 'rb') as file_object:
LOG.debug("uploading FTP file '%s'", infoex_data['host'])
ftp = FTP(infoex_data['host'], infoex_data['uuid'],
with open(path_to_file, 'rb') as file_object:
LOG.debug("uploading FTP file '%s'", infoex_data['host'])
ftp = FTP(infoex_data['host'], infoex_data['uuid'],
- infoex_data['api_key'])
+ infoex_data['api_key']
, timeout=10
)
ftp.storlines('STOR ' + path_to_file, file_object)
ftp.close()
file_object.close()
ftp.storlines('STOR ' + path_to_file, file_object)
ftp.close()
file_object.close()