More PEP8 fixes
This commit is contained in:
parent
eff29fca5d
commit
386b42c176
|
@ -18,7 +18,8 @@
|
|||
# Glance documentation build configuration file, created by
|
||||
# sphinx-quickstart on Tue May 18 13:50:15 2010.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
# This file is execfile()'d with the current directory set to it's containing
|
||||
# dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
|
@ -26,7 +27,8 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
|
@ -36,11 +38,17 @@ sys.path.append([os.path.abspath('../glance'),
|
|||
os.path.abspath('../bin')
|
||||
])
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.ifconfig',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.pngmath',
|
||||
'sphinx.ext.todo']
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig']
|
||||
todo_include_todos = True
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
@ -89,7 +97,7 @@ release = '1.0.2'
|
|||
# for source files.
|
||||
exclude_trees = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
# The reST default role (for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
|
@ -110,7 +118,7 @@ pygments_style = 'sphinx'
|
|||
modindex_common_prefix = ['glance.']
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. Major themes that come with
|
||||
# Sphinx are currently 'default' and 'sphinxdoc'.
|
||||
|
@ -185,7 +193,7 @@ html_static_path = ['_static']
|
|||
htmlhelp_basename = 'glancedoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
#latex_paper_size = 'letter'
|
||||
|
@ -194,7 +202,8 @@ htmlhelp_basename = 'glancedoc'
|
|||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
# (source start file, target name, title, author,
|
||||
# documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Glance.tex', u'Glance Documentation',
|
||||
u'Glance Team', 'manual'),
|
||||
|
@ -221,4 +230,3 @@ latex_documents = [
|
|||
intersphinx_mapping = {'python': ('http://docs.python.org/', None),
|
||||
'nova': ('http://nova.openstack.org', None),
|
||||
'swift': ('http://swift.openstack.org', None)}
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ def stub_out_swift_backend(stubs):
|
|||
"""
|
||||
class FakeSwiftAuth(object):
|
||||
pass
|
||||
|
||||
class FakeSwiftConnection(object):
|
||||
pass
|
||||
|
||||
|
|
|
@ -54,21 +54,23 @@ class FakeSocket(object):
|
|||
def makefile(self, mode, flags):
|
||||
return self._wbuffer
|
||||
|
||||
|
||||
class TrackerSocket(FakeSocket):
|
||||
def write(self, data):
|
||||
self._wbuffer.write(data)
|
||||
|
||||
def read(self, length=-1):
|
||||
return self._rbuffer.read(length)
|
||||
|
||||
def _create_GET_account_content(self, path, args):
|
||||
if args.has_key('format') and args['format'] == 'json':
|
||||
if 'format' in args and args['format'] == 'json':
|
||||
containers = []
|
||||
containers.append('[\n');
|
||||
containers.append('[\n')
|
||||
containers.append('{"name":"container1","count":2,"bytes":78},\n')
|
||||
containers.append('{"name":"container2","count":1,"bytes":39},\n')
|
||||
containers.append('{"name":"container3","count":3,"bytes":117}\n')
|
||||
containers.append(']\n')
|
||||
elif args.has_key('format') and args['format'] == 'xml':
|
||||
elif 'format' in args and args['format'] == 'xml':
|
||||
containers = []
|
||||
containers.append('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
containers.append('<account name="FakeAccount">\n')
|
||||
|
@ -89,12 +91,12 @@ class TrackerSocket(FakeSocket):
|
|||
def _create_GET_container_content(self, path, args):
|
||||
left = 0
|
||||
right = 9
|
||||
if args.has_key('offset'):
|
||||
if 'offset' in args:
|
||||
left = int(args['offset'])
|
||||
if args.has_key('limit'):
|
||||
if 'limit' in args:
|
||||
right = left + int(args['limit'])
|
||||
|
||||
if args.has_key('format') and args['format'] == 'json':
|
||||
if 'format' in args and args['format'] == 'json':
|
||||
objects = []
|
||||
objects.append('{"name":"object1",'
|
||||
'"hash":"4281c348eaf83e70ddce0e07221c3d28",'
|
||||
|
@ -137,7 +139,7 @@ class TrackerSocket(FakeSocket):
|
|||
'"content_type":"application\/octet-stream",'
|
||||
'"last_modified":"2007-03-04 20:32:17"}')
|
||||
output = '[\n%s\n]\n' % (',\n'.join(objects[left:right]))
|
||||
elif args.has_key('format') and args['format'] == 'xml':
|
||||
elif 'format' in args and args['format'] == 'xml':
|
||||
objects = []
|
||||
objects.append('<object><name>object1</name>'
|
||||
'<hash>4281c348eaf83e70ddce0e07221c3d28</hash>'
|
||||
|
@ -198,7 +200,7 @@ class TrackerSocket(FakeSocket):
|
|||
output = ''.join(objects)
|
||||
|
||||
# prefix/path don't make much sense given our test data
|
||||
if args.has_key('prefix') or args.has_key('path'):
|
||||
if 'prefix' in args or 'path' in args:
|
||||
pass
|
||||
return output
|
||||
|
||||
|
|
|
@ -327,7 +327,8 @@ class TestGlanceAPI(unittest.TestCase):
|
|||
req = webob.Request.blank("/images/2")
|
||||
req.method = 'GET'
|
||||
res = req.get_response(server.API())
|
||||
self.assertEquals(res.status_int, webob.exc.HTTPNotFound.code, res.body)
|
||||
self.assertEquals(res.status_int, webob.exc.HTTPNotFound.code,
|
||||
res.body)
|
||||
|
||||
def test_delete_non_exists_image(self):
|
||||
req = webob.Request.blank("/images/42")
|
||||
|
|
|
@ -27,7 +27,9 @@ from tests import stubs
|
|||
|
||||
Backend.CHUNKSIZE = 2
|
||||
|
||||
|
||||
class TestBackend(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""Establish a clean test environment"""
|
||||
self.stubs = stubout.StubOutForTesting()
|
||||
|
@ -93,7 +95,7 @@ class TestSwiftBackend(TestBackend):
|
|||
|
||||
def test_get(self):
|
||||
|
||||
swift_uri = "swift://user:password@localhost/container1/file.tar.gz"
|
||||
swift_uri = "swift://user:pass@localhost/container1/file.tar.gz"
|
||||
expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s',
|
||||
'ho', 'rt', ' a', 'nd', ' s', 'to', 'ut', '\n']
|
||||
|
||||
|
@ -114,7 +116,7 @@ class TestSwiftBackend(TestBackend):
|
|||
|
||||
def test_url_parsing(self):
|
||||
|
||||
swift_uri = "swift://user:password@localhost/v1.0/container1/file.tar.gz"
|
||||
swift_uri = "swift://user:pass@localhost/v1.0/container1/file.tar.gz"
|
||||
|
||||
parsed_uri = urlparse.urlparse(swift_uri)
|
||||
|
||||
|
@ -122,7 +124,7 @@ class TestSwiftBackend(TestBackend):
|
|||
SwiftBackend._parse_swift_tokens(parsed_uri)
|
||||
|
||||
self.assertEqual(user, 'user')
|
||||
self.assertEqual(key, 'password')
|
||||
self.assertEqual(key, 'pass')
|
||||
self.assertEqual(authurl, 'https://localhost/v1.0')
|
||||
self.assertEqual(container, 'container1')
|
||||
self.assertEqual(obj, 'file.tar.gz')
|
||||
|
|
|
@ -32,6 +32,7 @@ VENV = os.path.join(ROOT, '.glance-venv')
|
|||
PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires')
|
||||
TWISTED_NOVA = 'http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz'
|
||||
|
||||
|
||||
def die(message, *args):
|
||||
print >>sys.stderr, message % args
|
||||
sys.exit(1)
|
||||
|
@ -54,8 +55,10 @@ def run_command(cmd, redirect_output=True, check_exit_code=True):
|
|||
return output
|
||||
|
||||
|
||||
HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'], check_exit_code=False).strip())
|
||||
HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'], check_exit_code=False).strip())
|
||||
HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
|
||||
check_exit_code=False).strip())
|
||||
HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
|
||||
check_exit_code=False).strip())
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
|
@ -67,8 +70,9 @@ def check_dependencies():
|
|||
if HAS_EASY_INSTALL:
|
||||
print 'Installing virtualenv via easy_install...',
|
||||
if not run_command(['which', 'easy_install']):
|
||||
die('ERROR: virtualenv not found.\n\nGlance development requires virtualenv,'
|
||||
' please install it using your favorite package management tool')
|
||||
die('ERROR: virtualenv not found.\n\n'
|
||||
'Glance development requires virtualenv, please install'
|
||||
' it using your favorite package management tool')
|
||||
print 'done.'
|
||||
print 'done.'
|
||||
|
||||
|
@ -91,15 +95,17 @@ def install_dependencies(venv=VENV):
|
|||
|
||||
# Install greenlet by hand - just listing it in the requires file does not
|
||||
# get it in stalled in the right order
|
||||
run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, 'greenlet'],
|
||||
venv_tool = 'tools/with_venv.sh'
|
||||
run_command([venv_tool, 'pip', 'install', '-E', venv, 'greenlet'],
|
||||
redirect_output=False)
|
||||
run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
|
||||
run_command([venv_tool, 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
|
||||
redirect_output=False)
|
||||
run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, TWISTED_NOVA],
|
||||
run_command([venv_tool, 'pip', 'install', '-E', venv, TWISTED_NOVA],
|
||||
redirect_output=False)
|
||||
|
||||
# Tell the virtual env how to "import glance"
|
||||
pthfile = os.path.join(venv, "lib", "python2.6", "site-packages", "glance.pth")
|
||||
pthfile = os.path.join(venv, "lib", "python2.6", "site-packages",
|
||||
"glance.pth")
|
||||
f = open(pthfile, 'w')
|
||||
f.write("%s\n" % ROOT)
|
||||
|
||||
|
|
Loading…
Reference in New Issue