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


Python errno.ENAMETOOLONG属性代码示例

本文整理汇总了Python中errno.ENAMETOOLONG属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ENAMETOOLONG属性的具体用法?Python errno.ENAMETOOLONG怎么用?Python errno.ENAMETOOLONG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在errno的用法示例。


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

示例1: bind

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def bind(self, address):
        if isinstance(address, unicode):
            address = address.encode('utf8')
        rc = C.zmq_bind(self._zmq_socket, address)
        if rc < 0:
            if IPC_PATH_MAX_LEN and C.zmq_errno() == errno_mod.ENAMETOOLONG:
                # py3compat: address is bytes, but msg wants str
                if str is unicode:
                    address = address.decode('utf-8', 'replace')
                path = address.split('://', 1)[-1]
                msg = ('ipc path "{0}" is longer than {1} '
                                'characters (sizeof(sockaddr_un.sun_path)).'
                                .format(path, IPC_PATH_MAX_LEN))
                raise ZMQError(C.zmq_errno(), msg=msg)
            else:
                _check_rc(rc) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:socket.py

示例2: extract

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def extract(self, fwad, output_path):
        """Read data, convert it if needed, and write it to a file

        On error, partially retrieved files are removed.
        File redirections are skipped.
        """

        data = self.read_data(fwad)
        if data is None:
            return

        try:
            with write_file_or_remove(output_path) as fout:
                fout.write(data)
        except OSError as e:
            # Windows does not support path components longer than 255
            # ignore such files
            # TODO: Find a better way of handling these files
            if e.errno in (errno.EINVAL, errno.ENAMETOOLONG):
                logger.warning(f"ignore file with invalid path: {self.path}")
            else:
                raise 
开发者ID:CommunityDragon,项目名称:CDTB,代码行数:24,代码来源:wad.py

示例3: create_files

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def create_files(self, problem_id, source_code, *args, **kwargs):
        super().create_files(problem_id, source_code, *args, **kwargs)
        # This step is necessary because of Unicode classnames
        try:
            source_code = utf8text(source_code)
        except UnicodeDecodeError:
            raise CompileError('Your UTF-8 is bad, and you should feel bad')
        class_name = find_class(source_code)
        self._code = self._file('%s.java' % class_name.group(1))
        try:
            with open(self._code, 'wb') as fo:
                fo.write(utf8bytes(source_code))
        except IOError as e:
            if e.errno in (errno.ENAMETOOLONG, errno.ENOENT, errno.EINVAL):
                raise CompileError('Why do you need a class name so long? As a judge, I sentence your code to death.\n')
            raise
        self._class_name = class_name.group(1) 
开发者ID:DMOJ,项目名称:judge-server,代码行数:19,代码来源:java_executor.py

示例4: main

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def main():
    if len(sys.argv) < 3:
        print('Need data_dir and link_dir.\n'
              'e.g.: kenshin-rebuild-link.py /kenshin/data/a /kenshin/link/a')
        sys.exit(1)

    data_dir, link_dir = sys.argv[1:]
    data_dir = os.path.abspath(data_dir)
    link_dir = os.path.abspath(link_dir)

    for schema_name in os.listdir(data_dir):
        hs_file_pat = os.path.join(data_dir, schema_name, '*.hs')
        for fp in glob.glob(hs_file_pat):
            with open(fp) as f:
                header = kenshin.header(f)
                metric_list = header['tag_list']
                for metric in metric_list:
                    if metric != '':
                        try:
                            create_link(metric, link_dir, fp)
                        except OSError as exc:
                            if exc.errno == errno.ENAMETOOLONG:
                                pass
                            else:
                                raise 
开发者ID:douban,项目名称:Kenshin,代码行数:27,代码来源:kenshin-rebuild-link.py

示例5: rebuildLink

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def rebuildLink(instance_data_dir, instance_link_dir):
    for schema_name in os.listdir(instance_data_dir):
        hs_file_pat = os.path.join(instance_data_dir, schema_name, '*.hs')
        for fp in glob.glob(hs_file_pat):
            with open(fp) as f:
                header = kenshin.header(f)
                metric_list = header['tag_list']
                for metric in metric_list:
                    if metric != '':
                        link_path = getMetricPathByInstanceDir(instance_link_dir, metric)
                        try:
                            _createLinkHelper(link_path, fp)
                        except OSError as exc:
                            if exc.errno == errno.ENAMETOOLONG:
                                pass
                            else:
                                raise 
开发者ID:douban,项目名称:Kenshin,代码行数:19,代码来源:storage.py

