l.a.n.NascentUpload : class documentation

Part of lp.archiveuploader.nascentupload View In Hierarchy

Represents an upload being born. NascentUpload's responsibilities
are:

    1. Instantiating the ChangesFile and supplying to it the relevant
       context.
    2. Checking consistency of the upload in overall terms: given all
       present binaries, sources and other bits and pieces, does this
       upload "make sense"?
    2. Collecting errors and warnings that occurred while processing
       the upload.
    3. Checking signer ACL and keyring constraints.
    4. Creating state in the database once we've decided the upload
       is good, and throwing it away otherwise.
    5. Sending email to concerned individuals.

The collaborative international dictionary of English defines nascent as:

 1. Commencing, or in process of development; beginning to
    exist or to grow; coming into being; as, a nascent germ.
    [1913 Webster +PJC]

A nascent upload is thus in the process of coming into being. Specifically
a nascent upload is something we're trying to get into a shape we can
insert into the database as a queued upload to be processed.
Method __init__ Setup a NascentUpload for the given ChangesFile.
Class Method from_changesfile_path Create a NascentUpload from the given changesfile path.
Method process Process this upload, checking it against policy, loading it into
Method filename Return the changesfile name.
Method is_new Return true if any portion of the upload is NEW.
Method run_and_check_error Run the given callable and process errors and warnings.
Method run_and_collect_errors Run 'special' callable that generates a list of errors/warnings.
Method run_and_reject_on_error Run given callable and raise EarlyReturnUploadError on errors.
Method is_ppa Whether or not the current upload is target for a PPA.
Method getComponents Return a set of components present in the uploaded files.
Method reject Add the provided message to the rejection message.
Method rejection_message Aggregate rejection messages.
Method is_rejected Returns whether or not this upload was rejected.
Method warn Add the provided message to the warning message.
Method warning_message Aggregates warning messages.
Method verify_acl Check the signer's upload rights.
Method checkVersion Check if the proposed version is higher than the one in archive.
Method overrideSourceFile Overrides the uploaded source based on its override information.
Method overrideBinaryFile Overrides the uploaded binary based on its override information.
Method find_and_apply_overrides Look for ancestry and overrides information.
Method do_accept Accept the upload into the queue.
Method do_reject Reject the current upload given the reason provided.
Method storeObjectsInDatabase Insert this nascent upload into the database.
Method overrideArchive Override the archive set on the policy as necessary.
Method _check_overall_consistency Heuristics checks on upload contents and declared architecture.
Method _check_sourceful_consistency Heuristic checks on a sourceful upload.
Method _check_binaryful_consistency Heuristic checks on a binaryful upload.
Method _matchDDEBs Check and link DEBs and DDEBs in the upload.
Method _overrideDDEBSs Make sure that any DDEBs in the upload have the same overrides
Method _reject_with_logging Helper to reject an upload and log it using the logger function.
Method _createQueueEntry Return a PackageUpload object.
def __init__(self, changesfile, policy, logger):
Setup a NascentUpload for the given ChangesFile.
Parameterschangesfilethe ChangesFile object to be uploaded.
policythe upload policy to be used.
loggerthe logger to be used.
@classmethod
def from_changesfile_path(cls, changesfile_path, policy, logger):
Create a NascentUpload from the given changesfile path.

May raise UploadError due to unrecoverable problems building the ChangesFile object.

Parameterschangesfile_pathpath to the changesfile to be uploaded.
policythe upload policy to be used.
loggerthe logger to be used.
def process(self, build=None):
Process this upload, checking it against policy, loading it into the database if it seems okay.

No exceptions should be raised. In a few very unlikely events, an UploadError will be raised and sent up to the caller. If this happens the caller should call the reject method and process a rejection.

@property
def filename(self):
Return the changesfile name.
@property
def is_new(self):
Return true if any portion of the upload is NEW.
def _check_overall_consistency(self):
Heuristics checks on upload contents and declared architecture.

