MCPcopy Create free account
hub / github.com/ActiveState/code / get_build

Function get_build

recipes/Python/302592_Threaded_FTP_Client/recipe-302592.py:109–139  ·  view source on GitHub ↗

Function to get the module from the FTP Server

(module_id, config)

Source from the content-addressed store, hash-verified

107 raise
108
109def get_build(module_id, config):
110 """ Function to get the module from the FTP Server
111 """
112 if config.find_keep_original(module_id).lower() == "yes":
113 make_backup(module_id)
114 logger.info("["+module_id+"]FTP for this module started")
115 machine_name = config.find_ftp_info_machine_name_for_module(module_id)
116 uid = config.find_ftp_info_for_module(module_id, 'ftp_uid')
117 pwd = config.find_ftp_info_for_module(module_id, 'ftp_password')
118 ftp_loc = config.find_ftp_info_for_module(module_id, 'ftp_location')
119 local_loc = config.find_location_for_module(module_id, 'stage_location')
120 logger.debug("[" + module_id + "] Connecting to machine " + machine_name)
121 ftp_pool = FTP_pool(module_id,config)
122 local_loc = os.path.join(local_loc,os.path.basename(ftp_loc))
123 os.makedirs(local_loc)
124
125 try:
126 ftp = ftplib.FTP(machine_name)
127 ftp.login(uid, pwd)
128 recur_get(ftp, ftp_loc, local_loc, module_id, config, ftp_pool)
129 ftp.quit()
130 ftp_pool.close_all()
131 except:
132 ftp_pool.close_all()
133 logger.error("[" + module_id + "]Unable to access FTP location")
134 logger.error("[" + module_id + "]Error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
135 download_status[module_id] = "FAILED"
136 raise
137 else:
138 logger.info("[" + module_id + "] FTP for module completed")
139 download_status[module_id] = "SUCCESS"
140
141
142def download_distribute(module_id, machine_list,config):

Callers 1

download_distributeFunction · 0.85

Calls 15

close_allMethod · 0.95
make_backupFunction · 0.85
FTP_poolClass · 0.85
recur_getFunction · 0.85
strFunction · 0.85
find_keep_originalMethod · 0.80
loginMethod · 0.80
lowerMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected