当前位置: 首页>>代码示例>>Python>>正文


Python generic_app.main函数代码示例

本文整理汇总了Python中socorro.app.generic_app.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_exit_codes

    def test_exit_codes(self, logging):
        vsl = (ConfigFileFutureProxy, {'exit_code': 123})
        exit_code = main(ExitingApp, values_source_list=vsl)
        self.assertEqual(exit_code, 123)

        vsl = (ConfigFileFutureProxy, {'exit_code': 0})
        exit_code = main(ExitingApp, values_source_list=vsl)
        self.assertEqual(exit_code, 0)

        vsl = (ConfigFileFutureProxy, {'exit_code': None})
        exit_code = main(ExitingApp, values_source_list=vsl)
        self.assertEqual(exit_code, 0)
开发者ID:GabiThume,项目名称:socorro,代码行数:12,代码来源:test_generic_app.py

示例2: test_run_weeklyReportsPartitions

    def test_run_weeklyReportsPartitions(self):
        """Create a mock function named exactly like the stored procedure in
        the cron script we want to functionally test.
        That way we can assert that it was run.
        """

        # provide values for the config to pick up

        # be explicit about the values_source_list to
        # avoid configman picking up nosetests arguments
        main(WeeklyReportsPartitions, values_source_list=[DSN])

        # check that something was written to the mock_bucket
        cursor = self.conn.cursor()
        cursor.execute('select count(*) from mock_bucket;')
        self.assertTrue(cursor.fetchone())
开发者ID:Manchester412,项目名称:socorro,代码行数:16,代码来源:testWeeklyReportsPartitions.py

示例3: test_overriding_config_path

    def test_overriding_config_path(self, logging):
        vsl = (ConfigFileFutureProxy,)
        exit_code = main(MyApp, values_source_list=vsl)
        self.assertEqual(exit_code, 0)

        os.environ['DEFAULT_SOCORRO_CONFIG_PATH'] = '/foo/bar'
        self.assertRaises(IOError, main, (MyApp,), values_source_list=vsl)

        os.environ['DEFAULT_SOCORRO_CONFIG_PATH'] = self.tempdir
        exit_code = main(MyApp, values_source_list=vsl)
        self.assertEqual(exit_code, 0)

        logging.getLogger().error.assert_called_with('colour')

        _ini_file = os.path.join(self.tempdir, 'myapp.ini')
        with open(_ini_file, 'w') as f:
            f.write('color_or_colour=color\n')

        exit_code = main(MyApp, values_source_list=vsl)
        self.assertEqual(exit_code, 0)

        logging.getLogger().error.assert_called_with('color')
开发者ID:GabiThume,项目名称:socorro,代码行数:22,代码来源:test_generic_app.py

