Ejemplo n.º 1
0
    def mark_as_duplicated(self, silence=False):
        """
        Mark primary path as duplicated.

        If the target file if gone, the error is logged
        and the exception is silenced.
        """
        try:
            utils.mark_as_duplicated(self.primary_path)
        except OSError as e:
            logger.debug('The file is gone before marked as duplicated. %s' % e)
            if not silence: raise
Ejemplo n.º 2
0
    def handle_events(self, job_queue):
        while True:
            filepath = job_queue.get()
            logger.debug('Started handling event for %s' % filepath)

            try:
                attempt = checkin.get_attempt(filepath)

            except ValueError as e:
                try:
                    utils.mark_as_failed(filepath)
                except OSError as e:
                    logger.debug('The file is gone before marked as failed. %s' % e)

                logger.debug('Failed during checkin: %s: %s' % (filepath, e))

            except excepts.DuplicatedPackage as e:
                try:
                    utils.mark_as_duplicated(filepath)
                except OSError as e:
                    logger.debug('The file is gone before marked as duplicated. %s' % e)

            else:
                # Create a notification to keep track of the checkin process
                session = models.Session()
                checkin_notifier = self.CheckinNotifier(attempt, session)
                checkin_notifier.start()

                if attempt.is_valid:
                    notification_msg = 'Attempt ready to be validated'
                    notification_status = models.Status.ok
                else:
                    notification_msg = 'Attempt cannot be validated'
                    notification_status = models.Status.error

                checkin_notifier.tell(notification_msg, notification_status, 'Checkin')
                checkin_notifier.end()

                transaction.commit()

                #Send stream
                utils.send_message(self.stream, attempt, utils.make_digest)
                logging.debug('Message sent for %s: %s, %s' % (filepath,
                    repr(attempt), repr(utils.make_digest)))