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

Python utils.error函数代码示例

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

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



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

示例1: checkGbcFilesEq

def checkGbcFilesEq(name, genfile, reffile):
    """check if non-zero bytes in binary files are equal"""
    with open(genfile, "rb") as fg, open(reffile, "rb") as fr:
        genimage = fg.read()
        refimage = fr.read()[6:]
    if genimage != refimage and genimage != refimage[:-1]:
        error("GPL image", "Image mismatch: " + name)
开发者ID:christopherkobayashi,项目名称:xdt99,代码行数:7,代码来源:ga-checkimg.py


示例2: check_port

def check_port(name, port):
    debug('Checking for "{0}" command', name)
    for i in e('${PATH}').split(':'):
        if os.path.exists(e('${i}/${name}')):
            return

    error('Command {0} not found. Please run "pkg install {1}" or install from ports', name, port)
开发者ID:DeepikaDhiman,项目名称:freenas-build,代码行数:7,代码来源:check-host.py


示例3: status

def status(jira, args):
    m = re.match(r'(\w+-\d+) (.*)', args)

    if not m:
        return utils.not_valid_args(args)

    issue_key = m.group(1)
    issue_status = m.group(2)

    try:
        issue = jira.issue(issue_key)
        statuses = jira.statuses()

        if issue_status not in [s.name for s in statuses]:
            return utils.error('Status {} does not exist'.format(issue_status))

        if issue_status == issue.fields.status.name:
            return utils.error('Status {} already set'.format(issue_status))

        transitions = jira.transitions(issue)
        transition_id = utils.get_transition(transitions, issue_status)

        if not transition_id:
            return utils.error('Operation not permitted')

        jira.transition_issue(issue, transition_id)
        issue = jira.issue(issue_key)

        return utils.issue_info(issue)
    except JIRAError as e:
        response = utils.error('{} {}'.format(str(e.status_code), str(e.text)))
        return response
开发者ID:nserebry,项目名称:Bot-Jira-and-Slack,代码行数:32,代码来源:commands.py


示例4: sub

def sub(u, v):
    a = []
    if abs(len(u) - len(v)) < 1e-12:
        a = [ u[i]-v[i] for i in range(len(u)) ]
    else:
        utils.error('Vectors are of different length (utils_math: sub)')
    return a
开发者ID:maa8g09,项目名称:phd_code,代码行数:7,代码来源:utils_math.py


示例5: create

    def create(self, opts):
        """Create a conf stanza."""

        argv = opts.args
        count = len(argv)

        # unflagged arguments are conf, stanza, key. In this order
        # however, we must have a conf and stanza.
        cpres = True if count > 0 else False
        spres = True if count > 1 else False
        kpres = True if count > 2 else False 

        if kpres:
            kvpair = argv[2].split("=")
            if len(kvpair) != 2:
                error("Creating a k/v pair requires key and value", 2)

        if not cpres and not spres:
            error("Conf name and stanza name is required for create", 2)

        name = argv[0]
        stan = argv[1]
        conf = self.service.confs[name]

        if not kpres:
            # create stanza
            conf.create(stan)
            return 

        # create key/value pair under existing stanza
        stanza = conf[stan]
        stanza.submit(argv[2])
开发者ID:apanda,项目名称:splunk-sdk-python,代码行数:32,代码来源:conf.py


示例6: parse_blog_parts

def parse_blog_parts(string):
    """Parse and convert blog parts.

    Argument:

        string: blog entry body string.

    """

    ex_ref_char = re.compile('\&(?!amp;)')
    string = ex_ref_char.sub('&amp;', string)

    string = string.replace('alt="no image"', '')

    try:
        xmltree = xml.etree.ElementTree.fromstring(string)
    except:
        utils.error(string)

    if xmltree.get('class') == 'amazlet-box':
        repl_amazon = parse_amazlet(xmltree)
        return repl_amazon
    if xmltree.get('class'):
        if xmltree.get('class').find('bbpBox') == 0:
            repl_twitter = parse_twitter(xmltree)
            return repl_twitter
    if str(xmltree.get('id')).find('__ss_') == 0:
        repl_slideshare = parse_slideshare(xmltree)
        return repl_slideshare
    if str(xmltree.get('href')).find('heyquiz.com') >= 0:
        repl_heyquiz = parse_heyquiz(xmltree)
        return repl_heyquiz
