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

Python posixpath.splitext函数代码示例

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

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



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

示例1: check_make_bibliography

def check_make_bibliography(engine, filenames):
    allowed_exts = {'.bst', '.bib', '.aux'}
    filenames_by_ext = dict(
        (posixpath.splitext(filename)[1], filename) for filename in filenames
    )
    engine_name = engine.__name__.rsplit('.', 1)[-1]

    for ext in filenames_by_ext:
        if ext not in allowed_exts:
            raise ValueError(ext)

    with cd_tempdir() as tempdir:
        copy_files(filenames)
        bib_name = posixpath.splitext(filenames_by_ext['.bib'])[0]
        bst_name = posixpath.splitext(filenames_by_ext['.bst'])[0]
        if not '.aux' in filenames_by_ext:
            write_aux('test.aux', bib_name, bst_name)
            filenames_by_ext['.aux'] = 'test.aux'
        with errors.capture() as captured_errors:  # FIXME check error messages
            engine.make_bibliography(filenames_by_ext['.aux'])
        result_name = posixpath.splitext(filenames_by_ext['.aux'])[0] + '.bbl'
        with io.open_unicode(result_name) as result_file:
            result = result_file.read()
        correct_result_name = '{0}_{1}.{2}.bbl'.format(bib_name, bst_name, engine_name)
        correct_result = pkgutil.get_data('pybtex.tests.data', correct_result_name).decode(io.get_default_encoding())
        assert result == correct_result, diff(correct_result, result)
开发者ID:Superbeet,项目名称:bibolamazi,代码行数:26,代码来源:general_engine_test.py


示例2: _extract_file_format

    def _extract_file_format(self, url, headers):
        """
        Makes a best guess at the file format.

        /path/to/a_file.csv has format "CSV"
        /path/to/a_file.csv.zip has format "CSV / Zip"

        First this function tries to extract the file-extensions from the url,
        and deduce the format from there.  If no file-extension is found, then
        the mimetype from the headers is passed to `mimetypes.guess_extension()`.
        """
        formats = []
        parsed_url = urlparse.urlparse(url)
        path = parsed_url.path
        base, extension = posixpath.splitext(path)
        while extension:
            formats.append(extension[1:].upper())  # strip leading '.' from extension
            base, extension = posixpath.splitext(base)
        if formats:
            extension = ".".join(formats[::-1]).lower()
            format_tuple = ckan_helpers.resource_formats().get(extension)
            if format_tuple:
                return format_tuple[1]
            return " / ".join(formats[::-1])

        # No file extension found, attempt to extract format using the mimetype
        stripped_mimetype = self._extract_mimetype(headers)  # stripped of charset
        format_tuple = ckan_helpers.resource_formats().get(stripped_mimetype)
        if format_tuple:
            return format_tuple[1]

        extension = mimetypes.guess_extension(stripped_mimetype)
        if extension:
            return extension[1:].upper()
开发者ID:CarlQLange,项目名称:ckanext-qa,代码行数:34,代码来源:controllers.py


示例3: guess_type

 def guess_type(self, url, strict=True):
     (scheme, url) = urllib.parse.splittype(url)
     if scheme == 'data':
         comma = url.find(',')
         if comma < 0:
             return (None, None)
         semi = url.find(';', 0, comma)
         if semi >= 0:
             type = url[:semi]
         else:
             type = url[:comma]
         if '=' in type or '/' not in type:
             type = 'text/plain'
         return (type, None)
     (base, ext) = posixpath.splitext(url)
     while ext in self.suffix_map:
         (base, ext) = posixpath.splitext(base + self.suffix_map[ext])
     if ext in self.encodings_map:
         encoding = self.encodings_map[ext]
         (base, ext) = posixpath.splitext(base)
     else:
         encoding = None
     types_map = self.types_map[True]
     if ext in types_map:
         return (types_map[ext], encoding)
     if ext.lower() in types_map:
         return (types_map[ext.lower()], encoding)
     if strict:
         return (None, encoding)
     types_map = self.types_map[False]
     if ext in types_map:
         return (types_map[ext], encoding)
     if ext.lower() in types_map:
         return (types_map[ext.lower()], encoding)
     return (None, encoding)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:35,代码来源:mimetypes.py


