Skip to content

Commit dd57e51

Browse files
committed
Remove redundant download functions
1 parent a193138 commit dd57e51

File tree

2 files changed

+9
-62
lines changed

2 files changed

+9
-62
lines changed

changehc/delphi_changehc/download_ftp_files.py

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -42,61 +42,7 @@ def get_files_from_dir(sftp, filedate, out_path):
4242

4343

4444
def download_covid(filedate, out_path, ftp_conn):
45-
"""Download files necessary to create chng-covid signal from ftp server.
46-
47-
Args:
48-
filedate: YYYYmmdd string for which the files are named
49-
out_path: Path to local directory into which to download the files
50-
ftp_conn: Dict containing login credentials to ftp server
51-
"""
52-
# open client
53-
try:
54-
client = paramiko.SSHClient()
55-
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
56-
57-
client.connect(ftp_conn["host"], username=ftp_conn["user"],
58-
password=ftp_conn["pass"],
59-
port=ftp_conn["port"],
60-
allow_agent=False, look_for_keys=False)
61-
sftp = client.open_sftp()
62-
63-
sftp.chdir('/countproducts')
64-
get_files_from_dir(sftp, filedate, out_path)
65-
66-
finally:
67-
if client:
68-
client.close()
69-
70-
71-
def download_cli(filedate, out_path, ftp_conn):
72-
"""Download files necessary to create chng-cli signal from ftp server.
73-
74-
Args:
75-
filedate: YYYYmmdd string for which the files are named
76-
out_path: Path to local directory into which to download the files
77-
ftp_conn: Dict containing login credentials to ftp server
78-
"""
79-
# open client
80-
try:
81-
client = paramiko.SSHClient()
82-
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
83-
84-
client.connect(ftp_conn["host"], username=ftp_conn["user"],
85-
password=ftp_conn["pass"],
86-
port=ftp_conn["port"],
87-
allow_agent=False, look_for_keys=False)
88-
sftp = client.open_sftp()
89-
90-
sftp.chdir('/countproducts')
91-
get_files_from_dir(sftp, filedate, out_path)
92-
93-
finally:
94-
if client:
95-
client.close()
96-
97-
98-
def download_flu(filedate, out_path, ftp_conn):
99-
"""Download files necessary to create chng-flu signal from ftp server.
45+
"""Download files necessary to create chng- signals from ftp server.
10046
10147
Args:
10248
filedate: YYYYmmdd string for which the files are named

changehc/delphi_changehc/run.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from delphi_utils import get_structured_logger
1515

1616
# first party
17-
from .download_ftp_files import download_covid, download_cli, download_flu
17+
from .download_ftp_files import download_covid
1818
from .load_data import load_combined_data, load_cli_data, load_flu_data
1919
from .update_sensor import CHCSensorUpdater
2020

@@ -26,12 +26,13 @@ def retrieve_files(params, filedate, logger):
2626

2727
## download recent files from FTP server
2828
logger.info("downloading recent files through SFTP")
29-
if "covid" in params["indicator"]["types"]:
30-
download_covid(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
31-
if "cli" in params["indicator"]["types"]:
32-
download_cli(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
33-
if "flu" in params["indicator"]["types"]:
34-
download_flu(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
29+
#if "covid" in params["indicator"]["types"]:
30+
# download_covid(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
31+
#if "cli" in params["indicator"]["types"]:
32+
# download_cli(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
33+
#if "flu" in params["indicator"]["types"]:
34+
# download_flu(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
35+
download_covid(filedate, params["indicator"]["input_cache_dir"], params["indicator"]["ftp_conn"])
3536

3637
denom_file = "%s/%s_Counts_Products_Denom.dat.gz" % (params["indicator"]["input_cache_dir"],filedate)
3738
covid_file = "%s/%s_Counts_Products_Covid.dat.gz" % (params["indicator"]["input_cache_dir"],filedate)

0 commit comments

Comments
 (0)