def init_workspace(cfg, is_inplace=False):
log.info("init workspace is_inplace:%r",is_inplace)
if is_inplace:
init_workspace_inplace(cfg)
else:
# create a clean workspace
workspace_dir = os.path.join(BASE_HOME,cfg.exec_home)
if not os.path.exists(workspace_dir):
os.mkdir(workspace_dir)
else:
shutil.rmtree(workspace_dir)
os.mkdir(workspace_dir)
cfg.workspace_dir = workspace_dir
# copy target file into workspace
if os.path.exists(cfg.target):
shutil.copy(cfg.target, workspace_dir)
target_abs_path = os.path.join(workspace_dir, os.path.basename(cfg.target))
cfg.target_abs_path = target_abs_path
os.chmod(target_abs_path, stat.S_IRUSR)
else:
log.critical("%s dose not exist.", cfg.target)
os._exit(1)
log.info("Target absolute path: %s", cfg.target_abs_path)
# I can not change dir at here, the dir will be changed everytime when analyzer starts.
评论列表
文章目录