示例4: _extract_file_format

    def _extract_file_format(self, url, headers):
        """
        Makes a best guess at the file format.

        Returns a list of strings, with formats[0] being the outermost format.
        If no format can be found, then returns an empty list.

        /path/to/a_file.csv has format "csv"
        /path/to/a_file.csv.gz.torrent has format "torrent:gz:csv" (and inner-form "csv")

        First this function tries to extract the file-extensions from the url,
        and deduce the format from there.  If no file-extension is found, then
        the mimetype from the headers is passed to `mimetypes.guess_extension()`.
        """
        # Try to extract format from the file extension(s)
        formats = []
        parsed_url = urlparse.urlparse(url)
        path = parsed_url.path
        base, extension = posixpath.splitext(path)
        while extension:
            formats.append(extension[1:]) # strip leading '.' from extension
            base, extension = posixpath.splitext(base)
        if formats:
            return formats

        # No file extension found, attempt to extract format using the mimetype
        stripped_mimetype = self._extract_mimetype(headers) # stripped of charset
        extension = mimetypes.guess_extension(stripped_mimetype)
        return [extension[1:]] if extension else []
开发者ID:Hoedic,项目名称:ckanext-qa,代码行数:29,代码来源:qa_resource.py


示例5: write_latex

def write_latex(outdir,images,prefix,query_image):
  otex=posixpath.join(outdir,'{}.tex'.format(prefix))
  with open(otex,'w') as f:
    print(r'''\documentclass{article}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage{paralist}
\usepackage{multirow}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amssymb,amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}''',file=f)
    x=query_image
    pname=posixpath.join(outdir,'{}query{}'.format(prefix,posixpath.splitext(x)[1]))
    shutil.copyfile(x,pname)
    print(r'''\begin{figure}[h]
\centering
\includegraphics[width=2.0in]{%s}
\caption{query} \label{fig:%s}
\end{figure}''' % (posixpath.split(pname)[1],prefix+'query'),file=f)
    print(r'\begin{figure}',file=f)
    for i,x in enumerate(images):
      pname=posixpath.join(outdir,'{}{:03}{}'.format(prefix,i,posixpath.splitext(x)[1]))
      shutil.copyfile(x,pname)
      print(r'''\begin{minipage}[b]{.5\linewidth}
\centering \includegraphics[width=1.0in]{%s}
\subcaption{A subfigure}\label{fig:%s}
\end{minipage}''' % (posixpath.split(pname)[1],prefix+str(i)),file=f)
    print(r'\end{figure}',file=f)
    print(r'''\end{document}''',file=f)
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:32,代码来源:gist.py


示例6: dnd_get_image

def dnd_get_image(md, image_exts=IMAGE_EXTENSIONS):
    '''
    Get the image in the QMimeData object md.

    :return: None, None if no image is found
             QPixmap, None if an image is found, the pixmap is guaranteed not
             null
             url, filename if a URL that points to an image is found
    '''
    if dnd_has_image(md):
        for x in md.formats():
            x = unicode(x)
            if x.startswith('image/'):
                cdata = bytes(md.data(x))
                pmap = QPixmap()
                pmap.loadFromData(cdata)
                if not pmap.isNull():
                    return pmap, None
                break

    # No image, look for a URL pointing to an image
    if md.hasUrls():
        urls = [unicode(u.toString()) for u in
                md.urls()]
        purls = [urlparse(u) for u in urls]
        # First look for a local file
        images = [u2p(x) for x in purls if x.scheme in ('', 'file')]
        images = [x for x in images if
                posixpath.splitext(urllib.unquote(x))[1][1:].lower() in
                image_exts]
        images = [x for x in images if os.path.exists(x)]
        p = QPixmap()
        for path in images:
            try:
                with open(path, 'rb') as f:
                    p.loadFromData(f.read())
            except:
                continue
            if not p.isNull():
                return p, None

        # No local images, look for remote ones

        # First, see if this is from Firefox
        rurl, fname = get_firefox_rurl(md, image_exts)

        if rurl and fname:
            return rurl, fname
        # Look through all remaining URLs
        remote_urls = [x for x in purls if x.scheme in ('http', 'https',
            'ftp') and posixpath.splitext(x.path)[1][1:].lower() in image_exts]
        if remote_urls:
            rurl = remote_urls[0]
            fname = posixpath.basename(urllib.unquote(rurl.path))
            return urlunparse(rurl), fname

        return None, None
