Multiple issues fixed.

- Variable use before assignment
- Unhandled edge cases where variables referenced may not have the subdata/indexes requested
- try/catch fixes where 'finally' references a variable that might not exist
- Unnecessary imports
- Added requirements.txt file with base module requirements (without version specificity at this time)
master
Thomas Ward 5 years ago
parent b379ebb20d
commit f7e731faae
Signed by: teward
GPG Key ID: 5B8AD6F4C26ADDDD

@ -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"]

@ -16,7 +16,6 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
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()

@ -0,0 +1,5 @@
launchpadlib
jinja2
jenkinsapi
GitPython
PyYAML
Loading…
Cancel
Save