logging.info('*************** ENTERED PYTHON SCRIPT *****************')
logging.info('Arguments Passed: [UpdateType - %s][Part Name - %s] [BaseOld - %s] [BaseNew - %s] \n [OUTPUTDir - %s] [BASE ATTR - %s] [TARGET ATTR - %s]' % (UPDATE_TYPE, PART_NAME, BASE_OLD, BASE_NEW, OUT_DIR, ATTR_OLD, ATTR_NEW))
- ensure_dir_exists(OUT_DIR)
+ try:
+ ensure_dir_exists(OUT_DIR)
+ except FileExistsError as exc:
+ logging.error('Argument passed as OUT_DIR - %s is already an existing file' % OUT_DIR)
+ raise exc
if GenerateDiffAttr == "TRUE":
if not (os.path.isfile(ATTR_OLD) and os.path.isfile(ATTR_NEW)):
print >> sys.stderr, "Attributes missing -- ABORT"
def ensure_dir_exists(path):
if not os.path.exists(path):
os.makedirs(path)
+ elif os.path.isfile(path):
+ raise FileExistsError
#shutil.rmtree(path)
#os.makedirs(path)
for elt in files_new:
dst_file = BASE_NEW + '/' + elt
newfiles_dest_path = 'run/upgrade-sysroot/'
- ensure_dir_exists(newfiles_dest_path)
+ try:
+ ensure_dir_exists(newfiles_dest_path)
+ except FileExistsError as exc:
+ logging.error('Directory %s used by this script is already an existing file' % newfiles_dest_path)
+ raise exc
if os.path.islink(dst_file):
patch = os.readlink(dst_file)
logging.debug(' File New Links %s' % elt)
for elt in Dir_Added:
newfiles_dest_path = 'run/upgrade-sysroot/'
- ensure_dir_exists(newfiles_dest_path)
+ try:
+ ensure_dir_exists(newfiles_dest_path)
+ except FileExistsError as exc:
+ logging.error('Directory %s used by this script is already an existing file' % newfiles_dest_path)
+ raise exc
destpath = newfiles_dest_path + elt
if not os.path.exists(destpath):
os.makedirs(destpath)