當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。