Our build folder structure looks like something like below:
target file:/home/workspace/slave_1/dock_location/build/project_1/applications/target/*.tar.gz
target file:/home/workspace/slave_1/dock_location/build/project_1/applications/first_app/target/*.tar.gz
target file:/home/workspace/slave_1/dock_location/build/project_2/applications/third_app/target/*.tar.gz
and below snippet gets the list of all the tar.gz file names with the absolute path/
for dir in folders_to_search:
# where dir resolves to /home/workspace/slave_1/dock_location/build/project_1/applications/first_app and so on
final_file = os.path.join(dir, 'target', '*.tar.gz')
tar_list = glob.glob(final_file) # which will expand and give me the full tar.gz path
<logic to process the list of tar files...>
blah blah..
Now, there is a change in folder structure and the updated path looks like
tree /home/workspace/slave_1/dock_location/build/project_1/applications/first_app/target/neo-uber-path/
├── design
│ ├── app-lightining
│ │ └── 1.110.23450345
│ │ ├── app-lightining-1.110.23450345.tar.gz
│ │ └── design.json
│ └── background-lightining
│ └── 1.110.23450345
│ ├── background-lightining-1.110.23450345.tar.gz
│ └── design.json
└── features
├── provison-robust-feature
│ └── 1.23.108.35900021
│ ├── provison-robust-feature-1.1.110.23450345.tar.gz
│ └── BS.yaml
└── panda-service
└── 7.14.610.80350021
├── panda-service-1.1.110.23450345.tar.gz
└── BS.yaml
I'm not sure of the logic to get this line - final_file = os.path.join(dir, 'target', '*.tar.gz')
working for the new scenario.
My alternate option is like below, but would like to hear from the experts first, whether a tweak in my existing snippet is possible, rather than writing a new chunk of code..
Kindly correct me if Im wrong and pls. let me know if full piece of code is required , thank you.
Alternate option
for root, dirnames, filenames in os.walk(dir):
for filename in filenames:
if filename.endswith(extensions):
matches.append(os.path.join(root, filename))