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


Python rarfile.UNRAR_TOOL属性代码示例

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


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

示例1: _open_unrar

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def _open_unrar(self, rarfile, inf, psw=None, tmpfile=None, force_file=False):
        cmd = [UNRAR_TOOL] + list(OPEN_ARGS)
        add_password_arg(cmd, psw)
        cmd.append("--")
        cmd.append(rarfile)

        # not giving filename avoids encoding related problems
        if not tmpfile or force_file:
            fn = inf.filename
            if PATH_SEP != os.sep:
                fn = fn.replace(PATH_SEP, os.sep)
            cmd.append(fn)

        # read from unrar pipe
        return PipeReader(self, inf, cmd, tmpfile)

#
# RAR3 format
# 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:21,代码来源:rarfile.py

示例2: custom_popen

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def custom_popen(cmd):
    """Disconnect cmd from parent fds, read only from stdout.
    """
    # needed for py2exe
    creationflags = 0
    if sys.platform == 'win32':
        creationflags = 0x08000000   # CREATE_NO_WINDOW

    # run command
    try:
        p = Popen(cmd, bufsize=0, stdout=PIPE, stdin=PIPE, stderr=STDOUT,
                  creationflags=creationflags)
    except OSError as ex:
        if ex.errno == errno.ENOENT:
            raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
        if ex.errno == errno.EACCES or ex.errno == errno.EPERM:
            raise RarCannotExec("Cannot execute unrar (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
        raise
    return p 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:21,代码来源:rarfile.py

示例3: _check_unrar_tool

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def _check_unrar_tool():
    global UNRAR_TOOL, OPEN_ARGS, EXTRACT_ARGS, TEST_ARGS
    try:
        # does UNRAR_TOOL work?
        custom_check([ORIG_UNRAR_TOOL], True)

        UNRAR_TOOL = ORIG_UNRAR_TOOL
        OPEN_ARGS = ORIG_OPEN_ARGS
        EXTRACT_ARGS = ORIG_EXTRACT_ARGS
        TEST_ARGS = ORIG_TEST_ARGS
    except RarCannotExec:
        try:
            # does ALT_TOOL work?
            custom_check([ALT_TOOL] + list(ALT_CHECK_ARGS), True)
            # replace config
            UNRAR_TOOL = ALT_TOOL
            OPEN_ARGS = ALT_OPEN_ARGS
            EXTRACT_ARGS = ALT_EXTRACT_ARGS
            TEST_ARGS = ALT_TEST_ARGS
        except RarCannotExec:
            # no usable tool, only uncompressed archives work
            return False
    return True 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:25,代码来源:rarfile.py

示例4: custom_popen

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def custom_popen(cmd):
    """Disconnect cmd from parent fds, read only from stdout.
    """
    # needed for py2exe
    creationflags = 0
    if sys.platform == 'win32':
        creationflags = 0x08000000   # CREATE_NO_WINDOW

    # run command
    try:
        p = Popen(cmd, bufsize=0, stdout=PIPE, stdin=PIPE, stderr=STDOUT,
                  creationflags=creationflags)
    except OSError as ex:
        if ex.errno == errno.ENOENT:
            raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
        raise
    return p 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:19,代码来源:rarfile.py

示例5: _check_unrar_tool

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def _check_unrar_tool():
    global UNRAR_TOOL, OPEN_ARGS, EXTRACT_ARGS, TEST_ARGS
    try:
        # does UNRAR_TOOL work?
        custom_check([ORIG_UNRAR_TOOL], True)

        UNRAR_TOOL = ORIG_UNRAR_TOOL
        OPEN_ARGS = ORIG_OPEN_ARGS
        EXTRACT_ARGS = ORIG_EXTRACT_ARGS
        TEST_ARGS = ORIG_TEST_ARGS
    except RarCannotExec:
        try:
            # does ALT_TOOL work?
            custom_check([ALT_TOOL] + list(ALT_CHECK_ARGS), True)
            # replace config
            UNRAR_TOOL = ALT_TOOL
            OPEN_ARGS = ALT_OPEN_ARGS
            EXTRACT_ARGS = ALT_EXTRACT_ARGS
            TEST_ARGS = ALT_TEST_ARGS
        except RarCannotExec:
            # no usable tool, only uncompressed archives work
            pass 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:24,代码来源:rarfile.py

示例6: read

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def read(self, fname, psw=None):
        """
        read specific content of rarfile without parsing
        :param fname:
        :param psw:
        :return:
        """
        cmd = [rarfile.UNRAR_TOOL] + list(rarfile.ORIG_OPEN_ARGS)

        with rarfile.XTempFile(self._rarfile) as rf:
            log.debug(u"RAR CMD: %s", cmd + [rf, fname])
            p = rarfile.custom_popen(cmd + [rf, fname])
            output = p.communicate()[0]
            rarfile.check_returncode(p, output)

            return output 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:18,代码来源:rar.py

示例7: init_binaries

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def init_binaries():
    from utils import get_binary
    exe = get_binary("unrar")
    
    rarfile.UNRAR_TOOL = exe
    rarfile.ORIG_UNRAR_TOOL = exe
    try:
        rarfile.custom_check([rarfile.UNRAR_TOOL], True)
    except:
        logging.debug("custom check failed for: %s", exe)
    
    rarfile.OPEN_ARGS = rarfile.ORIG_OPEN_ARGS
    rarfile.EXTRACT_ARGS = rarfile.ORIG_EXTRACT_ARGS
    rarfile.TEST_ARGS = rarfile.ORIG_TEST_ARGS
    logging.debug("Using UnRAR from: %s", exe)
    unrar = exe
    
    return unrar 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:20,代码来源:init.py

示例8: testrar

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def testrar(self):
        """Let 'unrar' test the archive.
        """
        cmd = [UNRAR_TOOL] + list(TEST_ARGS)
        add_password_arg(cmd, self._password)
        cmd.append('--')

        if is_filelike(self.rarfile):
            tmpname = membuf_tempfile(self.rarfile)
            cmd.append(tmpname)
        else:
            tmpname = None
            cmd.append(self.rarfile)

        try:
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output)
        finally:
            if tmpname:
                os.unlink(tmpname) 
开发者ID:entynetproject,项目名称:arissploit,代码行数:23,代码来源:rarfile.py

示例9: _open_unrar

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def _open_unrar(self, rarfile, inf, psw = None, tmpfile = None):
        if is_filelike(rarfile):
            raise ValueError("Cannot use unrar directly on memory buffer")
        cmd = [UNRAR_TOOL] + list(OPEN_ARGS)
        add_password_arg(cmd, psw)
        cmd.append("--")
        cmd.append(rarfile)

        # not giving filename avoids encoding related problems
        if not tmpfile:
            fn = inf.filename
            if PATH_SEP != os.sep:
                fn = fn.replace(PATH_SEP, os.sep)
            cmd.append(fn)

        # read from unrar pipe
        return PipeReader(self, inf, cmd, tmpfile) 
开发者ID:entynetproject,项目名称:arissploit,代码行数:19,代码来源:rarfile.py

示例10: custom_popen

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def custom_popen(cmd):
    """Disconnect cmd from parent fds, read only from stdout."""

    # needed for py2exe
    creationflags = 0
    if sys.platform == 'win32':
        creationflags = 0x08000000 # CREATE_NO_WINDOW

    # run command
    try:
        p = Popen(cmd, bufsize = 0,
                  stdout = PIPE, stdin = PIPE, stderr = STDOUT,
                  creationflags = creationflags)
    except OSError as ex:
        if ex.errno == errno.ENOENT:
            raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
        raise
    return p 
开发者ID:entynetproject,项目名称:arissploit,代码行数:20,代码来源:rarfile.py

示例11: testrar

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def testrar(self):
        """Let 'unrar' test the archive.
        """
        cmd = [UNRAR_TOOL] + list(TEST_ARGS)
        add_password_arg(cmd, self._password)
        cmd.append('--')
        with XTempFile(self._rarfile) as rarfile:
            cmd.append(rarfile)
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output) 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:13,代码来源:rarfile.py

示例12: _extract

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def _extract(self, fnlist, path=None, psw=None):
        cmd = [UNRAR_TOOL] + list(EXTRACT_ARGS)

        # pasoword
        psw = psw or self._password
        add_password_arg(cmd, psw)
        cmd.append('--')

        # rar file
        with XTempFile(self._rarfile) as rarfn:
            cmd.append(rarfn)

            # file list
            for fn in fnlist:
                if os.sep != PATH_SEP:
                    fn = fn.replace(PATH_SEP, os.sep)
                cmd.append(fn)

            # destination path
            if path is not None:
                cmd.append(path + os.sep)

            # call
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output)

#
# File format parsing
# 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:32,代码来源:rarfile.py

示例13: check_returncode

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def check_returncode(p, out):
    """Raise exception according to unrar exit code.
    """
    code = p.returncode
    if code == 0:
        return

    # map return code to exception class, codes from rar.txt
    errmap = [None,
              RarWarning, RarFatalError, RarCRCError, RarLockedArchiveError,    # 1..4
              RarWriteError, RarOpenError, RarUserError, RarMemoryError,        # 5..8
              RarCreateError, RarNoFilesError, RarWrongPassword]                # 9..11
    if UNRAR_TOOL == ALT_TOOL:
        errmap = [None]
    if code > 0 and code < len(errmap):
        exc = errmap[code]
    elif code == 255:
        exc = RarUserBreak
    elif code < 0:
        exc = RarSignalExit
    else:
        exc = RarUnknownError

    # format message
    if out:
        msg = "%s [%d]: %s" % (exc.__doc__, p.returncode, out)
    else:
        msg = "%s [%d]" % (exc.__doc__, p.returncode)

    raise exc(msg) 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:32,代码来源:rarfile.py

示例14: __init__

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def __init__(self):
		# Set the unrar tool based on filesystem
		if os.getenv('TENMA_UNRAR_PATH'):
			rarfile.UNRAR_TOOL = os.getenv('TENMA_UNRAR_PATH')
		elif sys.platform == 'win32':		# Windows
			rarfile.UNRAR_TOOL = os.path.dirname(comics.__file__) + "/utils/unrar/unrar.exe"
		elif sys.platform == 'darwin':	# Mac
			rarfile.UNRAR_TOOL = os.path.dirname(comics.__file__) + "/utils/unrar/unrar_mac"
		elif sys.platform == 'linux':	# Linux
			rarfile.UNRAR_TOOL = os.path.dirname(comics.__file__) + "/utils/unrar/unrar-nonfree_ubuntu"

	#================================================================================================== 
开发者ID:Tenma-Server,项目名称:Tenma,代码行数:14,代码来源:comicfilehandler.py

示例15: _extract

# 需要导入模块: import rarfile [as 别名]
# 或者: from rarfile import UNRAR_TOOL [as 别名]
def _extract(self, fnlist, path=None, psw=None):
        cmd = [UNRAR_TOOL] + list(EXTRACT_ARGS)

        # pasoword
        psw = psw or self._password
        add_password_arg(cmd, psw)
        cmd.append('--')

        # rar file
        with XTempFile(self._rarfile) as rarfn:
            cmd.append(rarfn)

            # file list
            for fn in fnlist:
                if os.sep != PATH_SEP:
                    fn = fn.replace(PATH_SEP, os.sep)
                cmd.append(fn)

            # destination path
            if path is not None:
                if _have_pathlib and isinstance(path, Path):
                    path = str(path)
                #cmd.append(path + os.sep)
                cmd.append(path)

            # call
            p = custom_popen(cmd)
            output = p.communicate()[0]
            check_returncode(p, output)

#
# File format parsing
# 
开发者ID:alfa-addon,项目名称:addon,代码行数:35,代码来源:rarfile.py


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