-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathftpToFC.py
executable file
·41 lines (34 loc) · 964 Bytes
/
ftpToFC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python3
import os
import sys
from ftplib import FTP
# Read input args
numargs = len(sys.argv)
if numargs != 2:
print('Usage: {} [file]'.format(sys.argv[0]))
exit()
else:
file = sys.argv[1]
print('{} {}'.format('file = ',file))
test = False
# Field Catalog inputs
if test:
ftpCatalogServer = 'ftp.atmos.washington.edu'
ftpCatalogUser = 'anonymous'
ftpCatalogPassword = '[email protected]'
catalogDestDir = 'brodzik/incoming/impacts'
else:
ftpCatalogServer = 'catalog.eol.ucar.edu'
ftpCatalogUser = 'anonymous'
catalogDestDir = '/pub/incoming/catalog/impacts'
# Open ftp connection
if test:
catalogFTP = FTP(ftpCatalogServer,ftpCatalogUser,ftpCatalogPassword)
catalogFTP.cwd(catalogDestDir)
else:
catalogFTP = FTP(ftpCatalogServer,ftpCatalogUser)
catalogFTP.cwd(catalogDestDir)
# ftp kmlFile to Field Catalog
ftpFile = open(file,'rb')
catalogFTP.storbinary('STOR '+file,ftpFile)
ftpFile.close()