开发者ID:Eksmo,项目名称:calibre,代码行数:57,代码来源:dnd.py


示例7: guess_type

    def guess_type(self, url, strict = True):
        """Guess the type of a file based on its URL.
        
        Return value is a tuple (type, encoding) where type is None if
        the type can't be guessed (no or unknown suffix) or a string
        of the form type/subtype, usable for a MIME Content-type
        header; and encoding is None for no encoding or the name of
        the program used to encode (e.g. compress or gzip).  The
        mappings are table driven.  Encoding suffixes are case
        sensitive; type suffixes are first tried case sensitive, then
        case insensitive.
        
        The suffixes .tgz, .taz and .tz (case sensitive!) are all
        mapped to '.tar.gz'.  (This is table-driven too, using the
        dictionary suffix_map.)
        
        Optional `strict' argument when False adds a bunch of commonly found,
        but non-standard types.
        """
        scheme, url = urllib.splittype(url)
        if scheme == 'data':
            comma = url.find(',')
            if comma < 0:
                return (None, None)
            semi = url.find(';', 0, comma)
            if semi >= 0:
                type = url[:semi]
            else:
                type = url[:comma]
            if '=' in type or '/' not in type:
                type = 'text/plain'
            return (type, None)
        else:
            base, ext = posixpath.splitext(url)
            while ext in self.suffix_map:
                base, ext = posixpath.splitext(base + self.suffix_map[ext])

            if ext in self.encodings_map:
                encoding = self.encodings_map[ext]
                base, ext = posixpath.splitext(base)
            else:
                encoding = None
            types_map = self.types_map[True]
            if ext in types_map:
                return (types_map[ext], encoding)
            if ext.lower() in types_map:
                return (types_map[ext.lower()], encoding)
            if strict:
                return (None, encoding)
            types_map = self.types_map[False]
            if ext in types_map:
                return (types_map[ext], encoding)
            if ext.lower() in types_map:
                return (types_map[ext.lower()], encoding)
            return (None, encoding)
            return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:56,代码来源:mimetypes.py


示例8: songbook_rename

def songbook_rename(path, title):
  """Rename songbook at path to new-style path based off title.  Returns new path"""
  old_path = posixpath.normpath(path)
  old_path_base = posixpath.splitext(old_path)[0]
  new_path = posixpath.normpath(c.gen_unique_path('songbooks/%s.xml', title, orig_path=old_path))
  new_path_base = posixpath.splitext(new_path)[0]
  for fn in glob.glob(old_path_base+'.*'): # glob because of comments
    fn = posixpath.normpath(fn)
    os.rename(fn, fn.replace(old_path_base, new_path_base))
  return new_path
开发者ID:7flash,项目名称:yCanta,代码行数:10,代码来源:db.py


示例9: Extract

def Extract(path,Result):
	for Files in Result:
		try:
			name=use.splitext(use.basename(Files))[0]
			os.mkdir(use.join(path,name))
			os.chdir(use.join(path,name))
			for files in zipfile.ZipFile(Files).namelist():
				if use.dirname(files)=='':
					if use.splitext(files)[1]=='.txt':
						zipfile.ZipFile(Files).extract(files)
			os.chdir(path)
		except OSError:pass
开发者ID:saikiran638,项目名称:MyPrograms,代码行数:12,代码来源:AutoGen.py


示例10: guess_type

def guess_type(url):
    """Guess the type of a file based on its URL.

    Return value is a tuple (type, encoding) where type is None if the
    type can't be guessed (no or unknown suffix) or a string of the
    form type/subtype, usable for a MIME Content-type header; and
    encoding is None for no encoding or the name of the program used
    to encode (e.g. compress or gzip).  The mappings are table
    driven.  Encoding suffixes are case sensitive; type suffixes are
    first tried case sensitive, then case insensitive.

    The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped
    to ".tar.gz".  (This is table-driven too, using the dictionary
    suffix_map).

    """
    if not inited:
        init()
    scheme, url = urllib.splittype(url)
    if scheme == 'data':
	# syntax of data URLs:
	# dataurl   := "data:" [ mediatype ] [ ";base64" ] "," data
	# mediatype := [ type "/" subtype ] *( ";" parameter )
	# data      := *urlchar
	# parameter := attribute "=" value
	# type/subtype defaults to "text/plain"
	comma = string.find(url, ',')
	if comma < 0:
	    # bad data URL
	    return None, None
	semi = string.find(url, ';', 0, comma)
	if semi >= 0:
	    type = url[:semi]
	else:
	    type = url[:comma]
	if '=' in type or '/' not in type:
	    type = 'text/plain'
	return type, None		# never compressed, so encoding is None
    base, ext = posixpath.splitext(url)
    while suffix_map.has_key(ext):
        base, ext = posixpath.splitext(base + suffix_map[ext])
    if encodings_map.has_key(ext):
        encoding = encodings_map[ext]
        base, ext = posixpath.splitext(base)
    else:
        encoding = None
    if types_map.has_key(ext):
        return types_map[ext], encoding
    elif types_map.has_key(string.lower(ext)):
        return types_map[string.lower(ext)], encoding
    else:
        return None, encoding
开发者ID:arandilopez,项目名称:z-eves,代码行数:52,代码来源:mimetypes.py


示例11: HTML

def HTML(path):
	file_=open(use.join(path,use.basename(path)+'.htm'),"w")
	Str="<html><title>"+use.basename(path)+"</title><body>"
	Dict={}
	for files in os.listdir(path):
		if use.splitext(files)[1]=='.txt':
			Dict[int(use.splitext(files)[0])]=files
	list_=Dict.keys()
	list_.sort()
	for files in list_:
		Str+="<img src="+Dict[files]+">"
	file_.write(Str+"<br><br><font color='red'>&copy AUTOMATIC file generator</font></body></center></html>")
	file_.close()
开发者ID:saikiran638,项目名称:MyPrograms,代码行数:13,代码来源:AutoGen.py


示例12: _MaybeMarkdown

  def _MaybeMarkdown(self, path):
    if posixpath.splitext(path)[1] != '.html':
      return path

    dirname, file_name = posixpath.split(path)
    if dirname != '':
      dirname = dirname + '/'
    file_list = self.file_system.ReadSingle(dirname).Get()
    if file_name in file_list:
      return path

    if posixpath.splitext(file_name)[0] + '.md' in file_list:
      return posixpath.splitext(path)[0] + '.md'
    return path
开发者ID:MorS25,项目名称:chromium,代码行数:14,代码来源:content_provider.py


示例13: decode_mtl_texture

def decode_mtl_texture(line, effect, aux_file_loader):
    texture_data = aux_file_loader(line)
    if texture_data is None:
        return (None, None)
    texture_slug = slugify(posixpath.splitext(line)[0])
    texture_path = texture_slug + posixpath.splitext(line)[1]
    cimage = collada.material.CImage(texture_slug, "./%s" % texture_path)
    cimage.data = texture_data
    surface = collada.material.Surface(texture_slug + "-surface", cimage)
    sampler = collada.material.Sampler2D(texture_slug + "-sampler", surface)
    _map = collada.material.Map(sampler, "TEX0")
    effect.params.append(surface)
    effect.params.append(sampler)
    return (cimage, _map)
开发者ID:QuelleVille,项目名称:-deprecated-meshtool,代码行数:14,代码来源:load_obj.py


示例14: splitext

def splitext(path, force_posix=False):
    """
    Return a tuple of strings (basename, extension) for a path. The basename is
    the file name minus its extension. Return an empty extension string for a
    directory. A directory is identified by ending with a path separator. Not
    the same as os.path.splitext.

    For example:
    >>> expected = 'path', '.ext'
    >>> assert expected == splitext('C:\\dir\path.ext')

    Directories even with dotted names have no extension:
    >>> import ntpath
    >>> expected = 'path.ext', ''
    >>> assert expected == splitext('C:\\dir\\path.ext' + ntpath.sep)

    >>> expected = 'path.ext', ''
    >>> assert expected == splitext('/dir/path.ext/')

    >>> expected = 'file', '.txt'
    >>> assert expected == splitext('/some/file.txt')

    Composite extensions for tarballs are properly handled:
    >>> expected = 'archive', '.tar.gz'
    >>> assert expected == splitext('archive.tar.gz')
    """
    base_name = EMPTY_STRING
    extension = EMPTY_STRING
    if not path:
        return base_name, extension

    ppath = as_posixpath(path)
    name = resource_name(path, force_posix)
    name = name.strip(POSIX_PATH_SEP + WIN_PATH_SEP)
    if ppath.endswith(POSIX_PATH_SEP):
        # directories never have an extension
        base_name = name
        extension = EMPTY_STRING
    elif name.startswith(DOT) and DOT not in name[1:]:
        # .dot files base name is the full name and they do not have an extension
        base_name = name
        extension = EMPTY_STRING
    else:
        base_name, extension = posixpath.splitext(name)
        # handle composed extensions of tar.gz, bz, zx,etc
        if base_name.endswith(b'.tar' if on_linux else '.tar'):
            base_name, extension2 = posixpath.splitext(base_name)
            extension = extension2 + extension
    return base_name, extension
开发者ID:ocabrisses,项目名称:scancode-toolkit,代码行数:49,代码来源:fileutils.py


示例15: unzip

 def unzip(f):
     z = mkZipFileRd(f)
     names = z.namelist()
     if len(names) != 1:
         raise IOError('more than one item in zip file; which to use? %s' % names)  # noqa
     member = names[0]
     log.info('extracting %s from %s', member, f)
     # x.zip    -> x    -> x
     # x.db.zip -> x.db -> x
     destdir = splitext(splitext(f)[0])[0]
     dest = destdir + '.db'
     z.extract(member, destdir)
     rename(path_join(destdir, member), dest)
     rmdir(destdir)
     return dest
开发者ID:kumc-bmi,项目名称:bc_qa,代码行数:15,代码来源:bc_access.py


示例16: minify_sources

def minify_sources(sources, ext, fs_root='', timestamp=False):
    """Use utilities to minify javascript or css.

    :param sources: Paths of source files
    :param ext: Type of files
    :param fs_root: root of file (normally public dir)
    :type sources: string
    :type ext: js or css
    :type fs_root: string

    :returns: List of paths to minified sources
    """
    if 'js' in ext:
        js_minify = JavascriptMinify()
    minified_sources = []

    for source in sources:
        # generate full path to source
        no_ext_source = path.splitext(source)[0]
        full_source = path.join(fs_root, (no_ext_source + ext).lstrip('/'))

        # generate minified source path
        full_source = path.join(fs_root, (source).lstrip('/'))
        no_ext_full_source = path.splitext(full_source)[0]
        minified = no_ext_full_source + ext

        f_minified_source = open(minified, 'w')

        try:
            # minify js source (read stream is auto-closed inside)
            if 'js' in ext:
                js_minify.minify(open(full_source, 'r'), f_minified_source)

            # minify css source
            if 'css' in ext:
                sheet = cssutils.parseFile(full_source)
                cssutils.setSerializer(CSSUtilsMinificationSerializer())
                cssutils.ser.prefs.useMinified()
                f_minified_source.write(sheet.cssText)
        finally:
            f_minified_source.close()

        if no_ext_source.endswith('COMBINED'):
            minified_sources.append(no_ext_source + ext)
        else:
            minified_sources.append(no_ext_source + generate_timestamp(timestamp) + ext)

    return minified_sources
开发者ID:mitechie,项目名称:MinificationWebHelpers,代码行数:48,代码来源:__init__.py


示例17: WriteSourceVariables

