本文整理汇总了Python中Tardis.Util.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Python Util.authenticate方法的具体用法?Python Util.authenticate怎么用?Python Util.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tardis.Util
的用法示例。
在下文中一共展示了Util.authenticate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import authenticate [as 别名]
def main():
global logger
progressbar.streams.wrap_stderr()
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('')
args = processArgs()
password = Util.getPassword(args.password, args.passwordfile, args.passwordprog, allowNone=False)
crypto = TardisCrypto.TardisCrypto(password, args.client)
path = os.path.join(args.database, args.client, args.dbname)
db = TardisDB.TardisDB(path, backup=False)
Util.authenticate(db, args.client, password)
(f, c) = db.getKeys()
crypto.setKeys(f, c)
cacheDir = CacheDir.CacheDir(os.path.join(args.database, args.client))
if args.names or args.all:
encryptFilenames(db, crypto)
if args.dirs or args.all:
generateDirHashes(db, crypto, cacheDir)
if args.sigs or args.all:
generateSignatures(db, crypto, cacheDir)
if args.files or args.all:
encryptFiles(db, crypto, cacheDir)
if args.meta or args.all:
generateMetadata(db, cacheDir)
示例2: getDB
# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import authenticate [as 别名]
def getDB(crypt, password, new=False, allowRemote=True, allowUpgrade=False):
loc = urllib.parse.urlparse(args.database)
# This is basically the same code as in Util.setupDataConnection(). Should consider moving to it.
if (loc.scheme == 'http') or (loc.scheme == 'https'):
if not allowRemote:
raise Exception("This command cannot be executed remotely. You must execute it on the server directly.")
# If no port specified, insert the port
if loc.port is None:
netloc = loc.netloc + ":" + Defaults.getDefault('TARDIS_REMOTE_PORT')
dbLoc = urllib.parse.urlunparse((loc.scheme, netloc, loc.path, loc.params, loc.query, loc.fragment))
else:
dbLoc = args.database
tardisdb = RemoteDB.RemoteDB(dbLoc, args.client)
cache = tardisdb
else:
basedir = os.path.join(args.database, args.client)
if not args.dbdir:
dbdir = os.path.join(args.database, args.client)
else:
dbdir = os.path.join(args.dbdir, args.client)
dbfile = os.path.join(dbdir, args.dbname)
if new and os.path.exists(dbfile):
raise Exception("Database for client %s already exists." % (args.client))
cache = CacheDir.CacheDir(basedir, 2, 2, create=new)
schema = args.schema if new else None
tardisdb = TardisDB.TardisDB(dbfile, backup=False, initialize=schema, allow_upgrade=allowUpgrade)
if tardisdb.needsAuthentication():
if password is None:
password = Util.getPassword(args.password, args.passwordfile, args.passwordprog, prompt="Password for %s: " % (args.client), allowNone=False, confirm=False)
crypt = TardisCrypto.TardisCrypto(password, args.client)
Util.authenticate(tardisdb, args.client, password)
return (tardisdb, cache, crypt)