示例4: first

    needs a database connection because instead of doing an insert
    it just prints. However, it primes the connection by getting a cursor
    out first (otherwise it'd have to do it every time in a loo[).
    """

    def cursor(self):
        pass


class FTPScraperCronAppRunner(FTPScraperCronApp):  # pragma: no cover

    required_config = Namespace()
    required_config.add_option(
        'date',
        default=datetime.datetime.utcnow(),
        doc='Date to run for',
        from_string_converter='socorro.lib.datetimeutil.string_to_datetime'
    )

    def __init__(self, config):
        self.config = config
        self.config.dry_run = True

    def main(self):
        assert self.config.dry_run
        self.run(_MockConnection(), self.config.date)


if __name__ == '__main__':  # pragma: no cover
    sys.exit(main(FTPScraperCronAppRunner))
开发者ID:FishingCactus,项目名称:socorro,代码行数:30,代码来源:ftpscraper.py

示例5: WeeklyReportsPartitions

ekly-report-partitions
See https://bugzilla.mozilla.org/show_bug.cgi?id=701253
"""


class WeeklyReportsPartitions(App):
    app_name = 'weekly_reports_partitions'
    app_version = '0.1'
    app_description = __doc__

    required_config = Namespace()
    required_config.add_option('transaction_executor_class',
                               default=TransactionExecutorWithBackoff,
                               #default=TransactionExecutor,
                               doc='a class that will execute transactions')

    def run_query(self, connection):
        cursor = connection.cursor()
        cursor.execute('SELECT weekly_report_partitions()')

    def main(self):
        executor = self.config.transaction_executor_class(self.config)
        executor(self.run_query)
        # alternative use could be like this:
        # with self.config.transaction_executor_class(self.config) as connection:
        #    self.run_query(connection)


if __name__ == '__main__':  # pragma: no cover
    main(WeeklyReportsPartitions)
开发者ID:Manchester412,项目名称:socorro,代码行数:30,代码来源:weeklyReportsPartitions.py

示例6: len

        )

        # Verify data was correctly inserted.
        es_connection.refresh()
        total_indexed = es_connection.count(
            '*',
            index='socorro',
            doc_type='supersearch_fields',
        )['count']
        total_expected = len(all_fields)

        if total_expected != total_indexed:
            indexed_fields = es_connection.search(
                '*',
                index='socorro',
                doc_type='supersearch_fields',
                size=total_indexed,
            )
            indexed_fields = [x['_id'] for x in indexed_fields['hits']['hits']]

            self.config.logger.error(
                'The SuperSearch fields data was not correctly indexed, '
                '%s fields are missing from the database. Missing fields: %s',
                total_expected - total_indexed,
                list(set(all_fields.keys()) - set(indexed_fields))
            )


if __name__ == '__main__':
    generic_app.main(SetupSuperSearchApp)
开发者ID:linearregression,项目名称:socorro,代码行数:30,代码来源:setup_supersearch_app.py

示例7: processor2012


#.........这里部分代码省略.........

    # name: registrar.processor_id
    # doc: the id number for the processor (must already exist) (0 for create
    #      new Id, "auto" for autodetection, "host" for same host)
    # converter: str
    trans_config.registrar.processor_id = config.processorId

    # name: registrar.registrar_class
    # doc: the class that registers and tracks processors
    # converter: configman.converters.class_converter
    import socorro.processor.registration_client
    trans_config.registrar.registrar_class = \
        socorro.processor.registration_client.ProcessorAppRegistrationClient

    # name: registrar.transaction_executor_class
    # doc: a class that will manage transactions
    # converter: configman.converters.class_converter
    trans_config.registrar.transaction_executor_class = (
        socorro.database.transaction_executor
               .TransactionExecutorWithLimitedBackoff
    )

    # name: registrar.wait_log_interval
    # doc: seconds between log during retries
    # converter: int
    trans_config.registrar.wait_log_interval = 5

    #--------------------------------------------------------------------------
    # source -
    trans_config.source = DotDict()

    # name: source.backoff_delays
    # doc: delays in seconds between retries
    # converter: eval
    trans_config.source.backoff_delays = [10, 30, 60, 120, 300, 300, 300, 300,
                                          300, 300]

    # name: source.crashstorage_class
    # doc: the source storage class
    # converter: configman.converters.class_converter
    trans_config.source.crashstorage_class = \
        socorro.external.hbase.crashstorage.HBaseCrashStorage

    # name: source.forbidden_keys
    # doc: a comma delimited list of keys banned from the processed crash in
    #      HBase
    # converter: socorro.external.hbase.crashstorage.<lambda>
    trans_config.source.forbidden_keys = \
        ['email', 'url', 'user_id', 'exploitability']
    # name: source.hbase_host
    # doc: Host to HBase server
    # converter: str
    trans_config.source.hbase_host = config.hbaseHost

    # name: source.hbase_port
    # doc: Port to HBase server
    # converter: int
    trans_config.source.hbase_port = config.hbasePort

    # name: source.hbase_timeout
    # doc: timeout in milliseconds for an HBase connection
    # converter: int
    trans_config.source.hbase_timeout = config.hbaseTimeout

    # name: source.number_of_retries
    # doc: Max. number of retries when fetching from hbaseClient
    # converter: int
    trans_config.source.number_of_retries = 2

    # name: source.transaction_executor_class
    # doc: a class that will execute transactions
    # converter: configman.converters.class_converter
    trans_config.source.transaction_executor_class = (
        socorro.database.transaction_executor
               .TransactionExecutorWithLimitedBackoff
        )

    # name: source.wait_log_interval
    # doc: seconds between log during retries
    # converter: int
    trans_config.source.wait_log_interval = 5

    # name: destination.storage1.temporary_file_system_storage_path
    # doc: a local filesystem path dumps can be temporarily written
    #      for processing
    # converter: str
    trans_config.source.temporary_file_system_storage_path = \
        config.temporaryFileSystemStoragePath

    # name: destination.storage1.dump_file_suffix
    # doc: the suffix used to identify a dump file (for use in temp files)
    # converter: str
    trans_config.source.dump_file_suffix = config.dumpFileSuffix

    #--------------------------------------------------------------------------

    from socorro.app.generic_app import main
    from socorro.processor.processor_app import ProcessorApp

    main(ProcessorApp, [trans_config])
