本文整理汇总了Python中Tardis.Util.checkPasswordStrength方法的典型用法代码示例。如果您正苦于以下问题:Python Util.checkPasswordStrength方法的具体用法?Python Util.checkPasswordStrength怎么用?Python Util.checkPasswordStrength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tardis.Util
的用法示例。
在下文中一共展示了Util.checkPasswordStrength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import checkPasswordStrength [as 别名]
def main():
global logger
parseArgs()
logger = Util.setupLogging(args.verbose)
# Commands which cannot be executed on remote databases
allowRemote = args.command not in ['create', 'upgrade']
db = None
crypt = None
cache = None
try:
confirm = args.command in ['setpass', 'create']
allowNone = args.command not in ['setpass', 'chpass']
try:
password = Util.getPassword(args.password, args.passwordfile, args.passwordprog, prompt="Password for %s: " % (args.client), allowNone=allowNone, confirm=confirm)
except Exception as e:
logger.critical(str(e))
if args.exceptions:
logger.exception(e)
return -1
if password:
crypt = TardisCrypto.TardisCrypto(password, args.client)
args.password = None
if args.command == 'create':
return createClient(crypt, password)
if args.command == 'setpass':
if not Util.checkPasswordStrength(password):
return -1
if not crypt:
logger.error("No password specified")
return -1
return setPassword(crypt, password)
if args.command == 'chpass':
return changePassword(crypt, password)
upgrade = (args.command == 'upgrade')
try:
(db, cache, crypt) = getDB(crypt, password, allowRemote=allowRemote, allowUpgrade=upgrade)
if crypt and args.command != 'keys':
if args.keys:
(f, c) = Util.loadKeys(args.keys, db.getConfigValue('ClientID'))
else:
(f, c) = db.getKeys()
crypt.setKeys(f, c)
except TardisDB.AuthenticationException as e:
logger.error("Authentication failed. Bad password")
if args.exceptions:
logger.exception(e)
sys.exit(1)
except Exception as e:
logger.critical("Unable to connect to database: %s", e)
if args.exceptions:
logger.exception(e)
sys.exit(1)
if args.command == 'keys':
return moveKeys(db, crypt)
elif args.command == 'list':
return listBSets(db, crypt, cache)
elif args.command == 'files':
return listFiles(db, crypt)
elif args.command == 'info':
return bsetInfo(db)
elif args.command == 'purge':
return purge(db, cache)
elif args.command == 'delete':
return deleteBsets(db, cache)
elif args.command == 'priority':
return setPriority(db)
elif args.command == 'rename':
return renameSet(db)
elif args.command == 'getconfig':
return getConfig(db)
elif args.command == 'setconfig':
return setConfig(db)
elif args.command == 'orphans':
return removeOrphans(db, cache)
elif args.command == 'upgrade':
return
except KeyboardInterrupt:
pass
except TardisDB.AuthenticationException as e:
logger.error("Authentication failed. Bad password")
sys.exit(1)
except Exception as e:
logger.error("Caught exception: %s", str(e))
if args.exceptions:
logger.exception(e)
finally:
if db:
db.close()