calliope-edu / CalliopEO_AstroPi

MIT License
1 stars 2 forks source link

handle subdirectories in Zip file #61

Closed Amerlander closed 3 years ago

Amerlander commented 3 years ago

At the moment the script only handle .hex files who are directly zipped. If it happens that someone Zips a complete Folder the unpacked run_ folder will contain a subfolder where the .hex files are (`.zip/folder/file.hex`). These hex files wont be processed.

Unzip has a -j option to do not create subdirectories: unzip -j /path/to/file.zip. I'm not aware if shutil.unpack_archive() can do something similar.

But having multiple folders like

might result in ending with only one hex file instead of two. So It could also be an option to just cancel the process if the zip file contains one (or more than one) subfolder und report an error?

It could also be, that someone

rzbrk commented 3 years ago

Is there a good reason to have the hex file in zip archives in the first place?

Why not placing directly the hex files in the main directory? When processed, the hex files are renamed to .hex.done instead of the zip archives.

This way, we get rid of at least to problems:

  1. zip archives with subdirectories
  2. zip archives not (only) containing hex files

Maybe, falling back to processing hex files directly can be implemented in a later version.

Amerlander commented 3 years ago

I think this depends on how the process of receiving Code from the students and sending it to the Pi will look like. We should discuss this together with @joernalraun on Thursday.