Пример #1
0
    def operation(self):
        """
        Goal of this function is to check all the submission not
        finalized, and, if the expiration time sets in the context has
        been reached, then clean the submission_id along with the fields,
        and, if present, the uploaded folder/files.

        Second goal of this function, is to check all the InternalTip(s)
        and their expiration date, if match, remove that, all the folder,
        comment and tip related.

        Third goal of this function is to reset the exception counter that
        acts as limit for mail storm
        """
        try:
            # First Goal
            submissions = yield get_tiptime_by_marker(
                InternalTip._marker[0])  # Submission
            log.debug(
                "(Cleaning routines) %d unfinished Submission are check if expired"
                % len(submissions))
            for submission in submissions:
                if is_expired(ISO8601_to_datetime(submission['creation_date']),
                              GLSetting.defaults.submission_seconds_of_life):
                    log.info(
                        "Deleting an unfinalized Submission (creation %s expiration %s) files %d"
                        % (submission['creation_date'],
                           submission['expiration_date'], submission['files']))
                    yield itip_cleaning(submission['id'])

            # Second Goal
            tips = yield get_tiptime_by_marker(InternalTip._marker[2])  # First
            log.debug(
                "(Cleaning routines) %d Tips stored are check if expired" %
                len(tips))
            for tip in tips:
                if is_expired(ISO8601_to_datetime(tip['expiration_date'])):
                    log.info(
                        "Deleting an expired Tip (creation date: %s, expiration %s) files %d comments %d"
                        % (tip['creation_date'], tip['expiration_date'],
                           tip['files'], tip['comments']))
                    yield itip_cleaning(tip['id'])

            # Third Goal: Reset of GLSetting.exceptions
            GLSetting.exceptions = {}

        except Exception as excep:
            log.err(
                "Exception failure in submission/tip cleaning routine (%s)" %
                excep.message)
            sys.excepthook(*sys.exc_info())
Пример #2
0
    def test_put_postpone(self):
        now = datetime_now()

        yield self.force_itip_expiration()

        rtip_descs = yield self.get_rtips()

        for rtip_desc in rtip_descs:
            self.assertTrue(rtip_desc['expiration_date'] == '1970-01-01T00:00:00Z')
            operation = {
              'operation': 'postpone',
              'args': {}
            }

            handler = self.request(operation, role='receiver', user_id = rtip_desc['receiver_id'])
            yield handler.put(rtip_desc['id'])
            self.assertEqual(handler.request.code, 200)

        rtip_descs = yield self.get_rtips()
        for rtip_desc in rtip_descs:
            self.assertTrue(ISO8601_to_datetime(rtip_desc['expiration_date']) >= now)
Пример #3
0
 def ExpirationWatch(self):
     missing_time = ISO8601_to_datetime(
         self.data['tip']['expiration_date']) - datetime_now()
     missing_hours = int(divmod(missing_time.total_seconds(), 3600)[0])
     return str(missing_hours)
Пример #4
0
 def ExpirationDate(self):
     date = ISO8601_to_datetime(
         self.data['signup']['registration_date']) + timedelta(days=30)
     return datetime_to_pretty_str(date)