Browse Source

Merge "PEP8 on the doc and elements files"

Jenkins 4 years ago
parent
commit
4562892fcf

+ 59
- 75
doc/source/conf.py View File

@@ -1,45 +1,35 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 #
3
-# TripleO Image Elements documentation build configuration file, created by
4
-# sphinx-quickstart on Fri Apr 18 09:19:09 2014.
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
5 6
 #
6
-# This file is execfile()d with the current directory set to its
7
-# containing dir.
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8 8
 #
9
-# Note that not all possible configuration values are present in this
10
-# autogenerated file.
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
11 14
 #
12
-# All configuration values have a default; values that are commented out
13
-# serve to show the default.
14
-
15
-import sys
16
-import os
17 15
 
18 16
 # If extensions (or modules to document with autodoc) are in another directory,
19 17
 # add these directories to sys.path here. If the directory is relative to the
20 18
 # documentation root, use os.path.abspath to make it absolute, like shown here.
21
-#sys.path.insert(0, os.path.abspath('.'))
19
+# sys.path.insert(0, os.path.abspath('.'))
22 20
 
23 21
 # -- General configuration ------------------------------------------------
24 22
 
25 23
 # If your documentation needs a minimal Sphinx version, state it here.
26
-#needs_sphinx = '1.0'
24
+# needs_sphinx = '1.0'
27 25
 
28 26
 # Add any Sphinx extension module names here, as strings. They can be
29 27
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30 28
 # ones.
31 29
 extensions = ['oslosphinx']
32
-
33
-# Add any paths that contain templates here, relative to this directory.
34 30
 templates_path = ['_templates']
35
-
36 31
 # The suffix of source filenames.
37 32
 source_suffix = '.rst'
38
-
39
-# The encoding of source files.
40
-#source_encoding = 'utf-8-sig'
41
-
42
-# The master toctree document.
43 33
 master_doc = 'index'
44 34
 
45 35
 # General information about the project.
@@ -57,13 +47,13 @@ release = '0.0'
57 47
 
58 48
 # The language for content autogenerated by Sphinx. Refer to documentation
59 49
 # for a list of supported languages.
60
-#language = None
50
+# language = None
61 51
 
62 52
 # There are two options for replacing |today|: either, you set today to some
63 53
 # non-false value, then it is used:
64
-#today = ''
54
+# today = ''
65 55
 # Else, today_fmt is used as the format for a strftime call.
66
-#today_fmt = '%B %d, %Y'
56
+# today_fmt = '%B %d, %Y'
67 57
 
68 58
 # List of patterns, relative to source directory, that match files and
69 59
 # directories to ignore when looking for source files.
@@ -71,27 +61,27 @@ exclude_patterns = ['_build']
71 61
 
72 62
 # The reST default role (used for this markup: `text`) to use for all
73 63
 # documents.
74
-#default_role = None
64
+# default_role = None
75 65
 
76 66
 # If true, '()' will be appended to :func: etc. cross-reference text.
77
-#add_function_parentheses = True
67
+# add_function_parentheses = True
78 68
 
79 69
 # If true, the current module name will be prepended to all description
80 70
 # unit titles (such as .. function::).
81
-#add_module_names = True
71
+# add_module_names = True
82 72
 
83 73
 # If true, sectionauthor and moduleauthor directives will be shown in the
84 74
 # output. They are ignored by default.
85
-#show_authors = False
75
+# show_authors = False
86 76
 
87 77
 # The name of the Pygments (syntax highlighting) style to use.
88 78
 pygments_style = 'sphinx'
89 79
 
90 80
 # A list of ignored prefixes for module index sorting.
91
-#modindex_common_prefix = []
81
+# modindex_common_prefix = []
92 82
 
93 83
 # If true, keep warnings as "system message" paragraphs in the built documents.
94
-#keep_warnings = False
84
+# keep_warnings = False
95 85
 
96 86
 
97 87
 # -- Options for HTML output ----------------------------------------------
@@ -103,26 +93,26 @@ html_theme = 'default'
103 93
 # Theme options are theme-specific and customize the look and feel of a theme
104 94
 # further.  For a list of options available for each theme, see the
105 95
 # documentation.
106
-#html_theme_options = {}
96
+# html_theme_options = {}
107 97
 
108 98
 # Add any paths that contain custom themes here, relative to this directory.
109
-#html_theme_path = []
99
+# html_theme_path = []
110 100
 