def WriteSourceVariables(out, target, project):
  # gn separates the sheep from the goats based on file extensions.
  # A full separation is done here because of flag handing (see Compile flags).
  source_types = {'cxx':[], 'c':[], 'asm':[],
                  'obj':[], 'obj_target':[], 'input':[], 'other':[]}

  # TODO .def files on Windows
  for source in target.properties.get('sources', []):
    _, ext = posixpath.splitext(source)
    source_abs_path = project.GetAbsolutePath(source)
    source_types[source_file_types.get(ext, 'other')].append(source_abs_path)

  for input_path in target.properties.get('inputs', []):
    input_abs_path = project.GetAbsolutePath(input_path)
    source_types['input'].append(input_abs_path)

  # OBJECT library dependencies need to be listed as sources.
  # Only executables and non-OBJECT libraries may reference an OBJECT library.
  # https://gitlab.kitware.com/cmake/cmake/issues/14778
  if target.gn_type in gn_target_types_that_absorb_objects:
    object_dependencies = set()
    project.GetObjectSourceDependencies(target.gn_name, object_dependencies)
    for dependency in object_dependencies:
      cmake_dependency_name = GetCMakeTargetName(dependency)
      obj_target_sources = '$<TARGET_OBJECTS:' + cmake_dependency_name + '>'
      source_types['obj_target'].append(obj_target_sources)

  sources = {}
  for source_type, sources_of_type in source_types.items():
    if sources_of_type:
      sources[source_type] = '${target}__' + source_type + '_srcs'
      SetVariableList(out, sources[source_type], sources_of_type)
  return sources
开发者ID:ThomasWo,项目名称:proto-quic,代码行数:33,代码来源:gn_to_cmake.py


示例18: guess_type

    def guess_type(self, path):

        """Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.
        """
        base, ext = posixpath.splitext(path)

        if ext in self.extensions_map:
            return self.extensions_map[ext]

        ext = ext.lower()


        if ext in self.extensions_map:
            return self.extensions_map[ext]
        else:
            return self.extensions_map['']
开发者ID:nibble-arts,项目名称:swim,代码行数:26,代码来源:httpd.py


示例19: _CompileContent

 def _CompileContent(self, path, text):
   assert text is not None, path
   try:
     _, ext = posixpath.splitext(path)
     mimetype = _MIMETYPE_OVERRIDES.get(ext, mimetypes.guess_type(path)[0])
     if ext == '.md':
       # See http://pythonhosted.org/Markdown/extensions
       # for details on "extensions=".
       content = markdown(ToUnicode(text),
                          extensions=('extra', 'headerid', 'sane_lists'))
       mimetype = 'text/html'
       if self._supports_templates:
         content = Motemplate(content, name=path)
     elif mimetype is None:
       content = text
       mimetype = 'text/plain'
     elif mimetype == 'text/html':
       content = ToUnicode(text)
       if self._supports_templates:
         content = Motemplate(content, name=path)
     elif (mimetype.startswith('text/') or
           mimetype in ('application/javascript', 'application/json')):
       content = ToUnicode(text)
     else:
       content = text
     return ContentAndType(content,
                           mimetype,
                           self.file_system.Stat(path).version)
   except Exception as e:
     logging.warn('In file %s: %s' % (path, e.message))
     return ContentAndType('', mimetype, self.file_system.Stat(path).version)
开发者ID:AlinaGlavan,项目名称:chromium,代码行数:31,代码来源:content_provider.py


示例20: _StartClient

def _StartClient(vm, server_ip, client_thread_count):
  """Pushes and starts the client workload script.

  Args:
    vm: The client VM.
    server_ip: The server's ip address.
    client_thread_count: The client thread count used for this particular run.

  Returns:
    Stdout from CLIENT_SCRIPT

  Raises:
    ClientWorkloadScriptExecutionError: if an error occurred during execution
      of CLIENT_SCRIPT (detected by looking at stderr).
  """
  stdout, stderr = vm.RemoteCommand(
      'python {0} --server={1}:{2} --image_directory={3} '
      '--runtime={4} --num_threads={5}'.format(
          posixpath.join(INSTALL_DIR, CLIENT_SCRIPT), server_ip, SERVER_PORT,
          posixpath.join(INSTALL_DIR,
                         posixpath.splitext(ILSVRC_VALIDATION_IMAGES_TAR)[0]),
          FLAGS.tf_serving_runtime, client_thread_count),
      should_log=True)

  # Ensure that stderr from the client script is empty.
  # If it is, stderr from the remote command should contain a single line:
  # Warning: Permanently added {ip} (ECDSA) to the list of known hosts.
  if len(stderr.splitlines()) > 1:
    raise ClientWorkloadScriptExecutionError(
        'Exception occurred during execution of client script: {0}'.format(
            stderr))

  return stdout
开发者ID:9723,项目名称:PerfKitBenchmarker,代码行数:33,代码来源:tensorflow_serving_benchmark.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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