开发者ID:mkouhei,项目名称:hatena2rest,代码行数:32,代码来源:convert.py


示例7: build_nt

    def build_nt(self):
        os.chdir(self.build_dir)
        # do check for some file

        if os.path.exists(os.path.join("dcmdata/libsrc", BUILD_TARGET, "dcmdata.lib")):
            utils.output("dcmtk::dcmdata already built.  Skipping.")

        else:
            # Release buildtype (vs RelWithDebInfo) so we build with
            # /MD and not /MDd
            ret = utils.make_command("dcmtk.sln", install=False, project="dcmdata", win_buildtype=BUILD_TARGET)

            if ret != 0:
                utils.error("Could not build dcmtk::dcmdata.")

        if os.path.exists(os.path.join("ofstd/libsrc", BUILD_TARGET, "ofstd.lib")):
            utils.output("dcmtk::ofstd already built.  Skipping.")

        else:
            # Release buildtype (vs RelWithDebInfo) so we build with
            # /MD and not /MDd
            ret = utils.make_command("dcmtk.sln", install=False, project="ofstd", win_buildtype=BUILD_TARGET)

            if ret != 0:
                utils.error("Could not build dcmtk::ofstd.")
开发者ID:codester2,项目名称:devide.johannes,代码行数:25,代码来源:ip_dcmtk.py


示例8: output

def output(record):
    print_record(record)

    for k in sorted(record.keys()):
        if k.endswith("_str"): 
            continue # Ignore

        v = record[k]

        if v is None:
            continue # Ignore

        if isinstance(v, list):
            if len(v) == 0: continue
            v = ','.join([str(item) for item in v])

        # Field renames
        k = { 'source': "status_source" }.get(k, k)

        if isinstance(v, str):
            format = '%s="%s" '
            v = v.replace('"', "'")
        else:
            format = "%s=%r "
        result = format % (k, v)

        ingest.send(result)

    end = "\r\n---end-status---\r\n"
    try: 
        ingest.send(end)
    except:
        error("There was an error with the TCP connection to Splunk.", 2)
开发者ID:apanda,项目名称:splunk-sdk-python,代码行数:33,代码来源:input.py


示例9: get

	def get(self, key):
		profile = db.get(key)
		if profile.avatar:
			self.response.headers['Content-Type'] = "image/png"
			self.response.out.write(profile.avatar)
		else:
			error(self, 404); return
开发者ID:chmielu,项目名称:tpm,代码行数:7,代码来源:misc.py


示例10: validate

def validate(featureclass, quiet=False):

    """
    Checks if a feature class is suitable for uploading to Places.

    Requires arcpy and ArcGIS 10.x ArcView or better license

        Checks: geodatabase = good, shapefile = ok, others = fail
        geometry: polys, lines, point, no multipoints, patches, etc
        must have a spatial reference system
        geometryid (or alt) column = good othewise = ok
        if it has a placesid column it must be empty

    :rtype : basestring
    :param featureclass: The ArcGIS feature class to validate
    :param quiet: Turns off all messages
    :return: 'ok' if the feature class meets minimum requirements for upload
             'good' if the feature class is suitable for syncing
             anything else then the feature class should not be used
    """
    if not featureclass:
        if not quiet:
            utils.error("No feature class provided.")
        return 'no feature class'

    if not arcpy.Exists(featureclass):
        if not quiet:
            utils.error("Feature class not found.")
        return 'feature class not found'

    return 'ok'
开发者ID:regan-sarwas,项目名称:arc2osm,代码行数:31,代码来源:placescore.py


示例11: main

def main():
    try:

        args = parse_options()
        f = args.__dict__.get('infile')
        if f.find('~') == 0:
            infile = os.path.expanduser(f)
        else:
            infile = os.path.abspath(f)

        if args.__dict__.get('dstdir'):
            dstdir = args.__dict__.get('dstdir')
        else:
            # default: ~/tmp/hatena2rest/
            dstdir = None

        if args.__dict__.get('retrieve'):
            retrieve_image_flag = True
        else:
            retrieve_image_flag = False

        processing.xml2rest(infile, dstdir, retrieve_image_flag)

    except RuntimeError as e:
        utils.error(e)
        return
    except UnboundLocalError as e:
        utils.error(e)
        return
开发者ID:mkouhei,项目名称:hatena2rest,代码行数:29,代码来源:command.py


示例12: init4places

def init4places(featureclass, quiet=False):

    """
    Sets up a Geodatabase feature class for syncing with Places.

    Adds a PlacesID column if it doesn't exist,
    turn on archiving if not already on.

    :rtype : bool
    :param featureclass: The ArcGIS feature class to validate
    :param quiet: Turns off all messages
    :return: True if successful, False otherwise

    """

    if not featureclass:
        if not quiet:
            utils.error("No feature class provided.")
        return False

    if not arcpy.Exists(featureclass):
        if not quiet:
            utils.error("Feature class not found.")
        return False

    return True
开发者ID:regan-sarwas,项目名称:arc2osm,代码行数:26,代码来源:placescore.py


示例13: run

 def run(self, command, opts):
     """Dispatch the given command & args."""
     handlers = {"create": self.create, "delete": self.delete, "list": self.list}
     handler = handlers.get(command, None)
     if handler is None:
         error("Unrecognized command: %s" % command, 2)
     handler(opts)
开发者ID:malmoore,项目名称:splunk-sdk-python,代码行数:7,代码来源:conf.py


示例14: configure

    def configure(self):
        if os.path.exists(
            os.path.join(self.build_dir, 'CMakeFiles/cmake.check_cache')):
            utils.output("vtkdevide build already configured.")
            return
        
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        cmake_params = "-DBUILD_SHARED_LIBS=ON " \
                       "-DBUILD_TESTING=OFF " \
                       "-DCMAKE_BUILD_TYPE=RelWithDebInfo " \
                       "-DCMAKE_INSTALL_PREFIX=%s " \
                       "-DVTK_DIR=%s " \
                       "-DDCMTK_INCLUDE_PATH=%s " \
                       "-DDCMTK_LIB_PATH=%s " \
                       "-DPYTHON_EXECUTABLE=%s " \
                       "-DPYTHON_LIBRARY=%s " \
                       "-DPYTHON_INCLUDE_PATH=%s" % \
                       (self.inst_dir, config.VTK_DIR,
                        config.DCMTK_INCLUDE, config.DCMTK_LIB,
                        config.PYTHON_EXECUTABLE,
                        config.PYTHON_LIBRARY,
                        config.PYTHON_INCLUDE_PATH)

        ret = utils.cmake_command(self.build_dir, self.source_dir,
                cmake_params)

        if ret != 0:
            utils.error("Could not configure vtkdevide.  Fix and try again.")
开发者ID:codester2,项目名称:devide.johannes,代码行数:30,代码来源:ip_vtkdevide.py


示例15: sendXML

	def sendXML(self, xml):
		""" First, check wether the coq process is still running.
		Then it send the XML command, and finally it waits for the response """
		if self.coqtop == None:
			utils.error('ERROR: The coqtop process is not running or died !')
			print('Trying to relaunch it ...')
			self.launchCoqtopProcess()
		try:
			self.coqtop.stdin.write(XMLFactory.tostring(xml, 'utf-8'))
		except IOError as e:
			utils.error('Cannot communicate with the coq process : ' + str(e))
			self.coqtop = None
			return None
		response = ''
		file = self.coqtop.stdout.fileno()
		while True:
			try:
				response += os.read(file, 0x4000)
				try:
					t = XMLFactory.fromstring(response)
					return t
				except XMLFactory.ParseError:
					continue
			except OSError:
				return None
开发者ID:QuanticPotato,项目名称:vcoq,代码行数:25,代码来源:coq.py


示例16: post

	def post(self, username):
		username = urllib.unquote(username)
		if username != str(self.user) and not self.is_admin:
			error(self, 403); return

		if not self.is_admin and (self.request.get("is_member") or self.request.get("is_admin")):
			error(self, 403); return

		profile = db.Query(models.Profile).filter("user =", users.User(username)).get()

		if not profile:
			self.redirect("/user/create"); return

		screenname = self.request.get("screenname")
		if screenname:
			if screenname != profile.screenname:
				if db.Query(models.Profile).filter("screenname =", screenname).get():
					self.misc_render("user_profile.html", message="This screen name is taken.", form_profile=profile, username=username); return
			profile.screenname = screenname
		if self.request.get("realname"):
			profile.realname = self.request.get("realname")
		if self.request.get("is_member"):
			profile.is_member = True
		else:
			profile.is_member = False
		if self.request.get("is_admin"):
			profile.is_admin = True
		else:
			profile.is_admin = False

		profile.put()
		self.redirect("/user/%s/profile" % username)
开发者ID:chmielu,项目名称:tpm,代码行数:32,代码来源:user.py


示例17: checkRecordsByLen

def checkRecordsByLen(infile, fixed=None):
    """check records by encoded length"""
    refline = "*".join(["".join([chr(c) for c in xrange(64, 127)])
                        for _ in xrange(4)])
    if fixed is None:
        with open(infile, "r") as f:
            records = f.readlines()
    else:
        with open(infile, "rb") as f:
            data = f.read()
            records = [data[i:i + fixed]
                       for i in xrange(0, len(data), fixed)]
    for i, line in enumerate(records):
        if fixed:
            l = line
            if len(l) != fixed:
                error("VAR Records",
                      "%s: Record %d length mismatch: %d != %d" % (
                          infile, i, len(l), fixed))
        else:
            l = line[:-1] if line[-1] == "\n" else line
        l = l.rstrip()
        s = "!" + refline[:len(l) - 2] + chr(i + 49) if len(l) > 1 else ""
        if l != s:
            error("VAR Records",
                  "%s: Record %i content mismatch" % (infile, i))
开发者ID:christopherkobayashi,项目名称:xdt99,代码行数:26,代码来源:dm-checkdis.py


示例18: checkFileSizes

def checkFileSizes(files):
    for fn, fs in files:
        size = None
        with open(fn, "rb") as f:
            size = len(f.read())
        if fs != size:
            error("Files", "Incorect file size " + fn + ": " + str(size))
开发者ID:christopherkobayashi,项目名称:xdt99,代码行数:7,代码来源:as-checkext.py


示例19: main

def main():
    usage = "usage: %prog <search>"
    opts = utils.parse(sys.argv[1:], {}, ".splunkrc", usage=usage)

    if len(opts.args) != 1:
        utils.error("Search expression required", 2)
    search = opts.args[0]

    service = connect(**opts.kwargs)

    try:
        result = service.get(
            "search/jobs/export",
            search=search,
            earliest_time="rt", 
            latest_time="rt", 
            search_mode="realtime")

        reader = results.ResultsReader(result.body)
        while True:
            kind = reader.read()
            if kind == None: break
            if kind == results.RESULT:
                event = reader.value
                pprint(event)

    except KeyboardInterrupt:
        print "\nInterrupted."
开发者ID:apanda,项目名称:splunk-sdk-python,代码行数:28,代码来源:stail.py


示例20: pkgconfig_get_link_args

def pkgconfig_get_link_args(pkg, ucp='', system=True, static=True):
  havePcFile = pkg.endswith('.pc')
  pcArg = pkg
  if not havePcFile:
    if system:
      # check that pkg-config knows about the package in question
      run_command(['pkg-config', '--exists', pkg])
    else:
      # look for a .pc file
      if ucp == '':
        ucp = default_uniq_cfg_path()
      pcfile = pkg + '.pc' # maybe needs to be an argument later?

      pcArg = os.path.join(get_cfg_install_path(pkg, ucp), 'lib',
                           'pkgconfig', pcfile)

      if not os.access(pcArg, os.R_OK):
        error("Could not find '{0}'".format(pcArg), ValueError)

  static_arg = [ ]
  if static:
    static_arg = ['--static']

  libs_line = run_command(['pkg-config', '--libs'] + static_arg + [pcArg]);
  libs = libs_line.split()
  return libs
开发者ID:rchyena,项目名称:chapel,代码行数:26,代码来源:third_party_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.escape函数代码示例发布时间:2022-05-26
下一篇:
Python utils.err函数代码示例发布时间: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