开发者ID:GabiThume,项目名称:socorro,代码行数:101,代码来源:startProcessor.py

示例8: get_index_for_date

            'fields': es_fields,
            'size': es_size,
            'from': es_from
        }
        return self.es_storage.es.search(
            es_query,
            index=index,
        )['hits']

    def get_index_for_date(self, date, index_format):
        """return the elasticsearch index for a date"""
        if not index_format:
            return None

        if '%' in index_format:
            return date.strftime(index_format)

        return index_format

    def index_crashes(self, es_index, crashes_to_index):
        self.es_storage.es.bulk_index(
            es_index,
            self.config.elasticsearch.elasticsearch_doctype,
            crashes_to_index,
            id_field='crash_id'
        )


if __name__ == '__main__':
    generic_app.main(ElasticsearchBackfillApp)
开发者ID:Earth4,项目名称:socorro,代码行数:30,代码来源:elasticsearch_backfill_app.py

示例9: Namespace

    app_name = 'example'
    app_version = '0.1'
    app_description = __doc__

    #--------------------------------------------------------------------------
    # in this section, define any configuration requirements
    required_config = Namespace()
    required_config.add_option('name',
                               default='Wilma',
                               doc='a name to echo')
    required_config.add_option('time',
                               default=datetime.datetime.now(),
                               doc='the time of day')

    #--------------------------------------------------------------------------
    # implementing this constructor is only necessary when there is more
    # initialization to be done before main can be called
    #def __init__(self, config):
        #super(ExampleApp,self).__init__(config)

    #--------------------------------------------------------------------------
    def main(self):
        # this is where we'd implement the app
        # the configuraton is already setup as self.config
        print 'hello, %s. The time is: %s' % (self.config.name,
                                              self.config.time)


if __name__ == '__main__':
    main(ExampleApp)
开发者ID:Manchester412,项目名称:socorro,代码行数:30,代码来源:example_app.py

示例10:

            cursor = pg_connection.cursor()

            sql = """
                SELECT email, last_sending
                FROM emails
                WHERE last_sending >= %s
            """
            cursor.execute(sql, (start_date,))
            results = cursor.fetchall()
            if not results:
                self.config.logger.info('No data in emails table in postgres')
                return

            for row in results:
                # self.config.logger.info('putting %s into ES' % row[0])
                if not row[0] or not row[0].strip():
                    continue

                es_connection.index(
                    index=self.config.elasticsearch.elasticsearch_emails_index,
                    doc_type='emails',
                    doc={
                        'last_sending': row[1]
                    },
                    id=row[0]
                )


if __name__ == '__main__':
    generic_app.main(MoveEmailsApp)
开发者ID:Earth4,项目名称:socorro,代码行数:30,代码来源:move_emails.py

