Update README with preliminary new version text
[infoex-autowx.git] / infoex-autowx.py
index d6edf5e4cf88db34c7b3a910bf4bbbadf3863cc2..f703c4298f3a63f0fe570f86959240d2a2d470c8 100755 (executable)
@@ -27,6 +27,7 @@ import configparser
 import csv
 import datetime
 import logging
 import csv
 import datetime
 import logging
+import os
 import sys
 import time
 
 import sys
 import time
 
@@ -76,18 +77,18 @@ wsdl = 'https://www.wcc.nrcs.usda.gov/awdbWebService/services?WSDL'
 
 try:
     infoex = {
 
 try:
     infoex = {
-        'host': config['ftp']['host'],
-        'uuid': config['ftp']['uuid'],
-        'api_key': config['ftp']['api_key'],
-        'location_uuid': config['wxsite']['location_uuid'],
+        'host': config['infoex']['host'],
+        'uuid': config['infoex']['uuid'],
+        'api_key': config['infoex']['api_key'],
+        'location_uuid': config['infoex']['location_uuid'],
         'wx_data': {}, # placeholder key, values to come later
         'wx_data': {}, # placeholder key, values to come later
-        'csv_filename': config['wxsite']['csv_filename']
+        'csv_filename': config['infoex']['csv_filename']
     }
 
     }
 
-    station_triplet = config['wxsite']['station_triplet']
+    station_triplet = config['nrcs']['station_triplet']
 
     try:
 
     try:
-        desired_data = config['wxsite']['desired_data'].split(',')
+        desired_data = config['nrcs']['desired_data'].split(',')
     except:
         # desired_data malformed or missing, setting default
         desired_data = [
     except:
         # desired_data malformed or missing, setting default
         desired_data = [
@@ -239,11 +240,13 @@ with open(infoex['csv_filename'], 'w') as f:
     f.close()
 
 if not options.dry_run:
     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()
     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')
 
 log.debug('DONE')