• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python warnings.filterwarnings函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: django_tests

def django_tests(verbosity, interactive, failfast, test_labels):
    from django.conf import settings
    state = setup(verbosity, test_labels)
    extra_tests = []

    # Run the test suite, including the extra validation tests.
    from django.test.utils import get_runner
    if not hasattr(settings, 'TEST_RUNNER'):
        settings.TEST_RUNNER = 'django.test.runner.DiscoverRunner'
    TestRunner = get_runner(settings)

    test_runner = TestRunner(
        verbosity=verbosity,
        interactive=interactive,
        failfast=failfast,
    )
    # Catch warnings thrown in test DB setup -- remove in Django 1.9
    with warnings.catch_warnings():
        warnings.filterwarnings(
            'ignore',
            "Custom SQL location '<app_label>/models/sql' is deprecated, "
            "use '<app_label>/sql' instead.",
            PendingDeprecationWarning
        )
        failures = test_runner.run_tests(
            test_labels or get_installed(), extra_tests=extra_tests)

    teardown(state)
    return failures
开发者ID:kmalloc,项目名称:django,代码行数:29,代码来源:runtests.py


示例2: test_ccode_results_named_ordered

def test_ccode_results_named_ordered():
    x, y, z = symbols('x,y,z')
    B, C = symbols('B,C')
    A = MatrixSymbol('A', 1, 3)
    expr1 = Equality(A, Matrix([[1, 2, x]]))
    expr2 = Equality(C, (x + y)*z)
    expr3 = Equality(B, 2*x)
    name_expr = ("test", [expr1, expr2, expr3])
    expected = (
        '#include "test.h"\n'
        '#include <math.h>\n'
        'void test(double x, double *C, double z, double y, double *A, double *B) {\n'
        '   (*C) = z*(x + y);\n'
        '   A[0] = 1;\n'
        '   A[1] = 2;\n'
        '   A[2] = x;\n'
        '   (*B) = 2*x;\n'
        '}\n'
    )
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", category=SymPyDeprecationWarning)

        result = codegen(name_expr, "c", "test", header=False, empty=False,
                         argument_sequence=(x, C, z, y, A, B))
        source = result[0][1]
        assert source == expected
开发者ID:chiranthsiddappa,项目名称:sympy,代码行数:26,代码来源:test_codegen.py


示例3: log_likelihood_dataset

def log_likelihood_dataset(f, dataset, log_likelihood_datapoint, logger, ll_fun_wants_log_domain):
    """
    f : log-domain potentials
    ll_fun_wants_log_domain : whether or not the log-likelihood function needs f to be in log-domain (this is false only for the native chain LL implementation)
    """
    #print("f.dtype : %s" % f.dtype)
    #import hashlib
    #print("before " + str(int(hashlib.sha1(f.view(np.uint8)).hexdigest(), 16)))
    if not ll_fun_wants_log_domain:
        try:
            with warnings.catch_warnings():
                warnings.filterwarnings('error')
                f = np.exp(f) # changing semantics of f instead of inserting if's on edge_pot=... and node_pot=...
        except RuntimeWarning as rtw:
            logger.debug("RuntimeWarning: " + str(rtw))
    #print("after " + str(int(hashlib.sha1(f.view(np.uint8)).hexdigest(), 16)))
    ll = 0
    edge_pot = f[dataset.binaries]
#    print(dataset.binaries)
#    print(log_edge_pot)
    #assert(log_edge_pot.shape == (dataset.n_labels, dataset.n_labels))
    for n in range(dataset.N):
        node_pot = f[dataset.unaries[n]]
        ll_datapoint = log_likelihood_datapoint(node_pot, edge_pot, dataset.Y[n], dataset.object_size[n], dataset.n_labels) 
        # if (ll_datapoint >0):
            # info_string = ""
            # info_string += 'log_likelihood_datapoint as computed: %g\n' % ll_datapoint
            # info_string += 'n: %g\n' % n
            # info_string += 'node_pot.tolist(): %s\n' % node_pot.tolist()
            # info_string += 'edge_pot.tolist(): %s\n' % edge_pot.tolist()
            # info_string += 'dataset.Y[n]: %s\n' % dataset.Y[n].tolist()
            # raise Exception("positive log-likelihood is not allowed. More information:\n" + info_string)
        ll += ll_datapoint
        # in grid case, object_size will be ignored
    return ll # LL should not be scaled !