An upload may list 'powerpc' and 'all' in its architecture line and yet only upload 'powerpc' because of being built -B by a buildd. As a result, we use the think_* variables as a screen. If the files_X value is true then think_X must also be true. However nothing useful can be said of the other cases.

def _check_sourceful_consistency(self):
Heuristic checks on a sourceful upload.

Raises AssertionError when called for a non-sourceful upload. Ensures a sourceful upload has exactly one DSC. All further source checks are performed later by the DSC.

def _check_binaryful_consistency(self):
Heuristic checks on a binaryful upload.

It copes with mixed_uploads (source + binaries).

Check if the declared number of architectures corresponds to the upload contents.

def _matchDDEBs(self):
Check and link DEBs and DDEBs in the upload.

Matches each DDEB to its corresponding DEB, adding links in both directions. Unmatched or duplicated DDEBs result in upload errors.

This method is an error generator, i.e, it returns an iterator over all exceptions that are generated while processing all mentioned files.

def _overrideDDEBSs(self):
Make sure that any DDEBs in the upload have the same overrides as their counterpart DEBs. This method needs to be called after _matchDDEBS.

This is required so that domination can supersede both files in lockstep.

def run_and_check_error(self, callable):
Run the given callable and process errors and warnings.

UploadError(s) and UploadWarnings(s) are handled.

def run_and_collect_errors(self, callable):
Run 'special' callable that generates a list of errors/warnings.

The so called 'special' callables returns a generator containing all exceptions occurring during it's process.

Currently it is used for {NascentUploadFile, ChangesFile}.verify() method.

The rationale for this is that we want to collect as many errors/warnings as possible, instead of interrupting the checks when we find the first problem, when processing an upload.

This methodology helps to avoid retrying an upload multiple times because there are multiple problems.

def run_and_reject_on_error(self, callable):
Run given callable and raise EarlyReturnUploadError on errors.
@property
def is_ppa(self):
Whether or not the current upload is target for a PPA.
def getComponents(self):
Return a set of components present in the uploaded files.
def reject(self, msg):
Add the provided message to the rejection message.
@property
def rejection_message(self):
Aggregate rejection messages.
@property
def is_rejected(self):
Returns whether or not this upload was rejected.
def warn(self, msg):
Add the provided message to the warning message.
@property
def warning_message(self):
Aggregates warning messages.

Return a text header containing all the warnings raised during the upload processing or None, if no warnings were issued.

def verify_acl(self, build=None):
Check the signer's upload rights.

The signer must have permission to upload to either the component or the explicit source package, or in the case of a PPA must own it or be in the owning team.

def checkVersion(self, proposed_version, archive_version, filename):
Check if the proposed version is higher than the one in archive.
def overrideSourceFile(self, uploaded_file, override):
Overrides the uploaded source based on its override information.

Override target component and section.

def overrideBinaryFile(self, uploaded_file, override):
Overrides the uploaded binary based on its override information.

Override target component, section and priority.

def find_and_apply_overrides(self):
Look for ancestry and overrides information.

Anything not yet in the DB gets tagged as 'new' and won't count towards the permission check.

def do_accept(self, notify=True, build=None):
Accept the upload into the queue.

This MAY in extreme cases cause a database error and thus actually end up with a rejection being issued. This could occur, for example, if we have failed to validate the input sufficiently and something trips a database validation constraint.

ParametersnotifyTrue to send an email, False to not send one.
buildThe build associated with this upload.
def _reject_with_logging(self, error, notify, log_func):
Helper to reject an upload and log it using the logger function.
def do_reject(self, notify=True):
Reject the current upload given the reason provided.
def _createQueueEntry(self):
Return a PackageUpload object.
def storeObjectsInDatabase(self, build=None):
Insert this nascent upload into the database.
def overrideArchive(self):
Override the archive set on the policy as necessary.

In some circumstances we may wish to change the archive that the uploaded package is placed into based on various criteria. This includes decisions such as moving the package to the partner archive if the package's component is 'partner'.

Uploads with a mixture of partner and non-partner files will be rejected.

API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.