111 101
 # The name for this set of Sphinx documents.  If None, it defaults to
112 102
 # "<project> v<release> documentation".
113
-#html_title = None
103
+# html_title = None
114 104
 
115 105
 # A shorter title for the navigation bar.  Default is the same as html_title.
116
-#html_short_title = None
106
+# html_short_title = None
117 107
 
118 108
 # The name of an image file (relative to this directory) to place at the top
119 109
 # of the sidebar.
120
-#html_logo = None
110
+# html_logo = None
121 111
 
122 112
 # The name of an image file (within the static path) to use as favicon of the
123 113
 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
124 114
 # pixels large.
125
-#html_favicon = None
115
+# html_favicon = None
126 116
 
127 117
 # Add any paths that contain custom static files (such as style sheets) here,
128 118
 # relative to this directory. They are copied after the builtin static files,
@@ -132,48 +122,48 @@ html_static_path = ['_static']
132 122
 # Add any extra paths that contain custom files (such as robots.txt or
133 123
 # .htaccess) here, relative to this directory. These files are copied
134 124
 # directly to the root of the documentation.
135
-#html_extra_path = []
125
+# html_extra_path = []
136 126
 
137 127
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
138 128
 # using the given strftime format.
139
-#html_last_updated_fmt = '%b %d, %Y'
129
+# html_last_updated_fmt = '%b %d, %Y'
140 130
 
141 131
 # If true, SmartyPants will be used to convert quotes and dashes to
142 132
 # typographically correct entities.
143
-#html_use_smartypants = True
133
+# html_use_smartypants = True
144 134
 
145 135
 # Custom sidebar templates, maps document names to template names.
146
-#html_sidebars = {}
136
+# html_sidebars = {}
147 137
 
148 138
 # Additional templates that should be rendered to pages, maps page names to
149 139
 # template names.
150
-#html_additional_pages = {}
140
+# html_additional_pages = {}
151 141
 
152 142
 # If false, no module index is generated.
153
-#html_domain_indices = True
143
+# html_domain_indices = True
154 144
 
155 145
 # If false, no index is generated.
156
-#html_use_index = True
146
+# html_use_index = True
157 147
 
158 148
 # If true, the index is split into individual pages for each letter.
159
-#html_split_index = False
149
+# html_split_index = False
160 150
 
161 151
 # If true, links to the reST sources are added to the pages.
162
-#html_show_sourcelink = True
152
+# html_show_sourcelink = True
163 153
 
164 154
 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
165
-#html_show_sphinx = True
155
+# html_show_sphinx = True
166 156
 
167 157
 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
168
-#html_show_copyright = True
158
+# html_show_copyright = True
169 159
 
170 160
 # If true, an OpenSearch description file will be output, and all pages will
171 161
 # contain a <link> tag referring to it.  The value of this option must be the
172 162
 # base URL from which the finished HTML is served.
173
-#html_use_opensearch = ''
163
+# html_use_opensearch = ''
174 164
 
175 165
 # This is the file name suffix for HTML files (e.g. ".xhtml").
176
-#html_file_suffix = None
166
+# html_file_suffix = None
177 167
 
178 168
 # Output file base name for HTML help builder.
179 169
 htmlhelp_basename = 'TripleOImageElementsdoc'
@@ -181,44 +171,36 @@ htmlhelp_basename = 'TripleOImageElementsdoc'
181 171
 
182 172
 # -- Options for LaTeX output ---------------------------------------------
183 173
 
184
-latex_elements = {
185
-# The paper size ('letterpaper' or 'a4paper').
186
-#'papersize': 'letterpaper',
187
-
188
-# The font size ('10pt', '11pt' or '12pt').
189
-#'pointsize': '10pt',
190
-
191
-# Additional stuff for the LaTeX preamble.
192
-#'preamble': '',
193
-}
174
+latex_elements = {}
194 175
 
195 176
 # Grouping the document tree into LaTeX files. List of tuples
196 177
 # (source start file, target name, title,
197 178
 #  author, documentclass [howto, manual, or own class]).
198 179
 latex_documents = [
199
-  ('index', 'TripleOImageElements.tex', u'TripleO Image Elements Documentation',
200
-   u'OpenStack Developers', 'manual'),
180
+    ('index', 'TripleOImageElements.tex',
181
+     u'TripleO Image Elements Documentation',
182
+     u'OpenStack Developers', 'manual'),
201 183
 ]
