~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/hardwaredb/scripts/hwdbsubmissions.py

  • Committer: Abel Deuring
  • Date: 2011-09-13 14:47:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13946.
  • Revision ID: abel.deuring@canonical.com-20110913144712-kaf2u53te0f5gopp
transofrm reprocess-hwdb-submissions.py into a cronscript

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
UDEV_USB_TYPE_RE = re.compile('^[0-9]{1,3}/[0-9]{1,3}/[0-9]{1,3}$')
130
130
SYSFS_SCSI_DEVICE_ATTRIBUTES = set(('vendor', 'model', 'type'))
131
131
 
 
132
 
132
133
class SubmissionParser(object):
133
134
    """A Parser for the submissions to the hardware database."""
134
135
 
405
406
 
406
407
        :return: (name, (value, type)) of a property.
407
408
        """
408
 
        property_name = property_node.get('name')
409
409
        return (property_node.get('name'),
410
410
                self._getValueAndType(property_node))
411
411
 
1004
1004
                 the content.
1005
1005
        """
1006
1006
        self.submission_key = submission_key
1007
 
        submission_doc  = self._getValidatedEtree(submission, submission_key)
 
1007
        submission_doc = self._getValidatedEtree(submission, submission_key)
1008
1008
        if submission_doc is None:
1009
1009
            return None
1010
1010
 
1565
1565
                    'Invalid device path name: %r' % path_name,
1566
1566
                    self.submission_key)
1567
1567
                return False
1568
 
            for parent_path in path_names[path_index+1:]:
 
1568
            for parent_path in path_names[path_index + 1:]:
1569
1569
                if path_name.startswith(parent_path):
1570
1570
                    self.devices[parent_path].addChild(
1571
1571
                        self.devices[path_name])
2822
2822
            # SubmissionParser.checkUdevScsiProperties() ensures that
2823
2823
            # each SCSI device has a record in self.sysfs and that
2824
2824
            # the attribute 'vendor' exists.
2825
 
            path = self.udev['P']
2826
2825
            return self.sysfs['vendor']
2827
2826
        else:
2828
2827
            return None
2834
2833
            # SubmissionParser.checkUdevScsiProperties() ensures that
2835
2834
            # each SCSI device has a record in self.sysfs and that
2836
2835
            # the attribute 'model' exists.
2837
 
            path = self.udev['P']
2838
2836
            return self.sysfs['model']
2839
2837
        else:
2840
2838
            return None
3080
3078
                # further submissions in this batch raise an exception.
3081
3079
                self.transaction.commit()
3082
3080
 
 
3081
            self.start = submission.id + 1
3083
3082
            if self.max_submissions is not None:
3084
3083
                if self.max_submissions <= (
3085
3084
                    self.valid_submissions + self.invalid_submissions):
3113
3112
        submissions = removeSecurityProxy(submissions).find(
3114
3113
            HWSubmission.id >= self.start)
3115
3114
        submissions = list(submissions[:chunk_size])
3116
 
        if len(submissions) > 0:
3117
 
            self.start = submissions[-1].id + 1
3118
3115
        return submissions
3119
3116
 
3120
3117
 
3139
3136
        'Processed %i valid and %i invalid HWDB submissions'
3140
3137
        % (loop.valid_submissions, loop.invalid_submissions))
3141
3138
 
 
3139
 
3142
3140
def reprocess_invalid_submissions(start, transaction, logger,
3143
3141
                                  max_submissions=None, record_warnings=True):
3144
3142
    """Reprocess invalid submissions.
3160
3158
        'Processed %i valid and %i invalid HWDB submissions'
3161
3159
        % (loop.valid_submissions, loop.invalid_submissions))
3162
3160
    logger.info('last processed: %i' % loop.start)
 
3161
    return loop.start