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


Python getpass.GetPassWarning方法代码示例

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


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

示例1: run_extract

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import GetPassWarning [as 别名]
def run_extract(self, args: argparse.Namespace) -> int:
        target = args.arcfile
        verbose = args.verbose
        if not py7zr.is_7zfile(target):
            print('not a 7z file')
            return(1)
        if not args.password:
            password = None  # type: Optional[str]
        else:
            try:
                password = getpass.getpass()
            except getpass.GetPassWarning:
                sys.stderr.write('Warning: your password may be shown.\n')
                return(1)
        a = py7zr.SevenZipFile(target, 'r', password=password)
        cb = None  # Optional[ExtractCallback]
        if verbose:
            archive_info = a.archiveinfo()
            cb = CliExtractCallback(total_bytes=archive_info.uncompressed, ofd=sys.stderr)
        if args.odir:
            a.extractall(path=args.odir, callback=cb)
        else:
            a.extractall(callback=cb)
        return(0) 
开发者ID:miurahr,项目名称:py7zr,代码行数:26,代码来源:cli.py

示例2: fix_get_pass

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import GetPassWarning [as 别名]
def fix_get_pass():
        try:
            import getpass
        except ImportError:
            return #If we can't import it, we can't fix it
        import warnings
        fallback = getattr(getpass, 'fallback_getpass', None) # >= 2.6
        if not fallback:
            fallback = getpass.default_getpass # <= 2.5
        getpass.getpass = fallback
        if hasattr(getpass, 'GetPassWarning'):
            warnings.simplefilter("ignore", category=getpass.GetPassWarning) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:14,代码来源:sitecustomize.py

示例3: test_falls_back_to_stdin

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import GetPassWarning [as 别名]
def test_falls_back_to_stdin(self):
        with mock.patch('os.open') as os_open, \
                mock.patch('sys.stdin', spec=StringIO) as stdin:
            os_open.side_effect = IOError
            stdin.fileno.side_effect = AttributeError
            with support.captured_stderr() as stderr:
                with self.assertWarns(getpass.GetPassWarning):
                    getpass.unix_getpass()
            stdin.readline.assert_called_once_with()
            self.assertIn('Warning', stderr.getvalue())
            self.assertIn('Password:', stderr.getvalue()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_getpass.py

示例4: fix_getpass

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import GetPassWarning [as 别名]
def fix_getpass():
    try:
        import getpass
    except ImportError:
        return #If we can't import it, we can't fix it
    import warnings
    fallback = getattr(getpass, 'fallback_getpass', None) # >= 2.6
    if not fallback:
        fallback = getpass.default_getpass # <= 2.5 @UndefinedVariable
    getpass.getpass = fallback
    if hasattr(getpass, 'GetPassWarning'):
        warnings.simplefilter("ignore", category=getpass.GetPassWarning) 
开发者ID:mrknow,项目名称:filmkodi,代码行数:14,代码来源:fix_getpass.py


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