202 184
 
203 185
 # The name of an image file (relative to this directory) to place at the top of
204 186
 # the title page.
205
-#latex_logo = None
187
+# latex_logo = None
206 188
 
207 189
 # For "manual" documents, if this is true, then toplevel headings are parts,
208 190
 # not chapters.
209
-#latex_use_parts = False
191
+# latex_use_parts = False
210 192
 
211 193
 # If true, show page references after internal links.
212
-#latex_show_pagerefs = False
194
+# latex_show_pagerefs = False
213 195
 
214 196
 # If true, show URL addresses after external links.
215
-#latex_show_urls = False
197
+# latex_show_urls = False
216 198
 
217 199
 # Documents to append as an appendix to all manuals.
218
-#latex_appendices = []
200
+# latex_appendices = []
219 201
 
220 202
 # If false, no module index is generated.
221
-#latex_domain_indices = True
203
+# latex_domain_indices = True
222 204
 
223 205
 
224 206
 # -- Options for manual page output ---------------------------------------
@@ -231,7 +213,7 @@ man_pages = [
231 213
 ]
232 214
 
233 215
 # If true, show URL addresses after external links.
234
-#man_show_urls = False
216
+# man_show_urls = False
235 217
 
236 218
 
237 219
 # -- Options for Texinfo output -------------------------------------------
