from .decorators import *
class AWS(base.Object):
+ def init(self):
+ self._session_args = {
+ "region_name" : self.settings.get("aws-region"),
+ "aws_access_key_id" : self.settings.get("aws-access-key"),
+ "aws_secret_access_key" : self.settings.get("aws-access-secret"),
+ }
+
@property
def session(self):
- return boto3.session.Session(
- region_name=self.settings.get("aws-region"),
- aws_access_key_id=self.settings.get("aws-access-key"),
- aws_secret_access_key=self.settings.get("aws-access-secret"),
- )
+ return boto3.session.Session(**self._session_args)
@property
def ec2(self):
"""
await self.build.build_repo.installcheck([self])
- def _installcheck(self, p):
+ async def _installcheck(self, p):
"""
Implementation that takes an active Pakfire instance and
performs a check on whether the source package can be installed
repo = p.get_repo("@commandline")
# Open the archive
- archive = p.open(self.pkg.path)
+ archive = await asyncio.to_thread(p.open, self.pkg.path)
# Fetch the package
package = archive.get_package(repo)
# Perform the installcheck
try:
- package.installcheck()
+ await asyncio.to_thread(package.installcheck)
# Store any dependency errors
except DependencyError as e:
created_at
""")
- async def create(self, *args, **kwargs):
+ async def create(self, comment, user=None):
"""
Creates a new key
"""
- return await asyncio.to_thread(self._create, *args, **kwargs)
-
- def _create(self, comment, user=None):
# Launch a new Pakfire instance
with self.backend.pakfire() as p:
# Generate the new key
# Create a new temporary space for the
with tempfile.TemporaryDirectory() as target:
# Create a new source package
- file = await asyncio.to_thread(
- self._update_source_package, build.pkg, target)
+ file = await self._update_source_package(build.pkg, target)
# Upload the file
upload = await self.backend.uploads.create_from_local(file)
self.build = build
self.repo = repo
- def _update_source_package(self, package, target):
+ async def _update_source_package(self, package, target):
"""
Takes a package and recreates it with this release
"""
# Create a Pakfire instance from this distribution
with self.monitoring.distro.pakfire() as p:
# Open the archive
- archive = p.open(package.path)
+ archive = await asyncio.to_thread(p.open, package.path)
# Extract the archive into the temporary space
- archive.extract(path=tmp)
+ await asyncio.to_thread(archive.extract, path=tmp)
# XXX directories are being created with the wrong permissions
os.system("chmod a+x -R %s" % tmp)
# Remove any downloaded files
- shutil.rmtree(files)
+ await asyncio.to_thread(shutil.rmtree, files)
# Update the makefile
- diff = self._update_makefile(makefile)
+ diff = await self._update_makefile(makefile)
# Log the diff
log.info("Generated diff:\n%s" % diff)
self._set_attribute("diff", diff)
# Generate a new source package
- return p.dist(makefile, target)
+ return await asyncio.to_thread(p.dist, makefile, target)
- def _update_makefile(self, path):
+ async def _update_makefile(self, path):
"""
Reads the makefile in path and updates it with the newer version
returning a diff between the two.
"""
Performs an installation check for all given jobs
"""
- return await asyncio.to_thread(self._installcheck, jobs)
-
- def _installcheck(self, jobs):
- """
- Implementation of installcheck which is performed on all given jobs.
- """
# We create a new context which allows us to enter many (but unknown) numbers of
# Pakfire instances at a time which leads to Pakfire only being initialized once
# per architecture. We are then able to run all dependency checks one after the
# Perform the check for the job
with self.db.transaction():
- if job._installcheck(p):
+ if await job._installcheck(p):
success = True
return success