diff --git a/ci/jobgenerator.py b/ci/jobgenerator.py index 4c44972..1a6a24f 100755 --- a/ci/jobgenerator.py +++ b/ci/jobgenerator.py @@ -46,6 +46,7 @@ class Generator: if not metadata_url or not metadata_repo_name: raise ValueError("METADATA_URL and METADATA_REPO_NAME must be set") + metadata_loc = None # Create a temporary directory in the most secure manner possible and # clone the metadata, throwing the directory away when we're done try: @@ -59,7 +60,10 @@ class Generator: with open(config_file) as metadata_conf_file: metadata_conf = yaml_load(metadata_conf_file, Loader=CLoader) finally: - rmtree(metadata_loc) + if metadata_loc: + rmtree(metadata_loc) + else: + pass return metadata_conf @@ -127,12 +131,14 @@ class Generator: template += text template = Template(template) - if data: + if data is not None: url = data["packaging_url"] u_branch = data["packaging_branch_unstable"] s_branch = data["packaging_branch_stable"] u_upload_target = data["upload_target_unstable"] s_upload_target = data["upload_target_stable"] + else: + raise AttributeError("Data cannot be empty, cannot parse job data.") if job_type.startswith("package"): upstream = data["upstream_url"] diff --git a/ci/lp_check.py b/ci/lp_check.py index b8a606a..2b2261c 100755 --- a/ci/lp_check.py +++ b/ci/lp_check.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import argparse -import launchpadlib from time import sleep from launchpadlib.launchpad import Launchpad @@ -49,10 +48,14 @@ class LaunchpadCheck: lp = self.login() # Grab the correct PPA object + ppa = None for ippa in lp.people[self.lp_person].ppas: if ippa.name == self.ppa_name: ppa = ippa + if ppa is None: + raise ValueError("No PPA information available for package or package version.") + # We're verifying every five minutes; never go to more than two hours # (60 minutes × 2 hours) ÷ 5 minutes = 24 max iterations for i in range(0, 24): @@ -126,5 +129,6 @@ class LaunchpadCheck: # If we've timed out, raise an error raise ValueError("Timed out, contact Launchpad admins") + if __name__ == "__main__": lpcheck = LaunchpadCheck() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c0da230 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +launchpadlib +jinja2 +jenkinsapi +GitPython +PyYAML \ No newline at end of file