Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # Copyright 2011 - 2012 Justin Santa Barbara # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.
"""Read from a file if it has been modified.
:param cache_info: dictionary to hold opaque cache. :param reload_func: optional function to be called with data when file is reloaded due to a modification.
:returns: data from file.
"""
"""Help for JSON encoding dict-like objects.""" if not isinstance(obj, dict) and hasattr(obj, 'iteritems'): return dict(obj.iteritems()) return super(SmarterEncoder, self).default(obj)
"""Truncate passwords to the MAX_PASSWORD_LENGTH.""" else: except TypeError: raise exception.ValidationError(attribute='string', target='password')
"""Hash a user dict's password without modifying the passed-in dict.""" else:
"""Hash a user dict's password without modifying the passed-in dict.""" else:
"""Hash a password. Hard.""" rounds=CONF.crypt_strength)
"""Hash a password. Hard."""
return False
"""Check that a plaintext password matches hashed.
hashpw returns the salt value concatenated with the actual hash value. It extracts the actual salt if this value is then passed as the salt.
"""
# From python 2.7 r"""Run command with arguments and return its output as a byte string.
If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute.
The arguments are the same as for the Popen constructor. Example:
>>> check_output(['ls', '-l', '/dev/null']) 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT.
>>> import sys >>> check_output(['/bin/sh', '-c', ... 'ls -l non_existent_file ; exit 0'], ... stderr=sys.STDOUT) 'ls: non_existent_file: No such file or directory\n' """ raise ValueError('stdout argument not allowed, it will be overridden.') cmd = kwargs.get('args') if cmd is None: cmd = popenargs[0] raise subprocess.CalledProcessError(retcode, cmd)
"""Format datetime object as unix timestamp
:param dt_obj: datetime.datetime object :returns: float
"""
"""Constant-time string comparison.
:params provided: the first string :params known: the second string
:return: True if the strings are equal.
This function takes two strings and compares them. It is intended to be used when doing a comparison for authentication purposes to help guard against timing attacks. When using the function for this purpose, always provide the user-provided password as the first argument. The time this function will take is always a factor of the length of this string. """
hash_ = hashlib.md5() hash_.update(signed_text) return hash_.hexdigest()
if CONF.pydev_debug_host and CONF.pydev_debug_port: try: try: from pydev import pydevd except ImportError: import pydevd
pydevd.settrace(CONF.pydev_debug_host, port=CONF.pydev_debug_port, stdoutToServer=True, stderrToServer=True) return True except Exception: LOG.exception(_( 'Error setting up the debug environment. Verify that the ' 'option --debug-url has the format <host>:<port> and that a ' 'debugger processes is listening on that port.')) raise
"""Reader to limit the size of an incoming request.""" """Create an iterator on the underlying data.
:param data: Underlying data object :param limit: maximum number of bytes the reader should allow """
for chunk in self.data: self.bytes_read += len(chunk) if self.bytes_read > self.limit: raise exception.RequestTooLarge() else: yield chunk
|