~andreserl/maas/update-maas-images-v3

« back to all changes in this revision

Viewing changes to meph2/commands/cloudimg_sync.py

  • Committer: Lee Trager
  • Date: 2016-08-08 19:59:18 UTC
  • Revision ID: lee.trager@canonical.com-20160808195918-lqsfzwqzw42esic9
Only remove SquashFS file when not publishing SquashFS images and file exists

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
                if 'squashfs' in i and not self.squashfs:
164
164
                    # If we're not publishing the SquashFS image but one
165
165
                    # was used to generate root-image.gz delete it.
166
 
                    os.remove(filename)
 
166
                    if os.path.exists(filename):
 
167
                        os.remove(filename)
167
168
                    continue
168
169
                elif i == 'root-image.gz' and self.squashfs:
169
170
                    # If we're publishing the SquashFS image we don't need the
171
172
                    # Ubuntu releases (<16.04) don't have SquashFS images
172
173
                    # published, so only remove if a SquashFS file exists.
173
174
                    squashfs_image = os.path.join(
174
 
                        os.path.dirname(filename), '*.squashfs')
 
175
                        os.path.dirname(filename), '*squashfs')
175
176
                    if len(glob.glob(squashfs_image)) > 0:
176
177
                        if os.path.exists(filename):
177
178
                            os.remove(filename)
180
181
                    # If we're publishing the SquashFS image we don't need the
181
182
                    # root-image manifest either.
182
183
                    squashfs_image = os.path.join(
183
 
                        os.path.dirname(filename), '*.squashfs')
 
184
                        os.path.dirname(filename), '*squashfs')
184
185
                    if len(glob.glob(squashfs_image)) > 0:
185
186
                        if os.path.exists(filename):
186
187
                            os.remove(filename)