本文整理汇总了Python中settings.getProperty函数的典型用法代码示例。如果您正苦于以下问题:Python getProperty函数的具体用法?Python getProperty怎么用?Python getProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapped
def wrapped(*args, **kwargs):
try:
return fn(*args, **kwargs)
except requests.exceptions.HTTPError as e:
if e.response.status_code == 401:
authorizeUser()
return fn(*args, **kwargs)
else:
raise
except github.BadCredentialsException:
logger.debug("github: bad credentials")
authorizeUser()
logger.debug('trying with authtoken:', settings.getProperty('github', 'authtoken'))
return fn(*args, **kwargs)
except github.UnknownObjectException:
logger.debug("github: unknown object")
# some endpoints return 404 if the user doesn't have access, maybe
# it would be better to prompt for another username and password,
# and store multiple tokens that we can try for each request....
# but for now we assume that if the user is logged in then a 404
# really is a 404
if not _userAuthorized():
logger.info('failed to fetch Github object, re-trying with authentication...')
authorizeUser()
return fn(*args, **kwargs)
else:
raise
示例2: _getTarball
def _getTarball(url, into_directory, cache_key, origin_info=None):
'''unpack the specified tarball url into the specified directory'''
try:
access_common.unpackFromCache(cache_key, into_directory)
except KeyError as e:
tok = settings.getProperty('github', 'authtoken')
headers = {}
if tok is not None:
headers['Authorization'] = 'token ' + str(tok)
logger.debug('GET %s', url)
response = requests.get(url, allow_redirects=True, stream=True, headers=headers)
response.raise_for_status()
logger.debug('getting file: %s', url)
logger.debug('headers: %s', response.headers)
response.raise_for_status()
# github doesn't exposes hashes of the archives being downloaded as far
# as I can tell :(
access_common.unpackTarballStream(
stream = response,
into_directory = into_directory,
hash = {},
cache_key = cache_key,
origin_info = origin_info
)
示例3: _getTags
def _getTags(repo):
''' return a dictionary of {tag: tarball_url}'''
g = Github(settings.getProperty('github', 'authtoken'))
logger.info('get versions for ' + repo)
repo = g.get_repo(repo)
tags = repo.get_tags()
return {t.name: t.tarball_url for t in tags}
示例4: wrapped
def wrapped(*args, **kwargs):
try:
return fn(*args, **kwargs)
except restkit_errors.Unauthorized as e:
github_access.authorizeUser()
logger.debug('trying with authtoken:', settings.getProperty('github', 'authtoken'))
return fn(*args, **kwargs)
示例5: getPublicKey
def getPublicKey(registry=None):
''' Return the user's public key (generating and saving a new key pair if necessary) '''
registry = registry or Registry_Base_URL
pubkey_pem = None
if _isPublicRegistry(registry):
pubkey_pem = settings.getProperty('keys', 'public')
else:
for s in _getSources():
if _sourceMatches(s, registry):
if 'keys' in s and s['keys'] and 'public' in s['keys']:
pubkey_pem = s['keys']['public']
break
if not pubkey_pem:
pubkey_pem, privatekey_pem = _generateAndSaveKeys()
else:
# settings are unicode, we should be able to safely decode to ascii for
# the key though, as it will either be hex or PEM encoded:
pubkey_pem = pubkey_pem.encode('ascii')
# if the key doesn't look like PEM, it might be hex-encided-DER (which we
# used historically), so try loading that:
if b'-----BEGIN PUBLIC KEY-----' in pubkey_pem:
pubkey = serialization.load_pem_public_key(pubkey_pem, default_backend())
else:
pubkey_der = binascii.unhexlify(pubkey_pem)
pubkey = serialization.load_der_public_key(pubkey_der, default_backend())
return _pubkeyWireFormat(pubkey)
示例6: _getTags
def _getTags(repo):
""" return a dictionary of {tag: tarball_url}"""
logger.debug("get tags for %s", repo)
g = Github(settings.getProperty("github", "authtoken"))
repo = g.get_repo(repo)
tags = repo.get_tags()
logger.debug("tags for %s: %s", repo, [t.name for t in tags])
return {t.name: t.tarball_url for t in tags}
示例7: _getTags
def _getTags(repo):
''' return a dictionary of {tag: tarball_url}'''
logger.debug('get tags for %s', repo)
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
tags = repo.get_tags()
logger.debug('tags for %s: %s', repo, [t.name for t in tags])
return {t.name: _ensureDomainPrefixed(t.tarball_url) for t in tags}
示例8: _getTarball
def _getTarball(url, into_directory):
'''unpack the specified tarball url into the specified directory'''
resource = Resource(url, pool=connection_pool.getPool(), follow_redirect=True)
response = resource.get(
headers = {'Authorization': 'token ' + settings.getProperty('github', 'authtoken')},
)
logger.debug('getting file: %s', url)
# TODO: there's an MD5 in the response headers, verify it
access_common.unpackTarballStream(response.body_stream(), into_directory)
示例9: _getPrivateKey
def _getPrivateKey(registry):
if _isPublicRegistry(registry):
return settings.getProperty("keys", "private")
else:
for s in _getSources():
if _sourceMatches(s, registry):
if "keys" in s and s["keys"] and "private" in s["keys"]:
return s["keys"]["private"]
return None
示例10: retryWithAuthOrRaise
def retryWithAuthOrRaise(original_exception):
# in all cases ask for auth, so that in non-interactive mode a
# login URL is displayed
auth.authorizeUser(provider='github', interactive=interactive)
if not interactive:
raise original_exception
else:
logger.debug('trying with authtoken: %s', settings.getProperty('github', 'authtoken'))
return fn(*args, **kwargs)
示例11: _getTarball
def _getTarball(url, into_directory):
'''unpack the specified tarball url into the specified directory'''
headers = {'Authorization': 'token ' + str(settings.getProperty('github', 'authtoken'))}
response = requests.get(url, allow_redirects=True, stream=True, headers=headers)
logger.debug('getting file: %s', url)
# TODO: there's an MD5 in the response headers, verify it
access_common.unpackTarballStream(response, into_directory)
示例12: getPublicKey
def getPublicKey():
''' Return the user's public key (generating and saving a new key pair if necessary) '''
pubkey_hex = settings.getProperty('keys', 'public')
if not pubkey_hex:
k = RSA.generate(2048)
settings.setProperty('keys', 'private', binascii.hexlify(k.exportKey('DER')))
pubkey_hex = binascii.hexlify(k.publickey().exportKey('DER'))
settings.setProperty('keys', 'public', pubkey_hex)
pubkey_hex, privatekey_hex = _generateAndSaveKeys()
return _pubkeyWireFormat(RSA.importKey(binascii.unhexlify(pubkey_hex)))
示例13: _getBranchHeads
def _getBranchHeads(repo):
g = Github(settings.getProperty('github', 'authtoken'))
repo = g.get_repo(repo)
branches = repo.get_branches()
# branch tarball URLs aren't supported by the API, so have to munge the
# master tarball URL. Fetch the master tarball URL once (since that
# involves a network request), then mumge it for each branch we want:
master_tarball_url = repo.get_archive_link('tarball')
return {b.name:_tarballUrlForBranch(master_tarball_url, b.name) for b in branches}
示例14: wrapped
def wrapped(*args, **kwargs):
try:
return fn(*args, **kwargs)
except requests.exceptions.HTTPError as e:
if e.response.status_code == requests.codes.unauthorized:
logger.debug('%s unauthorised', fn)
github_access.authorizeUser()
logger.debug('trying with authtoken: %s', settings.getProperty('github', 'authtoken'))
return fn(*args, **kwargs)
else:
raise
示例15: _getTarball
def _getTarball(url, into_directory):
'''unpack the specified tarball url into the specified directory'''
tok = settings.getProperty('github', 'authtoken')
headers = {}
if tok is not None:
headers['Authorization'] = 'token ' + str(tok)
logger.debug('GET %s', url)
response = requests.get(url, allow_redirects=True, stream=True, headers=headers)
response.raise_for_status()
logger.debug('getting file: %s', url)
# TODO: there's an MD5 in the response headers, verify it
access_common.unpackTarballStream(response, into_directory)