开发者ID:sebastien-bratieres,项目名称:pygpstruct,代码行数:35,代码来源:prepare_from_data.py


示例4: _suppress_scipy_warnings

def _suppress_scipy_warnings():
    # Infiltrate warnings if necessary
    numpy_ver = versions['numpy']
    scipy_ver = versions['scipy']
    # There is way too much deprecation warnings spit out onto the
    # user. Lets assume that they should be fixed by scipy 0.7.0 time
    if not __debug__ or (__debug__ and 'PY' not in debug.active):
        filter_lines = []
        if "0.6.0" <= scipy_ver and scipy_ver < "0.7.0" \
            and numpy_ver > "1.1.0":
            if __debug__:
                debug('EXT', "Setting up filters for numpy DeprecationWarnings "
                      "regarding scipy < 0.7.0")
            filter_lines += [
                ('NumpyTest will be removed in the next release.*',
                 DeprecationWarning),
                ('PyArray_FromDims: use PyArray_SimpleNew.',
                 DeprecationWarning),
                ('PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr.',
                 DeprecationWarning),
                # Trick re.match, since in warnings absent re.DOTALL in re.compile
                ('[\na-z \t0-9]*The original semantics of histogram is scheduled to be.*'
                 '[\na-z \t0-9]*', Warning) ]
        if scipy_ver >= "0.15":
            filter_lines += [("`scipy.weave` is deprecated, use `weave` instead!",
                              DeprecationWarning)]
        if scipy_ver >= "0.16":
            # scipy deprecated it but statsmodels still import it for now
            filter_lines += [("`scipy.linalg.calc_lwork` is deprecated!",
                              DeprecationWarning)]
        for f, w in filter_lines:
            warnings.filterwarnings('ignore', f, w)
开发者ID:VladimirBadalyan,项目名称:PyMVPA,代码行数:32,代码来源:externals.py


示例5: main

def main(argv):

    pd.set_option('display.width', 200)
    pd.set_option('display.height', 500)

    warnings.filterwarnings("ignore")

    global file_path, RMSLE_scorer

    # RMSLE_scorer
    RMSLE_scorer = metrics.make_scorer(RMSLE, greater_is_better = False)

    if(platform.system() == "Windows"):
        file_path = 'C:/Python/Others/data/Kaggle/Caterpillar_Tube_Pricing/'
    else:
        file_path = '/home/roshan/Desktop/DS/Others/data/Kaggle/Caterpillar_Tube_Pricing/'

########################################################################################################################
#Read the input file , munging and splitting the data to train and test
########################################################################################################################
    Train_DS      = pd.read_csv(file_path+'competition_data/train_set.csv',sep=',')
    Actual_DS     = pd.read_csv(file_path+'competition_data/test_set.csv',sep=',')
    Tube_DS       = pd.read_csv(file_path+'competition_data/tube.csv',sep=',')
    Bill_DS       = pd.read_csv(file_path+'competition_data/bill_of_materials.csv',sep=',')
    Spec_DS       = pd.read_csv(file_path+'competition_data/specs.csv',sep=',')
    Tube_End_DS   = pd.read_csv(file_path+'competition_data/tube_end_form.csv',sep=',')
    Comp_DS       = pd.read_csv(file_path+'competition_data/components_2.csv',sep=',')
    Sample_DS     = pd.read_csv(file_path+'sample_submission.csv',sep=',')


    Train_DS, Actual_DS, y =  Data_Munging(Train_DS,Actual_DS,Tube_DS,Bill_DS,Spec_DS,Tube_End_DS, Comp_DS)

    pred_Actual = RFR_Regressor(Train_DS, y, Actual_DS, Sample_DS, grid=False)
开发者ID:roshankr,项目名称:DS_Competition,代码行数:33,代码来源:CTP_v_04.py


示例6: __init__

	def __init__(self,path_to_corpora):
		## Built-in dictionary for word-parser, and path to corpora
		self.stopword = stopwords.words('english')
		self.path_to_corpora = path_to_corpora
		warnings.filterwarnings("ignore")
		print 'Initialize LDAModel....path to corpora : ',path_to_corpora

		## Hyperparameters for training model
		# Minimun length of single document
		self.min_length = 200
		# Num_topics in LDA
		self.num_topics = 90
		# Filter out tokens that appear in less than `no_below` documents (absolute number)
		self.no_below_this_number = 50
		# Filter out tokens that appear in more than `no_above` documents (fraction of total corpus size, *not* absolute number).
		self.no_above_fraction_of_doc = 0.2
		# Remove topic which weights less than this number
		self.remove_topic_so_less = 0.05
		# Number of iterations in training LDA model, the less the documents in total, the more the iterations for LDA model to converge
		self.num_of_iterations = 1000
		# Number of passes in the model
		self.passes = 3
		#Print all hyperparameters
		parameters = {}
		parameters['min_length'] = self.min_length
		parameters['num_topics'] = self.num_topics
		parameters['no_below_this_number'] = self.no_below_this_number
		parameters['no_above_fraction_of_doc'] = self.no_above_fraction_of_doc
		parameters['remove_topic_so_less'] = self.remove_topic_so_less
		parameters['num_of_iterations'] = self.num_of_iterations
		parameters['passes'] = self.passes
		for k in parameters:
		    print "Parameter for {0} is {1}".format(k,parameters[k])
		print 'Finished initializing....'
开发者ID:divanerd,项目名称:LDA_RecEngine,代码行数:34,代码来源:LDAModel_English.py


示例7: test_rcparams_init

def test_rcparams_init():
    with pytest.raises(ValueError):
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore',
                                message='.*(validate)',
                                category=UserWarning)
            mpl.RcParams({'figure.figsize': (3.5, 42, 1)})
开发者ID:jklymak,项目名称:matplotlib,代码行数:7,代码来源:test_rcparams.py


示例8: get_build_from_file

def get_build_from_file (platform, file_name, name):
    gub_name = file_name.replace (os.getcwd () + '/', '')
    logging.verbose ('reading spec: %(gub_name)s\n' % locals ())
    # Ugh, FIXME
    # This loads gub/specs/darwin/python.py in PYTHON. namespace,
    # overwriting the PYTHON. namespace from gub/specs/python.py
    # Current workaround: always/also use __darwin etc. postfixing
    # of class names, also in specs/darwin/ etc.
    warnings.filterwarnings ('ignore', '''Parent module 'python-2' ''')
    module = misc.load_module (file_name, name)
    # cross/gcc.py:Gcc will be called: cross/Gcc.py,
    # to distinguish from specs/gcc.py:Gcc.py
    base = os.path.basename (name)
    class_name = ((base[0].upper () + base[1:])
                  .replace ('-', '_')
                  .replace ('.', '_')
                  .replace ('++', '_xx_')
                  .replace ('+', '_x_')
                  + ('-' + platform).replace ('-', '__'))
    logging.debug ('LOOKING FOR: %(class_name)s\n' % locals ())
    cls = misc.most_significant_in_dict (module.__dict__, class_name, '__')
    if (platform == 'tools32'
        and (not cls or issubclass (cls, target.AutoBuild))):
        cls = misc.most_significant_in_dict (module.__dict__, class_name.replace ('tools32', 'tools'), '__')
    if ((platform == 'tools' or platform == 'tools32')
        and (issubclass (cls, target.AutoBuild)
             and not issubclass (cls, tools.AutoBuild)
             and not issubclass (cls, tools32.AutoBuild))):
        cls = None
    return cls
开发者ID:alepharchives,项目名称:gub,代码行数:30,代码来源:dependency.py


示例9: test_5_save_host_keys

    def test_5_save_host_keys(self):
        """
        verify that SSHClient correctly saves a known_hosts file.
        """
        warnings.filterwarnings('ignore', 'tempnam.*')

        host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key'))
        public_host_key = paramiko.RSAKey(data=host_key.asbytes())
        fd, localname = mkstemp()
        os.close(fd)

        client = paramiko.SSHClient()
        self.assertEquals(0, len(client.get_host_keys()))

        host_id = '[%s]:%d' % (self.addr, self.port)

        client.get_host_keys().add(host_id, 'ssh-rsa', public_host_key)
        self.assertEquals(1, len(client.get_host_keys()))
        self.assertEquals(public_host_key, client.get_host_keys()[host_id]['ssh-rsa'])

        client.save_host_keys(localname)

        with open(localname) as fd:
            assert host_id in fd.read()

        os.unlink(localname)
开发者ID:RishYang,项目名称:paramiko,代码行数:26,代码来源:test_client.py


示例10: test_tmpnam

    def test_tmpnam(self):
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
                                    r"test_os$")
            warnings.filterwarnings("ignore", "tmpnam", DeprecationWarning)

            name = os.tmpnam()
            if sys.platform in ("win32",):
                # The Windows tmpnam() seems useless.  From the MS docs:
                #
                #     The character string that tmpnam creates consists of
                #     the path prefix, defined by the entry P_tmpdir in the
                #     file STDIO.H, followed by a sequence consisting of the
                #     digit characters '0' through '9'; the numerical value
                #     of this string is in the range 1 - 65,535.  Changing the
                #     definitions of L_tmpnam or P_tmpdir in STDIO.H does not
                #     change the operation of tmpnam.
                #
                # The really bizarre part is that, at least under MSVC6,
                # P_tmpdir is "\\".  That is, the path returned refers to
                # the root of the current drive.  That's a terrible place to
                # put temp files, and, depending on privileges, the user
                # may not even be able to open a file in the root directory.
                self.assertFalse(os.path.exists(name),
                            "file already exists for temporary file")
            else:
                self.check_tempfile(name)
开发者ID:RDWang,项目名称:python,代码行数:27,代码来源:test_os.py


示例11: test_norm_hash_name

    def test_norm_hash_name(self):
        "test norm_hash_name()"
        from itertools import chain
        from passlib.utils.pbkdf2 import norm_hash_name, _nhn_hash_names

        # test formats
        for format in self.ndn_formats:
            norm_hash_name("md4", format)
        self.assertRaises(ValueError, norm_hash_name, "md4", None)
        self.assertRaises(ValueError, norm_hash_name, "md4", "fake")

        # test types
        self.assertEqual(norm_hash_name(u("MD4")), "md4")
        self.assertEqual(norm_hash_name(b("MD4")), "md4")
        self.assertRaises(TypeError, norm_hash_name, None)

        # test selected results
        with catch_warnings():
            warnings.filterwarnings("ignore", ".*unknown hash")
            for row in chain(_nhn_hash_names, self.ndn_values):
                for idx, format in enumerate(self.ndn_formats):
                    correct = row[idx]
                    for value in row:
                        result = norm_hash_name(value, format)
                        self.assertEqual(result, correct, "name=%r, format=%r:" % (value, format))
开发者ID:BlackieXS,项目名称:neo4j-flask,代码行数:25,代码来源:test_utils_crypto.py


示例12: test_warnings_on_cleanup

    def test_warnings_on_cleanup(self) -> None:
        # Two kinds of warning on shutdown
        #   Issue 10888: may write to stderr if modules are nulled out
        #   ResourceWarning will be triggered by __del__
        with self.do_create() as dir:
            if os.sep != '\\':
                # Embed a backslash in order to make sure string escaping
                # in the displayed error message is dealt with correctly
                suffix = '\\check_backslash_handling'
            else:
                suffix = ''
            d = self.do_create(dir=dir, suf=suffix)

            #Check for the Issue 10888 message
            modules = [os, os.path]
            if has_stat:
                modules.append(stat)
            with support.captured_stderr() as err:
                with NulledModules(*modules):
                    d.cleanup()
            message = err.getvalue().replace('\\\\', '\\')
            self.assertIn("while cleaning up",  message)
            self.assertIn(d.name,  message)

            # Check for the resource warning
            with support.check_warnings(('Implicitly', ResourceWarning), quiet=False):
                warnings.filterwarnings("always", category=ResourceWarning)
                d.__del__()
            self.assertFalse(os.path.exists(d.name),
                        "TemporaryDirectory %s exists after __del__" % d.name)
开发者ID:FlorianLudwig,项目名称:mypy,代码行数:30,代码来源:test_tempfile.py


示例13: test_N_put_without_confirm

    def test_N_put_without_confirm(self):
        """
        verify that get/put work without confirmation.
        """
        warnings.filterwarnings('ignore', 'tempnam.*')

        """
        localname = os.tempnam()
        text = 'All I wanted was a plastic bunny rabbit.\n'
        f = open(localname, 'wb')
        f.write(text)
        f.close()
        """

        text = b'All I wanted was a plastic bunny rabbit.\n'

        f = tempfile.NamedTemporaryFile(delete=False)
        localname = f.name
        f.write(text)
        f.close()

        saved_progress = []
        def progress_callback(x, y):
            saved_progress.append((x, y))
        res = sftp.put(localname, FOLDER + '/bunny.txt', progress_callback, False)

        self.assertEquals(SFTPAttributes().attr, res.attr)

        f = sftp.open(FOLDER + '/bunny.txt', 'r')
        self.assertEquals(text, f.read(128))
        f.close()
        self.assertEquals((41, 41), saved_progress[-1])

        os.unlink(localname)
        sftp.unlink(FOLDER + '/bunny.txt')
开发者ID:jonConerly,项目名称:paramiko,代码行数:35,代码来源:test_sftp.py


示例14: request

    def request(self, method, amp, path='/', **kwargs):
        LOG.debug("request url %s", path)
        _request = getattr(self.session, method.lower())
        _url = self._base_url(amp.lb_network_ip) + path
        LOG.debug("request url " + _url)
        timeout_tuple = (CONF.haproxy_amphora.rest_request_conn_timeout,
                         CONF.haproxy_amphora.rest_request_read_timeout)
        reqargs = {
            'verify': CONF.haproxy_amphora.server_ca,
            'url': _url,
            'timeout': timeout_tuple, }
        reqargs.update(kwargs)
        headers = reqargs.setdefault('headers', {})

        headers['User-Agent'] = OCTAVIA_API_CLIENT
        self.ssl_adapter.uuid = amp.id
        # Keep retrying
        for a in six.moves.xrange(CONF.haproxy_amphora.connection_max_retries):
            try:
                with warnings.catch_warnings():
                    warnings.filterwarnings(
                        "ignore",
                        message="A true SSLContext object is not available"
                    )
                    r = _request(**reqargs)
            except (requests.ConnectionError, requests.Timeout):
                LOG.warning(_LW("Could not connect to instance. Retrying."))
                time.sleep(CONF.haproxy_amphora.connection_retry_interval)
                if a == CONF.haproxy_amphora.connection_max_retries - 1:
                    raise driver_except.TimeOutException()
            else:
                return r
        raise driver_except.UnavailableException()
开发者ID:evanscottgray,项目名称:octavia,代码行数:33,代码来源:rest_api_driver.py


示例15: capture_glib_warnings

def capture_glib_warnings(allow_warnings=False, allow_criticals=False):
    """Temporarily suppress glib warning output and record them.

    The test suite is run with G_DEBUG="fatal-warnings fatal-criticals"
    by default. Setting allow_warnings and allow_criticals will temporarily
    allow warnings or criticals without terminating the test run.
    """

    old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags(0))

    new_mask = old_mask
    if allow_warnings:
        new_mask &= ~GLib.LogLevelFlags.LEVEL_WARNING
    if allow_criticals:
        new_mask &= ~GLib.LogLevelFlags.LEVEL_CRITICAL

    GLib.log_set_always_fatal(GLib.LogLevelFlags(new_mask))

    GLibWarning = gi._gi._gobject.Warning
    try:
        with warnings.catch_warnings(record=True) as warn:
            warnings.filterwarnings('always', category=GLibWarning)
            yield warn
    finally:
        GLib.log_set_always_fatal(old_mask)
开发者ID:Distrotech,项目名称:pygobject,代码行数:25,代码来源:helper.py


示例16: main

def main():

    warnings.filterwarnings("ignore", "Degrees of freedom <= 0 for slice", RuntimeWarning)

    options = getoptions()

    setuplogger(options['log'], options['logfile'], logging.INFO)

    total_procs = options['nprocs'] * options['total_instances']
    start_offset = options['instance_id'] * options['nprocs']

    exit_code = 0

    if options['nprocs'] == 1:
        createsummary(options, None, None)
    else:
        proclist = []
        for procid in xrange(options['nprocs']):
            p = Process( target=createsummary, args=(options, total_procs, start_offset + procid) )
            p.start()
            proclist.append(p)

        for proc in proclist:
            proc.join()
            exit_code += proc.exitcode

    sys.exit(exit_code)
开发者ID:ubccr,项目名称:tacc_stats,代码行数:27,代码来源:process.py


示例17: setUp

    def setUp(self):
        self.warn_filters = warnings.filters
        warnings.filterwarnings('ignore',
                                category=FutureWarning,
                                module=".*format")

        self.frame = _frame.copy()
开发者ID:c0state,项目名称:pandas,代码行数:7,代码来源:test_format.py


示例18: main

