diff --git a/britney.py b/britney.py index 8f03135..542265c 100755 --- a/britney.py +++ b/britney.py @@ -797,6 +797,7 @@ class Britney(object): # write excuses to the output file if not self.options.dry_run: self.logger.info("> Writing Excuses to %s", self.options.excuses_output) + os.makedirs(os.path.dirname(self.options.excuses_output), exist_ok=True) write_excuses(excuses, self.options.excuses_output, output_format="legacy-html") if hasattr(self.options, 'excuses_yaml_output'): @@ -1545,6 +1546,7 @@ class Britney(object): " as this is a dry-run.") elif hasattr(self.options, 'upgrade_output'): upgrade_output = getattr(self.options, 'upgrade_output') + os.makedirs(os.path.dirname(self.options.upgrade_output), exist_ok=True) file_handler = logging.FileHandler(upgrade_output, mode='w', encoding='utf-8') output_formatter = logging.Formatter('%(message)s') file_handler.setFormatter(output_formatter) diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index e97f436..2137131 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -516,6 +516,7 @@ class AgePolicy(BasePolicy): basename = 'Dates' old_file = None filename = os.path.join(directory, basename) + os.makedirs(directory, exist_ok=True) filename_tmp = os.path.join(directory, '%s_new' % basename) with open(filename_tmp, 'w', encoding='utf-8') as fd: for pkg in sorted(dates): diff --git a/britney2/utils.py b/britney2/utils.py index bd640d2..1a886b2 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -299,7 +299,6 @@ def write_heidi_delta(filename, all_selected): fd.write('%s%s %s %s\n' % (prefix, item.package, item.version, item.architecture)) - def write_excuses(excuses, dest_file, output_format="yaml"): """Write the excuses to dest_file @@ -309,6 +308,7 @@ def write_excuses(excuses, dest_file, output_format="yaml"): """ excuselist = sorted(excuses.values(), key=lambda x: x.sortkey()) if output_format == "yaml": + os.makedirs(os.path.dirname(dest_file), exist_ok=True) with open(dest_file, 'w', encoding='utf-8') as f: edatalist = [e.excusedata(excuses) for e in excuselist] excusesdata = { @@ -317,6 +317,7 @@ def write_excuses(excuses, dest_file, output_format="yaml"): } f.write(yaml.dump(excusesdata, default_flow_style=False, allow_unicode=True)) elif output_format == "legacy-html": + os.makedirs(os.path.dirname(dest_file), exist_ok=True) with open(dest_file, 'w', encoding='utf-8') as f: f.write("\n") f.write("