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

Function make_backup

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

Function: Move the directory to a backup location

(module_id)

Source from the content-addressed store, hash-verified

6global logger, timer_start_dict, timer_end_dict, download_status
7
8def make_backup(module_id):
9 """ Function: Move the directory to a backup location
10 """
11 backup_location = config.find_location_for_module(module_id, 'backup_location')
12 stage_location = config.find_location_for_module(module_id, 'stage_location')
13 logger.info("["+module_id+"] Moving files " + stage_location + " to " + backup_location )
14 try:
15 if os.path.exists(backup_location):
16 shutil.rmtree( backup_location, True )
17 else:
18 #This is to ensure that backup folder's path exists
19 #and this path is reachable
20 os.makedirs(backup_location)
21 shutil.rmtree(backup_location, True )
22 if os.path.exists(stage_location):
23 shutil.move( stage_location , backup_location)
24 else:
25 logger.info("Location " + stage_location + " not present, no backup taken")
26 except:
27 logger.error("[" + module_id + "] Failed to remove:" + backup_location)
28 logger.error("[" + module_id + "] Failed to remove Error:" + str(sys.exc_info()[0])+ " " + str(sys.exc_info()[1]))
29 raise
30 else:
31 os.makedirs(stage_location)
32
33
34def copy_to_machine(machine_name, module_id, config):

Callers 1

get_buildFunction · 0.85

Calls 6

strFunction · 0.85
infoMethod · 0.45
existsMethod · 0.45
moveMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected