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

Python utils.warn函数代码示例

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

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



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

示例1: readDXF

def readDXF(filename):
    """Read a DXF file and extract the recognized entities.

    `filename`: name of a .DXF file.

    Returns a multiline string with one line for each recognized entity,
    in a format that can directly be used by :func:`convertDXF`.
    
    This function requires the external program `dxfparser` which comes
    with the pyFormex distribution. It currently recognizes entities of
    type 'Arc', 'Line', 'Polyline', 'Vertex'.
    """
    import utils,commands
    print(filename)
    if utils.hasExternal('dxfparser'):
        cmd = 'pyformex-dxfparser %s 2>/dev/null' % filename
        print(cmd)
        sta,out = utils.runCommand(cmd)
        if sta==0:
            return out
        else:
            return ''
    else:
        utils.warn('warn_no_dxfparser')
        return ''
开发者ID:dladd,项目名称:pyFormex,代码行数:25,代码来源:dxf.py


示例2: verify_plugin_settings

    def verify_plugin_settings(self):
        puts("Verifying settings requested by plugins...")

        missing_settings = False
        missing_setting_error_messages = []
        with indent(2):
            for name, meta in self.required_settings_from_plugins.items():
                if not hasattr(settings, name):
                    error_message = (
                        "%(setting_name)s is missing. It's required by the"
                        "%(plugin_name)s plugin's '%(function_name)s' method."
                    ) % meta
                    puts(colored.red("✗ %(setting_name)s" % meta))
                    missing_setting_error_messages.append(error_message)
                    missing_settings = True
                else:
                    show_valid("%(setting_name)s" % meta)

            if missing_settings:
                puts("")
                warn(
                    "Will is missing settings required by some plugins. "
                    "He's starting up anyway, but you will run into errors"
                    " if you try to use those plugins!"
                )
                self.add_startup_error("\n".join(missing_setting_error_messages))
            else:
                puts("")
开发者ID:AirbornePorcine,项目名称:will,代码行数:28,代码来源:main.py


示例3: tvnamer

def tvnamer(paths):
    """Main tvnamer function, takes an array of paths, does stuff.
    """
    # Warn about move_files function
    if Config['move_files_enable']:
        import warnings
        warnings.warn("The move_files feature is still under development. "
            "Be very careful with it.\n"
            "It has not been heavily tested, and is not recommended for "
            "general use yet.")

    if Config['force_name'] is not None:
        import warnings
        warnings.warn("The --name argument is a temporary solution, and will"
            "be removed at some point in the future. Do no depend on it")

    p("#" * 20)
    p("# Starting tvnamer")

    episodes_found = []

    for cfile in findFiles(paths):
        parser = FileParser(cfile)
        try:
            episode = parser.parse()
        except InvalidFilename, e:
            warn("Invalid filename: %s" % e)
        else:
            if episode.seriesname is None:
                warn("Parsed filename did not contain series name, skipping: %s" % cfile)
            else:
                episodes_found.append(episode)
开发者ID:oracal,项目名称:tvnamer,代码行数:32,代码来源:main.py


示例4: syslog

def syslog(message, tag='cvs_check', priority='local0.warn'):
    """Add the given entry to the syslog file.

    PARAMETERS
        message: The message to file.
        tag: Mark every line in the log with the specified tag.
        priority: Enter the message with the specified priority.
    """
    logger_exe = 'logger'
    if 'GIT_HOOKS_LOGGER' in environ:
        logger_exe = environ['GIT_HOOKS_LOGGER']

    p = Popen([logger_exe, '-t', tag, '-p', priority, message],
              stdout=PIPE, stderr=STDOUT)
    out, _ = p.communicate()
    if p.returncode != 0:
        info = (['Failed to file the following syslog entry:',
                 '  - message: %s' % message,
                 '  - tag: %s' % tag,
                 '  - priority: %s' % priority,
                 '',
                 'logger returned with error code %d:' % p.returncode]
                + out.splitlines())
        warn(*info)

    elif out.rstrip():
        print out.rstrip()
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:27,代码来源:syslog.py


示例5: tvnamer

def tvnamer(paths):
    """Main tvnamer function, takes an array of paths, does stuff.
    """
    print "#" * 20
    print "# Starting tvnamer"

    episodes_found = []

    for cfile in findFiles(paths):
        parser = FileParser(cfile)
        try:
            episode = parser.parse()
        except InvalidFilename:
            warn("Invalid filename %s" % cfile)
        else:
            episodes_found.append(episode)

    if len(episodes_found) == 0:
        raise NoValidFilesFoundError()

    print "# Found %d episodes" % len(episodes_found)

    tvdb_instance = Tvdb(
        interactive=not Config['selectfirst'],
        debug = Config['verbose'],
        search_all_languages = Config['search_all_languages'],
        language = Config['language'])

    for episode in episodes_found:
        processFile(tvdb_instance, episode)
        print

    print "#" * 20
    print "# Done"
开发者ID:minrk,项目名称:tvnamer,代码行数:34,代码来源:main.py


示例6: track_module

def track_module(module):
	dependency_map = {}
	include_stack = collections.OrderedDict()
	included_dirs = set()
	for source, ext, _ in module.source_files():
		dependency_map[source] = (track_file(module, source, included_dirs, include_stack), ext)
	for dep in module.private_required:
		ok = False
		for d in dep.public_includes:
			if d in included_dirs:
				ok = True
				break
		if not ok:
			utils.warn("Module %s: Useless dependency '%s'" % (module.name, dep.name))
	included_dirs = set()
	for header, ext, _ in module.header_files():
		dependency_map[header] = (track_file(module, header, included_dirs, include_stack), ext)
	for dep in module.public_required:
		ok = False
		for d in dep.public_includes:
			if d in included_dirs:
				ok = True
				break
		if not ok:
			utils.warn("Module %s: Dependency '%s' should be private" % (module.name, dep.name))
	return dependency_map
开发者ID:Julow,项目名称:makemake,代码行数:26,代码来源:dependency_finder.py


示例7: __init__

    def __init__(self, *args, **kwargs):
        self.__dict__ = self.__shared_state

        if not getattr(self, 'initialised', False):
            self.initialised = True

            self.timestamp = time.strftime("%Y%m%d%H%M%S")

            cnf = Config()
            if cnf.has_key("Dir::UrgencyLog"):
                # Create the log directory if it doesn't exist
                self.log_dir = cnf["Dir::UrgencyLog"]

                if not os.path.exists(self.log_dir) or not os.access(self.log_dir, os.W_OK):
                    warn("UrgencyLog directory %s does not exist or is not writeable, using /srv/ftp.debian.org/tmp/ instead" % (self.log_dir))
                    self.log_dir = '/srv/ftp.debian.org/tmp/'

                # Open the logfile
                self.log_filename = "%s/.install-urgencies-%s.new" % (self.log_dir, self.timestamp)
                self.log_file = open_file(self.log_filename, 'w')

            else:
                self.log_dir = None
                self.log_filename = None
                self.log_file = None

            self.writes = 0
开发者ID:abhi11,项目名称:dak,代码行数:27,代码来源:urgencylog.py


示例8: Minimize

def Minimize(func, h, points):
    n = len(points)
    if n > 2000:
        #raise ValueError("Too many points for Cross Validation, limit is 2000")
        msg = "Too many points for Cross Validation, limit is 2000, using 0.7 * hRef."
        utils.warn(msg)
        return 0.7*h
    
    allSquaredDistances = DistancesSquared(points)

    min_percent = 0.05
    max_percent = 2.00
    step_percent = 0.10
    h1 = Search(func, allSquaredDistances, n, h, min_percent, max_percent, step_percent)
    if h1 <= min_percent * h or h1 >= max_percent * h:
        # then it is the min or max value checked
        msg = "Cross Validation using "+func.__name__+" failed to minimize, using 0.7 * hRef."
        utils.warn(msg)
        return 0.7*h
#    return h1
    #print h1
    h2 = Search(func, allSquaredDistances, n, h1, 0.89, 1.11, 0.01)
    #print h2
    h3 = Search(func, allSquaredDistances, n, h2, 0.989, 1.011, 0.001)
    return h3
开发者ID:FabianUx,项目名称:AnimalMovement,代码行数:25,代码来源:UD_SmoothingFactor.py


示例9: doMoveFile

def doMoveFile(cnamer, destDir = None, destFilepath = None, getPathPreview = False):
    """Moves file to destDir, or to destFilepath
    """

    if (destDir is None and destFilepath is None) or (destDir is not None and destFilepath is not None):
        raise ValueError("Specify only destDir or destFilepath")

    if not (Config['move_files_enable'] or Config['link_files_enable']):
        raise ValueError("move_files feature is disabled but doMoveFile was called")

    if Config['move_files_destination'] is None:
        raise ValueError("Config value for move_files_destination cannot be None if move_files_enabled is True")

    try:
        if Config['link_files_enable'] and not Config['move_files_enable']:
            return cnamer.linkPath(
                new_path = destDir,
                new_fullpath = destFilepath,
                always_move = Config['always_move'],
                getPathPreview = getPathPreview,
                force = Config['overwrite_destination_on_move'])
        else:
            return cnamer.newPath(
                new_path = destDir,
                new_fullpath = destFilepath,
                always_move = Config['always_move'],
                getPathPreview = getPathPreview,
                force = Config['overwrite_destination_on_move'],
                linkBack = Config['link_files_enable'])

    except OSError, e:
        warn(e)
开发者ID:predakanga,项目名称:tvnamer,代码行数:32,代码来源:main.py


示例10: processFile

def processFile(tvdb_instance, episode):
    """Gets episode name, prompts user for input
    """
    p("#" * 20)
    p("# Processing file: %s" % episode.fullfilename)

    if len(Config['input_filename_replacements']) > 0:
        replaced = applyCustomInputReplacements(episode.fullfilename)
        p("# With custom replacements: %s" % (replaced))

    # Use force_name option. Done after input_filename_replacements so
    # it can be used to skip the replacements easily
    if Config['force_name'] is not None:
        episode.seriesname = Config['force_name']

    p("# Detected series: %s (%s)" % (episode.seriesname, episode.number_string()))

    try:
        episode.populateFromTvdb(tvdb_instance, force_name=Config['force_name'], series_id=Config['series_id'])
    except (DataRetrievalError, ShowNotFound), errormsg:
        if Config['always_rename'] and Config['skip_file_on_error'] is True:
            warn("Skipping file due to error: %s" % errormsg)
            return
        else:
            warn(errormsg)
开发者ID:rwycuff33,项目名称:mover,代码行数:25,代码来源:main.py


示例11: commit

 def commit(self):
     if self.__cursor:
         self.__cursor.close()
         self.__conn.commit()
         self.__cursor = None
     else:
         utils.warn('Nothing committed!!!')
开发者ID:unixzii,项目名称:Cyanstack,代码行数:7,代码来源:dbhelper.py


示例12: post_receive_one

def post_receive_one(ref_name, old_rev, new_rev, refs, submitter_email):
    """post-receive treatment for one reference.

    PARAMETERS
        ref_name: The name of the reference.
        old_rev: The SHA1 of the reference before the update.
        new_rev: The SHA1 of the reference after the update.
        refs: A dictionary containing all references, as described
            in git_show_ref.
        submitter_email: Same as AbstractUpdate.__init__.
    """
    debug('post_receive_one(ref_name=%s\n'
          '                        old_rev=%s\n'
          '                        new_rev=%s)'
          % (ref_name, old_rev, new_rev))

    update = new_update(ref_name, old_rev, new_rev, refs, submitter_email)
    if update is None:
        # We emit a warning, rather than trigger an assertion, because
        # it gives the script a chance to process any other reference
        # that was updated, but not processed yet.
        warn("post-receive: Unsupported reference update: %s (ignored)."
             % ref_name,
             "              old_rev = %s" % old_rev,
             "              new_rev = %s" % new_rev)
        return
    update.send_email_notifications()
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:27,代码来源:post_receive.py


示例13: __no_cvs_check_user_override

    def __no_cvs_check_user_override(self):
        """Return True iff pre-commit-checks are turned off by user override...

        ... via the ~/.no_cvs_check file.

        This function also performs all necessary debug traces, warnings,
        etc.
        """
        no_cvs_check_fullpath = expanduser('~/.no_cvs_check')
        # Make sure the tilde expansion worked.  Since we are only using
        # "~" rather than "~username", the expansion should really never
        # fail...
        assert (not no_cvs_check_fullpath.startswith('~'))

        if not isfile(no_cvs_check_fullpath):
            return False

        # The no_cvs_check file exists.  Verify its age.
        age = time.time() - getmtime(no_cvs_check_fullpath)
        one_day_in_seconds = 24 * 60 * 60

        if (age > one_day_in_seconds):
            warn('%s is too old and will be ignored.' % no_cvs_check_fullpath)
            return False

        debug('%s found - pre-commit checks disabled' % no_cvs_check_fullpath)
        syslog('Pre-commit checks disabled for %(rev)s on %(repo)s by user'
               ' %(user)s using %(no_cvs_check_fullpath)s'
               % {'rev': self.new_rev,
                  'repo': self.email_info.project_name,
                  'user': get_user_name(),
                  'no_cvs_check_fullpath': no_cvs_check_fullpath,
                  })
        return True
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:34,代码来源:__init__.py


示例14: check

def check(modules):
	checked = []
	module_names = {}
	main_module = 0
	for module in modules:
		try:
			if module.name in module_names:
				raise CheckError("redefined")
			module_names[module.name] = module
			_check_module(module, checked)
			checked.append(module)
		except config.BaseError as e:
			raise CheckError("Module %s: %s" % (module.name, str(e)))
		if module.is_main:
			main_module += 1
	if main_module == 0:
		utils.warn("Main module missing")
	for module in modules:
		def check_dep(lst):
			for r in lst:
				if r.is_main:
					utils.warn("Main module %s: Should be the root module (required by %s)" % (r.name, module.name))
		check_dep(module.public_required)
		check_dep(module.private_required)
	for module in modules:
		check_include_loop(module, [])
	return True
开发者ID:Julow,项目名称:makemake,代码行数:27,代码来源:module_checker.py


示例15: get

    def get(self, request, *args, **kwargs):
        # get base
        base = kwargs['base']
        base_model = get_object_or_404(Base, name=base)

        # exec id
        exec_id = kwargs['id']

        # get exec from database
        try:
            exec_model = base_model.apys.get(name=exec_id)
        except Apy.DoesNotExist:
            warn(channel_name_for_user(request), "404 on %s" % request.META['PATH_INFO'])
            return HttpResponseNotFound("404 on %s"     % request.META['PATH_INFO'])

        user = channel_name_for_user(request)
        debug(user, "%s-Request received, URI %s" % (request.method, request.path))

        apy_data = serializers.serialize("json", [exec_model], fields=('base_id', 'name'))
        struct = json.loads(apy_data)
        apy_data = json.dumps(struct[0])
        rpc_request_data = {}
        rpc_request_data.update({'model': apy_data, 
                'base_name': base_model.name,
            })
        get_dict = copy.deepcopy(request.GET)
        post_dict = copy.deepcopy(request.POST)
        for key in ["json", "shared_key"]:
            if request.method == "GET":
                if get_dict.has_key(key): del get_dict[key]
            if request.method == "POST":
                if post_dict.has_key(key): del get_dict[key]
        rpc_request_data.update({'request': 
                { 
                'method': request.method,
                'GET': get_dict.dict(),
                'POST': post_dict.dict(),
                #'session': request.session.session_key,
                'user': {'username': request.user.username},
                'REMOTE_ADDR': request.META.get('REMOTE_ADDR')
                }
            })
        logger.debug("REQUEST-data: %s" % rpc_request_data)
        try:
            # _do on remote
            start = int(round(time.time() * 1000))
            response_data = call_rpc_client(json.dumps(rpc_request_data), 
                generate_vhost_configuration(base_model.user.username, base_model.name), 
                base_model.name, 
                base_model.executor.password)
            end = int(round(time.time() * 1000))
            ms=str(end-start)

            logger.info("RESPONSE-time: %sms" %  str(ms))
            logger.debug("RESPONSE-data: %s" % response_data[:120])
            data = json.loads(response_data)
        except Exception, e:
            logger.exception(e)
            raise HttpResponseServerError(e)
开发者ID:fatrix,项目名称:django-fastapp,代码行数:59,代码来源:views.py


示例16: debugConnection

def debugConnection(sock, addr, port):
    # Prints the details of a connection
    warn("connection timed out, plesae check listener status")
    info("detailed Report:")
    info("IP_ADDR: "%addr)
    info("PORT: "%port)
    if not sock.gettimeout(): return
    info("connection timed out after %.3f seconds"%sock.gettimeout())
开发者ID:harveybia,项目名称:the-flash-sudo,代码行数:8,代码来源:framework.py


示例17: init

    def init(self):
        if os.path.exists(self.repo_path):
            utils.warn("Homefiles repo already exists at '%s'"
                       % self.repo_path)
            return

        utils.mkdir(self.repo_path)
        self.git.init()
开发者ID:rconradharris,项目名称:homefiles,代码行数:8,代码来源:__init__.py


示例18: doRenameFile

def doRenameFile(cnamer, newName):
    """Renames the file. cnamer should be Renamer instance,
    newName should be string containing new filename.
    """
    try:
        cnamer.newName(newName)
    except OSError, e:
        warn(unicode(e))
开发者ID:chainsawbike,项目名称:tvnamer,代码行数:8,代码来源:main.py


示例19: doRenameFile

def doRenameFile(cnamer, newName):
    """Renames the file. cnamer should be Renamer instance,
    newName should be string containing new filename.
    """
    try:
        cnamer.newName(newName, force = Config['overwrite_destination_on_rename'])
    except OSError, e:
        warn(e)
开发者ID:rwycuff33,项目名称:mover,代码行数:8,代码来源:main.py


示例20: BuildFixesFromPoints

def BuildFixesFromPoints(features, shapeFieldName, dateField, groupingFields,
                         locationVarianceField, mobilityVarianceField, spatialReference):
    
    fieldNames = [f.name for f in arcpy.ListFields(features)]
    if not dateField or dateField not in fieldNames:
        raise ValueError, "date field is not found in the dataset"

    #FIXME - verify field types   
    dateFieldDelimited = arcpy.AddFieldDelimiters(features, dateField)
    sort = dateField  + " A"
    fields = shapeFieldName + ";" + dateField
    if locationVarianceField and locationVarianceField in fieldNames:
        fields += ";" + arcpy.AddFieldDelimiters(features, locationVarianceField)
    else:
        locationVarianceField = None
    if mobilityVarianceField and mobilityVarianceField in fieldNames:
        fields += ";" + arcpy.AddFieldDelimiters(features, mobilityVarianceField)
    else:
        mobilityVarianceField = None
    if spatialReference.factoryCode != arcpy.Describe(features).spatialReference.factoryCode:
        #FIXME - ESRI BUG - reprojection does not work if the data is in a FGDB and a sort order is given.
        sort = ''
        msg = "Due to a bug in ArcGIS 10, data cannot be both sorted and projected on the fly. "
        msg += "Since a projection is required for your data sorting is turned off. "
        msg += "This is OK for data in the Animal Movements Database, however other data "
        msg += "must be correctly pre-sorted by date or you will get incorrect results. "
        msg += "If you can't guarantee pre-sorted data, then reproject your data first."
        utils.warn(msg)
    
    results = {}
    #print groupingFields, dateFieldDelimited
    for groupName, whereClaus in GetGroupings(groupingFields, dateFieldDelimited).iteritems():
        #print groupName, whereClaus
        #utils.info("Where = " + where + " Fields = " + fields + " Sort = " + sort)
        #FIXME - ESRI BUG - reprojection does not work if the data is in a FGDB and a sort order is given.
        #utils.info("Spatial Ref = " + spatialRef.Name)
        fixes = []
        firstTime = None
        #print whereClaus, spatialRef, fields, sort
        points = arcpy.SearchCursor(features, whereClaus, spatialReference, fields, sort)
        for point in points:
            fix = [0,0,0,0,0]
            newTime = point.getValue(dateField)
            if firstTime == None:
                firstTime = newTime
            fix[0] = GetMinutes(newTime, firstTime)
            fix[1] = point.getValue(shapeFieldName).getPart().X
            fix[2] = point.getValue(shapeFieldName).getPart().Y
            if locationVarianceField:
                fix[3] = point.getValue(locationVarianceField)
            if mobilityVarianceField:
                fix[4] = point.getValue(mobilityVarianceField)
            fixes.append(fix)
            
        results[groupName] = fixes
        utils.info("fixes "+ str(len(fixes)) +" first fix: " + str(fixes[0]))
    return results
开发者ID:FabianUx,项目名称:AnimalMovement,代码行数:57,代码来源:BB_Raster.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.warning函数代码示例发布时间:2022-05-27
下一篇:
Python file.store_uploaded_file函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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