Skip to content

Commit

Permalink
Added checks and exception messages for removing temporary directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyapayne committed Jan 25, 2016
1 parent 270642f commit 768ef58
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,32 @@ def make_output_dirs(self):

output_dir = utils.path_join(self.output_dir(), self.project_name())
if os.path.exists(output_dir):
utils.rmtree(output_dir, ignore_errors=True)
try:
utils.rmtree(output_dir)
except OSError as e:
error = u'Failed to remove output directory: {}.'.format(output_dir)
error += '\nError recieved: {}'.format(e)
self.logger.error(error)
self.output_err += error

temp_dir = utils.path_join(TEMP_DIR, 'webexectemp')

if os.path.exists(temp_dir):
utils.rmtree(temp_dir, ignore_errors=True)
try:
utils.rmtree(temp_dir)
except OSError as e:
error = u'Failed to remove temporary directory: {}.'.format(temp_dir)
error += '\nError recieved: {}'.format(e)
self.logger.error(error)
self.output_err += error

self.progress_text = 'Making new directories...\n'

if not os.path.exists(output_dir):
os.makedirs(output_dir)

os.makedirs(temp_dir)
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)

self.copy_files_to_project_folder()

Expand Down Expand Up @@ -806,7 +820,13 @@ def make_output_dirs(self):
self.logger.error(error)
self.output_err += error
finally:
utils.rmtree(temp_dir, ignore_errors=True)
try:
utils.rmtree(temp_dir)
except OSError as e:
error = u'Failed to remove temporary directory: {}.'.format(temp_dir)
error += '\nError recieved: {}'.format(e)
self.logger.error(error)
self.output_err += error

def make_desktop_file(self, nw_path, export_dest):
icon_set = self.get_setting('icon')
Expand Down

0 comments on commit 768ef58

Please sign in to comment.