示例6: pytest_runtest_protocol

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def pytest_runtest_protocol(self, item, nextitem):
        prof_filename = os.path.abspath(os.path.join(self.dir, clean_filename(item.name) + ".prof"))
        try:
            os.makedirs(os.path.dirname(prof_filename))
        except OSError:
            pass
        prof = cProfile.Profile()
        prof.enable()
        yield
        prof.disable()
        try:
            prof.dump_stats(prof_filename)
        except EnvironmentError as err:
            if err.errno != errno.ENAMETOOLONG:
                raise

            if len(item.name) < LARGE_FILENAME_HASH_LEN:
                raise

            hash_str = md5(item.name.encode('utf-8')).hexdigest()[:LARGE_FILENAME_HASH_LEN]
            prof_filename = os.path.join(self.dir, hash_str + ".prof")
            prof.dump_stats(prof_filename)
        self.profs.append(prof_filename) 
开发者ID:man-group,项目名称:pytest-plugins,代码行数:25,代码来源:pytest_profiling.py

示例7: __is_fifo

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def __is_fifo(self, file_path: Path) -> bool:
        try:
            return stat.S_ISFIFO(os.stat(file_path).st_mode)
        except OSError as e:
            if e.errno not in (EBADF, ENAMETOOLONG, ENOENT, ENOTDIR):
                raise

            return False
        except ValueError:
            return False 
开发者ID:thombashi,项目名称:sqlitebiter,代码行数:12,代码来源:_file.py

示例8: update_files

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def update_files(self, url, ad_info):
        MAX_FILENAME_LENGTH = 245

        ad_page_soup, ad_title, ad_submitter, ad_url = (
            ad_info["ad_page_soup"],
            ad_info["ad_title"],
            ad_info["ad_submitter"],
            ad_info["ad_url"],
        )
        # save url to file, so as not to send a message to them again
        with open(
            os.path.join(self.ad_links_folder, "WG Ad Links.csv"),
            "a",
            newline="",
            encoding="utf-8",
        ) as file_write:
            csv_file_write = csv.writer(file_write)
            csv_file_write.writerow([url, ad_submitter, ad_title])

        # save a copy of the ad for offline viewing, in case the ad is deleted before the user can view it online
        max_ad_title_length = MAX_FILENAME_LENGTH - len(ad_submitter) - len(ad_url)
        if len(ad_title) > max_ad_title_length:
            ad_title = ad_title[: max_ad_title_length - 1] + "..."

        file_name = "{}-{}-{}".format(ad_submitter, ad_title, ad_url)
        try:
            with open(
                os.path.join(self.offline_ad_folder, file_name), "w", encoding="utf-8"
            ) as outfile:
                outfile.write(str(ad_page_soup))
        except OSError as err:
            if err.errno == errno.ENAMETOOLONG:
                self.logger.exception(
                    "File name of {} is too long, could not save this ad offline".format(
                        file_name
                    )
                ) 
开发者ID:grantwilliams,项目名称:wg-gesucht-crawler-cli,代码行数:39,代码来源:crawler.py

示例9: _export_wad

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def _export_wad(self, wad, overwrite=True):
        logger.info(f"export {wad.path} ({len(wad.files)})")
        # similar to Wad.extract()
        # unknown files are skipped
        with open(wad.path, 'rb') as fwad:
            for wadfile in wad.files:
                if wadfile.path is None:
                    continue

                converter = self._get_converter(wadfile.path)
                if not overwrite and converter.converted_paths_exist(self.output, wadfile.path):
                    continue

                data = wadfile.read_data(fwad)
                if data is None:
                    continue  # should not happen, file redirections have been filtered already

                try:
                    converter.convert(BytesIO(data), self.output, wadfile.path)
                except FileConversionError as e:
                    logger.warning(f"cannot convert file '{wadfile.path}': {e}")
                except OSError as e:
                    # Windows does not support path components longer than 255
                    # ignore such files
                    if e.errno in (errno.EINVAL, errno.ENAMETOOLONG):
                        logger.warning(f"ignore file with invalid path: {wad.path}")
                    else:
                        raise 
开发者ID:CommunityDragon,项目名称:CDTB,代码行数:30,代码来源:export.py

示例10: bind

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def bind(self, address):
        rc = C.zmq_bind(self._zmq_socket, address)
        if rc < 0:
            if IPC_PATH_MAX_LEN and C.zmq_errno() == errno_mod.ENAMETOOLONG:
                # py3compat: address is bytes, but msg wants str
                if str is unicode:
                    address = address.decode('utf-8', 'replace')
                path = address.split('://', 1)[-1]
                msg = ('ipc path "{0}" is longer than {1} '
                                'characters (sizeof(sockaddr_un.sun_path)).'
                                .format(path, IPC_PATH_MAX_LEN))
                raise ZMQError(C.zmq_errno(), msg=msg)
            else:
                _check_rc(rc) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:socket.py

示例11: is_fifo

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def is_fifo(file_path):
    try:
        return stat.S_ISFIFO(os.stat(file_path).st_mode)
    except OSError as e:
        if e.errno not in (EBADF, ENAMETOOLONG, ENOENT, ENOTDIR):
            raise

        return False
    except ValueError:
        return False 
开发者ID:thombashi,项目名称:pytablereader,代码行数:12,代码来源:_validator.py

