Improve --dry-run behavior
[infoex-autowx.git] / infoex-autowx.py
index d6edf5e4cf88db34c7b3a910bf4bbbadf3863cc2..ea91beff5dc256cfde9116457fc71be1fd49ebb4 100755 (executable)
@@ -27,6 +27,7 @@ import configparser
 import csv
 import datetime
 import logging
+import os
 import sys
 import time
 
@@ -239,11 +240,13 @@ with open(infoex['csv_filename'], 'w') as f:
     f.close()
 
 if not options.dry_run:
+    # not a dry run
     with open(infoex['csv_filename'], 'rb') as f:
         log.debug("uploading FTP file '%s'" % (infoex['host']))
         ftp = FTP(infoex['host'], infoex['uuid'], infoex['api_key'])
         ftp.storlines('STOR ' + infoex['csv_filename'], f)
         ftp.close()
         f.close()
+    os.remove(infoex['csv_filename'])
 
 log.debug('DONE')