示例11: class_with_partial_init

            self.config.services.services_controller.service_list
        ):
            services_list.append(
                # a tuple associating a URI with a service class
                (
                    uri,
                    # a binding of the service class with the configuration
                    # namespace for that service class
                    class_with_partial_init(
                        self.config.services[namespace]
                            .service_implementation_class,
                        self.config.services[namespace],
                        self.config
                    )
                )
            )

        # initialize the wsgi server with the list of URI/service impl tuples
        self.web_server = self.config.web_server.wsgi_server_class(
            self.config,  # needs the whole config not the local namespace
            services_list
        )

        # for modwsgi the 'run' method returns the wsgi function that the web
        # server will use.  For other webservers, the 'run' method actually
        # starts the standalone web server.
        application = self.web_server.run()

if __name__ == '__main__':
    main(CollectorApp)
开发者ID:nnethercote,项目名称:socorro,代码行数:30,代码来源:collector_app.py

示例12: in

        services_list = []
        # populate the 'services_list' with the tuples that will define the
        # urls and services offered by dataservice.
        for impl_class_namespace in (
            self.config.services.service_list.subordinate_namespace_names
        ):
            impl_class = self.config.services[impl_class_namespace].cls
            services_list.append(impl_class)

        if not services_list:
            raise RuntimeError(
                "No services configured."
                "See the [services].service_list setting in the config file"
            )

        self.web_server = self.config.web_server.wsgi_server_class(
            self.config,
            services_list
        )

        # for modwsgi the 'run' method returns the wsgi function that
        # will use.  For other webservers, the 'run' method actually starts
        # the standalone web server.
        application = self.web_server.run()


#==============================================================================
if __name__ == '__main__':
    main(DataserviceApp)
开发者ID:snorp,项目名称:socorro,代码行数:29,代码来源:dataservice_app.py

示例13: IntegrationTestAutomaticEmailsApp


class IntegrationTestAutomaticEmailsApp(generic_app.App):
    app_name = 'test_automatic_emails'
    app_version = '0.1'
    app_description = __doc__

    required_config = Namespace()
    required_config.add_option(
        'automatic_emails_class',
        default=AutomaticEmailsCronApp,
        doc='The class to use to send automatic emails.'
    )
    required_config.add_option(
        'tester_email_address',
        default='',
        doc='Send the automatic email to this address.'
    )

    def main(self):
        emailer = self.config.automatic_emails_class(self.config, '')

        report = {
            'email': self.config.tester_email_address,
        }

        print emailer.send_email(report)

if __name__ == '__main__':
    generic_app.main(IntegrationTestAutomaticEmailsApp)
开发者ID:GabiThume,项目名称:socorro,代码行数:28,代码来源:test_automatic_emails_app.py

示例14: import

import os
from socorro.app.generic_app import main
from socorro.middleware.middleware_app import MiddlewareApp
from socorro.webapi.servers import ApacheModWSGI
import socorro.middleware.middleware_app

from configman import (
    ConfigFileFutureProxy,
    environment
)

if os.path.isfile('/etc/socorro/middleware.ini'):
    config_path = '/etc/socorro'
else:
    config_path = ApacheModWSGI.get_socorro_config_path(__file__)

# invoke the generic main function to create the configman app class and which
# will then create the wsgi app object.
main(
    MiddlewareApp,  # the socorro app class
    config_path=config_path,
    values_source_list=[
        ConfigFileFutureProxy,
        environment
    ]
)

application = socorro.middleware.middleware_app.application
开发者ID:Earth4,项目名称:socorro,代码行数:28,代码来源:middleware.py

示例15: main

import os
from socorro.app.generic_app import main
from socorro.collector.collector_app import CollectorApp
from socorro.webapi.servers import ApacheModWSGI
import socorro.collector.collector_app

from configman import ConfigFileFutureProxy

if os.path.isfile('/etc/socorro/collector.ini'):
    config_path = '/etc/socorro'
else:
    config_path = ApacheModWSGI.get_socorro_config_path(__file__)

# invoke the generic main function to create the configman app class and which
# will then create the wsgi app object.
main(
    CollectorApp,  # the socorro app class
    config_path=config_path
)

application = socorro.collector.collector_app.application

开发者ID:JamJar,项目名称:socorro,代码行数:21,代码来源:collector.py


注:本文中的socorro.app.generic_app.main函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。