def main(argv=None, interactive=True):
    """
    Entry point for setup.py.

    Wrapper for a profiler if requested otherwise just call run() directly.
    If profiling is enabled we disable interactivity as it would wait for user
    input and influence the statistics. However the -r option still works.
    """
    # catch and ignore a NumPy deprecation warning
    with warnings.catch_warnings(record=True):
        warnings.filterwarnings(
            "ignore", 'The compiler package is deprecated and removed in '
            'Python 3.x.', DeprecationWarning)
        np.safe_eval('1')

    if '-p' in sys.argv or '--profile' in sys.argv:
        try:
            import cProfile as Profile
        except ImportError:
            import Profile
        Profile.run('from obspy.scripts.runtests import run; run()',
                    'obspy.pstats')
        import pstats
        stats = pstats.Stats('obspy.pstats')
        print()
        print("Profiling:")
        stats.sort_stats('cumulative').print_stats('obspy.', 20)
        print(PSTATS_HELP)
    else:
        errors = run(argv, interactive)
        if errors:
            sys.exit(1)
开发者ID:petrrr,项目名称:obspy,代码行数:32,代码来源:runtests.py


示例19: load_mysql

    def load_mysql(self, model, csv_path):
        import warnings
        import MySQLdb
        warnings.filterwarnings("ignore", category=MySQLdb.Warning)

        # Flush the target model
        self.cursor.execute('TRUNCATE TABLE %s' % model._meta.db_table)

        # Build the MySQL LOAD DATA INFILE command
        bulk_sql_load_part_1 = """
            LOAD DATA LOCAL INFILE '%s'
            INTO TABLE %s
            FIELDS TERMINATED BY ','
            OPTIONALLY ENCLOSED BY '"'
            LINES TERMINATED BY '\\n'
            IGNORE 1 LINES
            (
        """ % (
            csv_path,
            model._meta.db_table
        )

        # Get the headers and the row count from the source CSV
        csv_headers = self.get_headers(csv_path)
        csv_record_cnt = self.get_row_count(csv_path)

        header_sql_list = []
        field_types = dict(
            (f.db_column, f.db_type(self.connection))
            for f in model._meta.fields
        )
        date_set_list = []

        for h in csv_headers:
            # Pull the data type of the field
            data_type = field_types[h]
            # If it is a date field, we need to reformat the data
            # so that MySQL will properly parse it on the way in.
            if data_type == 'date':
                header_sql_list.append('@`%s`' % h)
                date_set_list.append(
                    "`%s` =  %s" % (h, self.date_sql % h)
                )
            elif data_type == 'datetime':
                header_sql_list.append('@`%s`' % h)
                date_set_list.append(
                    "`%s` =  %s" % (h, self.datetime_sql % h)
                )
            else:
                header_sql_list.append('`%s`' % h)

        bulk_sql_load = bulk_sql_load_part_1 + ','.join(header_sql_list) + ')'
        if date_set_list:
            bulk_sql_load += " set %s" % ",".join(date_set_list)

        # Run the query
        cnt = self.cursor.execute(bulk_sql_load)

        # Report back on how we did
        self.finish_load_message(cnt, csv_record_cnt)
开发者ID:caciviclab,项目名称:django-calaccess-raw-data,代码行数:60,代码来源:loadcalaccessrawfile.py


示例20: init

def init(format_prefix="", output_mode=OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path=DEFAULT_LOGFILE_PATH):
    if output_mode == "/dev/null":
        assert output_mode != OutputMode.LOGFILE, "Must enable a logging mode."
        output_mode = OutputMode.CONSOLE

    # Start with the default
    logging.config.dictConfig( get_default_config( format_prefix, output_mode, logfile_path ) )
    
    # Update from the user's customizations
    loggingHelpers.updateFromConfigFile()
    
    # Capture warnings from the warnings module
    logging.captureWarnings(True)
    
    # Warnings module warnings are shown only once
    warnings.filterwarnings("once")

    # Don't warn about pending deprecations (PyQt generates some of these)
    warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
    
    # Custom format for warnings
    def simple_warning_format(message, category, filename, lineno, line=None):
        filename = os.path.split(filename)[1]
        return filename + "(" + str(lineno) + "): " + category.__name__ + ": " + message[0]

    warnings.formatwarning = simple_warning_format
开发者ID:CVML,项目名称:ilastik,代码行数:26,代码来源:default_config.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python warnings.formatwarning函数代码示例发布时间:2022-05-26
下一篇:
Python warnings.catch_warnings函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap