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

Function main

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

Function invoked my __main__

(command_line)

Source from the content-addressed store, hash-verified

321 End of Functions and Class definitions
322"""
323def main(command_line):
324 """
325 Function invoked my __main__
326 """
327 usage = """
328 myFTP : A tool to download files and directories from remote location
329 Usage : myftp <config.xml>
330 """
331 if len(command_line) < 2 :
332 print usage
333 sys.exit(1)
334 else:
335 config_file = command_line[1]
336
337 # Read the configurations
338 print "Reading config file :" + config_file
339 global config, logger, timer_start_dict, timer_end_dict, download_status
340
341 try:
342 config = config_file_util(config_file)
343 except:
344 print "Configuration file may be corrupted, Quiting..."
345 print str(sys.exc_info()[0])+ " " + str(sys.exc_info()[1])
346 sys.exit(1)
347
348 # Execute the FTP Process for all modules
349 thread_id_list = []
350 timer_end_dict = {}
351 timer_start_dict = {}
352 download_status = {}
353 logger_status = {"DEBUG":logging.DEBUG, "ERROR":logging.ERROR, \
354 "INFO":logging.INFO, "WARNING":logging.WARNING}
355
356 # Creating the Logging Mechanism
357 try:
358 logger = logging.getLogger('ftpbuild')
359 hdlr = logging.FileHandler(config.find_config("LOG"),"wb")
360 stderr_hdlr = logging.StreamHandler()
361 formatter = logging.Formatter('%(asctime)s : %(levelname)s : %(message)s')
362 hdlr.setFormatter(formatter)
363 logger.addHandler(hdlr)
364 logger.addHandler(stderr_hdlr)
365 logger.setLevel(logger_status[config.find_config("LOG_LEVEL")])
366 logger.info("========================================================")
367 logger.info("=========== START OF FTP PROCESS ======================")
368 logger.info("========================================================")
369 except:
370 print "Unable to start logging, Quiting..."
371 print str(sys.exc_info()[0])+ " " + str(sys.exc_info()[1])
372 sys.exit(1)
373
374
375 for module_id in config.find_all_modules():
376 timer_start_dict[module_id] = 0
377 timer_end_dict[module_id] = 0
378 download_status[module_id] = "SUCCESS"
379 thread_id = module_thread(module_id)
380 thread_id_list.append(thread_id)

Callers 1

recipe-302592.pyFile · 0.70

Calls 12

config_file_utilClass · 0.85
strFunction · 0.85
module_threadClass · 0.85
getLoggerMethod · 0.80
find_configMethod · 0.80
find_all_modulesMethod · 0.80
gmtimeMethod · 0.80
exitMethod · 0.45
infoMethod · 0.45
appendMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected