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


Python utils.error函数代码示例

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


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


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