示例12: lzc_send_translate_error

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def lzc_send_translate_error(ret, snapname, fromsnap, fd, flags):
    if ret == 0:
        return
    if ret == errno.EXDEV and fromsnap is not None:
        if _pool_name(fromsnap) != _pool_name(snapname):
            raise lzc_exc.PoolsDiffer(snapname)
        else:
            raise lzc_exc.SnapshotMismatch(snapname)
    elif ret == errno.EINVAL:
        if (fromsnap is not None and not _is_valid_snap_name(fromsnap) and
                not _is_valid_bmark_name(fromsnap)):
            raise lzc_exc.NameInvalid(fromsnap)
        elif not _is_valid_snap_name(snapname) and not _is_valid_fs_name(snapname):
            raise lzc_exc.NameInvalid(snapname)
        elif fromsnap is not None and len(fromsnap) > MAXNAMELEN:
            raise lzc_exc.NameTooLong(fromsnap)
        elif len(snapname) > MAXNAMELEN:
            raise lzc_exc.NameTooLong(snapname)
        elif fromsnap is not None and _pool_name(fromsnap) != _pool_name(snapname):
            raise lzc_exc.PoolsDiffer(snapname)
    elif ret == errno.ENOENT:
        if (fromsnap is not None and not _is_valid_snap_name(fromsnap) and
                not _is_valid_bmark_name(fromsnap)):
            raise lzc_exc.NameInvalid(fromsnap)
        raise lzc_exc.SnapshotNotFound(snapname)
    elif ret == errno.ENAMETOOLONG:
        if fromsnap is not None and len(fromsnap) > MAXNAMELEN:
            raise lzc_exc.NameTooLong(fromsnap)
        else:
            raise lzc_exc.NameTooLong(snapname)
    raise lzc_exc.StreamIOError(ret) 
开发者ID:ClusterHQ,项目名称:pyzfs,代码行数:33,代码来源:_error_translation.py

示例13: lzc_receive_translate_error

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def lzc_receive_translate_error(ret, snapname, fd, force, origin, props):
    if ret == 0:
        return
    if ret == errno.EINVAL:
        if not _is_valid_snap_name(snapname) and not _is_valid_fs_name(snapname):
            raise lzc_exc.NameInvalid(snapname)
        elif len(snapname) > MAXNAMELEN:
            raise lzc_exc.NameTooLong(snapname)
        elif origin is not None and not _is_valid_snap_name(origin):
            raise lzc_exc.NameInvalid(origin)
        else:
            raise lzc_exc.BadStream()
    if ret == errno.ENOENT:
        if not _is_valid_snap_name(snapname):
            raise lzc_exc.NameInvalid(snapname)
        else:
            raise lzc_exc.DatasetNotFound(snapname)
    if ret == errno.EEXIST:
        raise lzc_exc.DatasetExists(snapname)
    if ret == errno.ENOTSUP:
        raise lzc_exc.StreamFeatureNotSupported()
    if ret == errno.ENODEV:
        raise lzc_exc.StreamMismatch(_fs_name(snapname))
    if ret == errno.ETXTBSY:
        raise lzc_exc.DestinationModified(_fs_name(snapname))
    if ret == errno.EBUSY:
        raise lzc_exc.DatasetBusy(_fs_name(snapname))
    if ret == errno.ENOSPC:
        raise lzc_exc.NoSpace(_fs_name(snapname))
    if ret == errno.EDQUOT:
        raise lzc_exc.QuotaExceeded(_fs_name(snapname))
    if ret == errno.ENAMETOOLONG:
        raise lzc_exc.NameTooLong(snapname)
    if ret == errno.EROFS:
        raise lzc_exc.ReadOnlyPool(_pool_name(snapname))
    if ret == errno.EAGAIN:
        raise lzc_exc.SuspendedPool(_pool_name(snapname))

    raise lzc_exc.StreamIOError(ret) 
开发者ID:ClusterHQ,项目名称:pyzfs,代码行数:41,代码来源:_error_translation.py

示例14: test_create_dir_doesnt_exist_but_raises

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def test_create_dir_doesnt_exist_but_raises(self, mock_os, mock_path):
        mock_path.exists.return_value = False
        mock_os.makedirs.side_effect = OSError(errno.ENAMETOOLONG, "nametoolong")
        with self.assertRaises(OSError):
            create_dir("testpath")
        self.assertTrue(
            mock_os.makedirs.called, "Failed to make directories if path not present."
        ) 
开发者ID:upsidetravel,项目名称:bucket-antivirus-function,代码行数:10,代码来源:common_test.py

示例15: createLink

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENAMETOOLONG [as 别名]
def createLink(metric, file_path):
    metric_path = getMetricPath(metric)
    try:
        _createLinkHelper(metric_path, file_path)
    except OSError as exc:
        if exc.errno == errno.ENAMETOOLONG:
            pass
        else:
            raise 
开发者ID:douban,项目名称:Kenshin,代码行数:11,代码来源:storage.py


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