- gpxeimg = search_file('gpxe.lkrn', iso_mount)
- if gpxeimg is None:
- logging.warn("Warning: gpxe.lkrn not found (that's fine if you don't need it)")
- else:
- exec_rsync(gpxeimg, addons + 'gpxe.lkrn')
+ handle_addon_copy('gpxe.lkrn', addons, iso_mount)
+
+
+def glob_and_copy(filepattern, dst):
+ """Glob on specified filepattern and copy the result to dst
+
+ @filepattern: globbing pattern
+ @dst: target directory
+ """
+ for name in glob.glob(filepattern):
+ copy_if_exist(name, dst)
+
+def search_and_copy(filename, search_path, dst):
+ """Search for the specified filename at searchpath and copy it to dst
+
+ @filename: filename to look for
+ @search_path: base search file
+ @dst: destionation to copy the file to
+ """
+ file_location = search_file(filename, search_path)
+ copy_if_exist(file_location, dst)
+
+def copy_if_exist(filename, dst):
+ """Copy filename to dst if filename is set.
+
+ @filename: a filename
+ @dst: dst file
+ """
+ if filename and (os.path.isfile(filename) or os.path.isdir(filename)):
+ exec_rsync(filename, dst)