@@ -240,19 +222,21 @@ man_pages = [
240 222
 # (source start file, target name, title, author,
241 223
 #  dir menu entry, description, category)
242 224
 texinfo_documents = [
243
-  ('index', 'TripleOImageElements', u'TripleO Image Elements Documentation',
244
-   u'OpenStack Developers', 'TripleOImageElements', 'One line description of project.',
245
-   'Miscellaneous'),
225
+    ('index', 'TripleOImageElements',
226
+     u'TripleO Image Elements Documentation',
227
+     u'OpenStack Developers', 'TripleOImageElements',
228
+     'One line description of project.',
229
+     'Miscellaneous'),
246 230
 ]
247 231
 
248 232
 # Documents to append as an appendix to all manuals.
249
-#texinfo_appendices = []
233
+# texinfo_appendices = []
250 234
 
251 235
 # If false, no module index is generated.
252
-#texinfo_domain_indices = True
236
+# texinfo_domain_indices = True
253 237
 
254 238
 # How to display URL addresses: 'footnote', 'no', or 'inline'.
255
-#texinfo_show_urls = 'footnote'
239
+# texinfo_show_urls = 'footnote'
256 240
 
257 241
 # If true, do not generate a @detailmenu in the "Top" node's menu.
258
-#texinfo_no_detailmenu = False
242
+# texinfo_no_detailmenu = False

+ 1
- 1
elements/horizon/os-apply-config/etc/horizon/local_settings.py View File

@@ -49,7 +49,7 @@ CACHES = {
49 49
         {{#horizon.caches.memcached}}
50 50
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
51 51
         'LOCATION': [{{#nodes}}'{{.}}',{{/nodes}}]
52
-        {{/horizon.caches.memcached}}
52
+        {{/horizon.caches.memcached}} # flake8: noqa
53 53
         {{^horizon.caches.memcached}}
54 54
         'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
55 55
         {{/horizon.caches.memcached}}

+ 24
- 18
elements/mysql-common/os-refresh-config/post-configure.d/50-mysql-users View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 #
3 3
 # Assert users that came from metadata config
4 4
 #
@@ -18,26 +18,32 @@
18 18
 # under the License.
19 19
 #
20 20
 
21
-import subprocess
22
-import MySQLdb
23
-import logging
21
+from __future__ import print_function
22
+
24 23
 import argparse
25
-import os
24
+import base64
26 25
 import json
27
-from base64 import b64encode
26
+import logging
27
+import os
28
+import subprocess
29
+
30
+import MySQLdb
28 31
 
29 32
 logging.basicConfig()
30 33
 logger = logging.getLogger('mysql-users')
31 34
 
32
-# Try to connect with no password, ~/.my.cnf and /mnt/state/root/metadata.my.cnf
35
+# Try to connect with no password, ~/.my.cnf and
36
+# /mnt/state/root/metadata.my.cnf
33 37
 # in that order. This should cover os-refresh-config post install and re-image
34 38
 try:
35 39
     conn = MySQLdb.Connect()
36 40
 except Exception as e:
37 41
     try:
38
-        conn = MySQLdb.Connect(read_default_file=os.path.expanduser('~/.my.cnf'))
42
+        conn = MySQLdb.Connect(
43
+            read_default_file=os.path.expanduser('~/.my.cnf'))
39 44
     except Exception as e:
40
-        conn = MySQLdb.Connect(read_default_file='/mnt/state/root/metadata.my.cnf')
45
+        conn = MySQLdb.Connect(
46
+            read_default_file='/mnt/state/root/metadata.my.cnf')
41 47
 cursor = conn.cursor()
42 48
 rows = cursor.execute("SELECT DISTINCT User FROM mysql.user WHERE user != ''")
43 49
 existing = set([x[0] for x in cursor.fetchmany(size=rows)])
@@ -75,25 +81,25 @@ for createuser in to_create:
75 81
     if 'password' in dbvalue:
76 82
         password = dbvalue['password']
77 83
     else:
78
-        password = b64encode(os.urandom(30))
84
+        password = base64.b64encode(os.urandom(30))
79 85
 
80 86
     cmd = "GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@'%%' IDENTIFIED BY '%s'" % (
81 87
         dbvalue['database'], dbvalue['username'], password)
82 88
     if opts.noop:
83
-        print "%s" % (cmd)
89
+        print("%s" % (cmd))
84 90
     else:
85 91
         cursor = conn.cursor()
86 92
         cursor.execute(cmd)
87 93
         cursor.close()
88 94
 
89 95
     if 'userhandle' in dbvalue:
90
-      # Inform Heat of new password for this user
91
-      cmd = ['/opt/aws/bin/cfn-signal', '-i', dbvalue['username'],
92
-             '-s', 'true', '--data', password, dbvalue['userhandle']]
93
-      if opts.noop:
94
-          print cmd
95
-      else:
96
-          subprocess.check_call(cmd)
96
+        # Inform Heat of new password for this user
97
+        cmd = ['/opt/aws/bin/cfn-signal', '-i', dbvalue['username'],
98
+               '-s', 'true', '--data', password, dbvalue['userhandle']]
99
+        if opts.noop:
100
+            print(cmd)
101
+        else:
102
+            subprocess.check_call(cmd)
97 103
 
98 104
 if to_delete:
99 105
     logger.warn('The following users are not accounted for: %s' % to_delete)

+ 12
- 7
elements/mysql-common/os-refresh-config/post-configure.d/60-mysql-secure View File

@@ -42,15 +42,19 @@ def load_userfile(path, users):
42 42
 
43 43
 
44 44
 def secure_installation(rootuser):
45
-    # Try to connect with no password, ~/.my.cnf and /mnt/state/root/metadata.my.cnf
46
-    # in that order. This should cover os-refresh-config post install and re-image
45
+    # Try to connect with no password, ~/.my.cnf and
46
+    # /mnt/state/root/metadata.my.cnf in that order.
47
+    # This should cover os-refresh-config post install
48
+    # and re-image
47 49
     try:
48 50
         conn = MySQLdb.Connect()
49
-    except Exception as e:
51
+    except Exception:
50 52
         try:
51
-            conn = MySQLdb.Connect(read_default_file=os.path.expanduser('~/.my.cnf'))
52
-        except Exception as e:
53
-            conn = MySQLdb.Connect(read_default_file='/mnt/state/root/metadata.my.cnf')
53
+            conn = MySQLdb.Connect(
54
+                read_default_file=os.path.expanduser('~/.my.cnf'))
55
+        except Exception:
56
+            conn = MySQLdb.Connect(
57
+                read_default_file='/mnt/state/root/metadata.my.cnf')
54 58
     with conn:
55 59
         # Remove Anonymous Users
56 60
         cursor = conn.cursor()
@@ -72,7 +76,8 @@ def secure_installation(rootuser):
72 76
             cursor.execute(cmd, (rootpwd, "root"))
73 77
             cursor.execute("FLUSH PRIVILEGES")
74 78
             # As Above also sets root password .my.cnf with new password
75
-            shutil.copy2('/mnt/state/root/metadata.my.cnf',os.path.expanduser('~/.my.cnf'))
79
+            shutil.copy2('/mnt/state/root/metadata.my.cnf',
80
+                         os.path.expanduser('~/.my.cnf'))
76 81
         cursor.close()
77 82
 
78 83
 users = {}

+ 1
- 1
elements/nagios3/bin/refresh-nagios-from-nova View File

@@ -87,4 +87,4 @@ if errors:
87 87
 
88 88
 if reload_nagios:
89 89
     sys.stderr.write("INFO: reloading nagios.")
90
-    subprocess.call(["service","nagios3","reload"])
90
+    subprocess.call(["service", "nagios3", "reload"])

+ 2
- 2
elements/os-svc-install/tests/test_os_svc_daemon.py View File

@@ -12,10 +12,10 @@
12 12
 #    License for the specific language governing permissions and limitations
13 13
 #    under the License.
14 14
 
15
-from tests import base
15
+import tests.base
16 16
 
17 17
 
18
-class TestOsSvcDaemon(base.ScriptTestBase):
18
+class TestOsSvcDaemon(tests.base.ScriptTestBase):
19 19
     def setUp(self):
20 20
         super(TestOsSvcDaemon, self).setUp()
21 21
         self._stub_script('map-services', 'echo $1')

+ 10
- 6
elements/rabbitmq-server/os-refresh-config/post-configure.d/50-rabbitmq-passwords View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 # Copyright 2013 Hewlett-Packard Development Company, L.P.
3 3
 # All Rights Reserved.
4 4
 #
@@ -15,18 +15,21 @@
15 15
 # under the License.
16 16
 #
17 17
 
18
+from __future__ import print_function
19
+
18 20
 import base64
19 21
 import json
20 22
 import logging
21 23
 import os
22
-import sys
23 24
 import subprocess
25
+import sys
24 26
 
25
-logging.basicConfig(level='INFO',
26
-   format='[%(asctime)s] (%(name)s) [%(levelname)s] %(message)s')
27
+logging.basicConfig(
28
+    level='INFO',
29
+    format='[%(asctime)s] (%(name)s) [%(levelname)s] %(message)s')
27 30
 LOG = logging.getLogger(os.path.basename(sys.argv[0]))
28 31
 
29
-USERS_FILE='/etc/rabbitmq/heat_users.json'
32
+USERS_FILE = '/etc/rabbitmq/heat_users.json'
30 33
 HANDLE_FILE = '/etc/rabbitmq/heat_password_handle'
31 34
 
32 35
 # USERS_FILE can exist without any content, in which case it will just be an
@@ -39,6 +42,7 @@ if os.path.exists(HANDLE_FILE):
39 42
     with open(HANDLE_FILE) as hf:
40 43
         PASSWORD_HANDLE = hf.read().rstrip()
41 44
 
45
+
42 46
 def get_existing_users():
43 47
     list_users = subprocess.check_output(['rabbitmqctl', 'list_users'],
44 48
                                          stderr=subprocess.STDOUT)
@@ -88,7 +92,7 @@ for need_user in need:
88 92
                                    '--data', password,
89 93
                                    PASSWORD_HANDLE])
90 94
         else:
91
-            print '%s:%s' % (username, password)
95
+            print('%s:%s' % (username, password))
92 96
     if 'permissions' in detail:
93 97
         args = ['rabbitmqctl', 'set_permissions', username]
94 98
         args.append(detail['permissions']['conf'])

+ 1
- 1
elements/tempest/tests2skip.py View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 #
3 3
 # Copyright 2013 Red Hat
4 4
 # All Rights Reserved.

+ 23
- 0
run-flake8 View File

@@ -0,0 +1,23 @@
1
+#!/bin/bash
2
+# Copyright 2014 eNovance <licensing@enovance.com>
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+#     http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+#
16
+set -eu
17
+set -o pipefail
18
+
19
+flake8
20
+
21
+extra_python_files=$(egrep -R --null-data --files-with-matches "^#!/usr/bin/env python" elements/)
22
+echo $extra_python_files
23
+flake8 ${extra_python_files}

+ 2
- 2
tox.ini View File

@@ -18,11 +18,11 @@ commands =
18 18
 commands = {posargs}
19 19
 
20 20
 [testenv:pep8]
21
-commands = flake8
21
+commands = ./run-flake8
22 22
 
23 23
 [flake8]
24 24
 ignore = E125,H803
25
-exclude = .venv,.tox,dist,doc,*.egg
25
+exclude = .venv,.tox,dist,*.egg
26 26
 show-source = true
27 27
 
28 28
 [tox:jenkins]

Loading…
Cancel
Save