Пример #1
0
 def run(self):
     buf = StringIO()
     writer = csv.writer(buf)
     writer.writerow((
         'debug_file',
         'debug_id',
         'code_file',
         'code_id',
     ))
     implementation = MissingSymbols(config=self.config)
     date = datetime.datetime.utcnow()
     date -= datetime.timedelta(hours=self.config.hours_back)
     rows = 0
     for each in implementation.iter(date=date.date()):
         writer.writerow((
             each['debug_file'],
             each['debug_id'],
             each['code_file'],
             each['code_id'],
         ))
         rows += 1
     s3 = self.config.boto_class(self.config)
     conn = s3._connect()
     self.config.logger.info(
         'Writing {} missing symbols rows to a file in {}'.format(
             format(rows, ','), self.config.bucket_name))
     bucket = s3._get_or_create_bucket(conn, self.config.bucket_name)
     key_object = bucket.new_key('latest.csv')
     key_object.set_contents_from_string(buf.getvalue())
     self.config.logger.info('Generated {} ({} bytes, {:.2f} Mb)'.format(
         key_object.generate_url(expires_in=0, query_auth=False),
         format(key_object.size, ','), key_object.size / 1024.0 / 1024.0))
Пример #2
0
    def test_iter(self):
        implementation = MissingSymbols(config=self.config)
        today = datetime.datetime.utcnow().date()
        res = implementation.iter(date=today)
        assert isinstance(res, types.GeneratorType)

        rows = sorted(list(res))  # run the generator into a list
        expected = sorted([
            {
                'debug_file': 'McBrwCtl.pdb',
                'debug_id': '133A2F3537E341A995D7C2BF8C3B2C663',
                'code_file': '',
                'code_id': '',
            },
            {
                'debug_file': 'msmpeg2vdec.pdb',
                'debug_id': '8515599DC90B4A01997BA2647DFE24941',
                'code_file': 'msmpeg2vdec.dll',
                'code_id': '54134E292c4000',
            },
        ])
        assert rows == expected
Пример #3
0
    def test_iter(self):
        implementation = MissingSymbols(config=self.config)
        today = datetime.datetime.utcnow().date()
        res = implementation.iter(date=today)
        ok_(isinstance(res, types.GeneratorType))

        rows = sorted(list(res))  # run the generator into a list
        expected = sorted([
            {
                'debug_file': 'McBrwCtl.pdb',
                'debug_id': '133A2F3537E341A995D7C2BF8C3B2C663',
                'code_file': '',
                'code_id': '',
            },
            {
                'debug_file': 'msmpeg2vdec.pdb',
                'debug_id': '8515599DC90B4A01997BA2647DFE24941',
                'code_file': 'msmpeg2vdec.dll',
                'code_id': '54134E292c4000',
            },
        ])
        eq_(rows, expected)
Пример #4
0
 def run(self):
     buf = StringIO()
     writer = csv.writer(buf)
     writer.writerow((
         'debug_file',
         'debug_id',
         'code_file',
         'code_id',
     ))
     implementation = MissingSymbols(config=self.config)
     date = datetime.datetime.utcnow()
     date -= datetime.timedelta(hours=self.config.hours_back)
     rows = 0
     for each in implementation.iter(date=date.date()):
         writer.writerow((
             each['debug_file'],
             each['debug_id'],
             each['code_file'],
             each['code_id'],
         ))
         rows += 1
     s3 = self.config.boto_class(self.config)
     conn = s3._connect()
     self.config.logger.info(
         'Writing {} missing symbols rows to a file in {}'.format(
             format(rows, ','),
             self.config.bucket_name
         )
     )
     bucket = s3._get_or_create_bucket(conn, self.config.bucket_name)
     key_object = bucket.new_key('latest.csv')
     key_object.set_contents_from_string(buf.getvalue())
     self.config.logger.info(
         'Generated {} ({} bytes, {:.2f} Mb)'.format(
             key_object.generate_url(expires_in=0, query_auth=False),
             format(key_object.size, ','),
             key_object.size / 1024.0 / 1024.0
         )
     )