Merge lp:~harlowja/cloud-init/cloud-init-flake8-fixups into lp:~cloud-init-dev/cloud-init/trunk
- cloud-init-flake8-fixups
- Merge into trunk
Proposed by
Joshua Harlow
on 2016-05-12
| Status: | Merged |
|---|---|
| Merged at revision: | 1217 |
| Proposed branch: | lp:~harlowja/cloud-init/cloud-init-flake8-fixups |
| Merge into: | lp:~cloud-init-dev/cloud-init/trunk |
| Diff against target: |
1364 lines (+157/-133) 62 files modified
cloudinit/config/cc_apt_configure.py (+3/-3) cloudinit/config/cc_bootcmd.py (+2/-2) cloudinit/config/cc_disk_setup.py (+1/-1) cloudinit/config/cc_emit_upstart.py (+1/-1) cloudinit/config/cc_fan.py (+1/-1) cloudinit/config/cc_final_message.py (+1/-1) cloudinit/config/cc_grub_dpkg.py (+1/-1) cloudinit/config/cc_keys_to_console.py (+1/-1) cloudinit/config/cc_lxd.py (+1/-1) cloudinit/config/cc_mounts.py (+5/-5) cloudinit/config/cc_phone_home.py (+3/-3) cloudinit/config/cc_rightscale_userdata.py (+2/-2) cloudinit/config/cc_runcmd.py (+1/-1) cloudinit/config/cc_scripts_per_boot.py (+1/-1) cloudinit/config/cc_scripts_per_instance.py (+1/-1) cloudinit/config/cc_scripts_per_once.py (+1/-1) cloudinit/config/cc_scripts_user.py (+1/-1) cloudinit/config/cc_scripts_vendor.py (+1/-1) cloudinit/config/cc_seed_random.py (+1/-1) cloudinit/config/cc_set_passwords.py (+1/-1) cloudinit/config/cc_snappy.py (+2/-2) cloudinit/config/cc_ssh.py (+3/-3) cloudinit/config/cc_ssh_import_id.py (+2/-2) cloudinit/config/cc_ubuntu_init_switch.py (+2/-2) cloudinit/distros/__init__.py (+2/-2) cloudinit/distros/debian.py (+2/-2) cloudinit/handlers/__init__.py (+3/-3) cloudinit/handlers/cloud_config.py (+1/-1) cloudinit/handlers/upstart_job.py (+1/-1) cloudinit/helpers.py (+5/-5) cloudinit/net/__init__.py (+8/-10) cloudinit/net/network_state.py (+4/-3) cloudinit/net/udev.py (+1/-1) cloudinit/netinfo.py (+4/-3) cloudinit/reporting/handlers.py (+5/-5) cloudinit/sources/DataSourceAzure.py (+7/-5) cloudinit/sources/DataSourceBigstep.py (+2/-2) cloudinit/sources/DataSourceCloudSigma.py (+3/-2) cloudinit/sources/DataSourceCloudStack.py (+3/-2) cloudinit/sources/DataSourceDigitalOcean.py (+2/-2) cloudinit/sources/DataSourceGCE.py (+2/-2) cloudinit/sources/DataSourceNoCloud.py (+2/-2) cloudinit/sources/DataSourceOVF.py (+16/-9) cloudinit/sources/__init__.py (+1/-2) cloudinit/sources/helpers/azure.py (+1/-0) cloudinit/sources/helpers/openstack.py (+2/-2) cloudinit/sources/helpers/vmware/imc/boot_proto.py (+1/-1) cloudinit/sources/helpers/vmware/imc/config.py (+1/-1) cloudinit/sources/helpers/vmware/imc/config_nic.py (+1/-1) cloudinit/sources/helpers/vmware/imc/config_source.py (+1/-1) cloudinit/sources/helpers/vmware/imc/guestcust_error.py (+1/-1) cloudinit/sources/helpers/vmware/imc/guestcust_event.py (+1/-1) cloudinit/sources/helpers/vmware/imc/guestcust_state.py (+1/-1) cloudinit/sources/helpers/vmware/imc/guestcust_util.py (+1/-1) cloudinit/sources/helpers/vmware/imc/ipv4_mode.py (+1/-1) cloudinit/sources/helpers/vmware/imc/nic_base.py (+3/-3) cloudinit/stages.py (+2/-2) cloudinit/url_helper.py (+3/-2) cloudinit/user_data.py (+1/-1) cloudinit/util.py (+9/-9) test-requirements.txt (+9/-2) tox.ini (+5/-0) |
| To merge this branch: | bzr merge lp:~harlowja/cloud-init/cloud-init-flake8-fixups |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Scott Moser | 2016-05-12 | Approve on 2016-05-12 | |
|
Review via email:
|
|||
Commit Message
Description of the Change
To post a comment you must log in.
lp:~harlowja/cloud-init/cloud-init-flake8-fixups
updated
on 2016-05-12
- 1219. By Joshua Harlow on 2016-05-12
-
Ensure hacking is installed
- 1220. By Joshua Harlow on 2016-05-12
-
Freeze lint testing requirements
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'cloudinit/config/cc_apt_configure.py' |
| 2 | --- cloudinit/config/cc_apt_configure.py 2016-03-03 22:20:10 +0000 |
| 3 | +++ cloudinit/config/cc_apt_configure.py 2016-05-12 18:35:40 +0000 |
| 4 | @@ -207,20 +207,20 @@ |
| 5 | ks = ent['keyserver'] |
| 6 | try: |
| 7 | ent['key'] = getkeybyid(ent['keyid'], ks) |
| 8 | - except: |
| 9 | + except Exception: |
| 10 | errorlist.append([source, "failed to get key from %s" % ks]) |
| 11 | continue |
| 12 | |
| 13 | if 'key' in ent: |
| 14 | try: |
| 15 | util.subp(('apt-key', 'add', '-'), ent['key']) |
| 16 | - except: |
| 17 | + except Exception: |
| 18 | errorlist.append([source, "failed add key"]) |
| 19 | |
| 20 | try: |
| 21 | contents = "%s\n" % (source) |
| 22 | util.write_file(ent['filename'], contents, omode="ab") |
| 23 | - except: |
| 24 | + except Exception: |
| 25 | errorlist.append([source, |
| 26 | "failed write to file %s" % ent['filename']]) |
| 27 | |
| 28 | |
| 29 | === modified file 'cloudinit/config/cc_bootcmd.py' |
| 30 | --- cloudinit/config/cc_bootcmd.py 2015-02-10 21:33:11 +0000 |
| 31 | +++ cloudinit/config/cc_bootcmd.py 2016-05-12 18:35:40 +0000 |
| 32 | @@ -38,7 +38,7 @@ |
| 33 | content = util.shellify(cfg["bootcmd"]) |
| 34 | tmpf.write(util.encode_text(content)) |
| 35 | tmpf.flush() |
| 36 | - except: |
| 37 | + except Exception: |
| 38 | util.logexc(log, "Failed to shellify bootcmd") |
| 39 | raise |
| 40 | |
| 41 | @@ -49,6 +49,6 @@ |
| 42 | env['INSTANCE_ID'] = str(iid) |
| 43 | cmd = ['/bin/sh', tmpf.name] |
| 44 | util.subp(cmd, env=env, capture=False) |
| 45 | - except: |
| 46 | + except Exception: |
| 47 | util.logexc(log, "Failed to run bootcmd module %s", name) |
| 48 | raise |
| 49 | |
| 50 | === modified file 'cloudinit/config/cc_disk_setup.py' |
| 51 | --- cloudinit/config/cc_disk_setup.py 2016-04-04 19:02:00 +0000 |
| 52 | +++ cloudinit/config/cc_disk_setup.py 2016-05-12 18:35:40 +0000 |
| 53 | @@ -198,7 +198,7 @@ |
| 54 | d_type = "" |
| 55 | try: |
| 56 | d_type = device_type(name) |
| 57 | - except: |
| 58 | + except Exception: |
| 59 | LOG.warn("Query against device %s failed" % name) |
| 60 | return False |
| 61 | |
| 62 | |
| 63 | === modified file 'cloudinit/config/cc_emit_upstart.py' |
| 64 | --- cloudinit/config/cc_emit_upstart.py 2015-03-16 17:20:26 +0000 |
| 65 | +++ cloudinit/config/cc_emit_upstart.py 2016-05-12 18:35:40 +0000 |
| 66 | @@ -20,8 +20,8 @@ |
| 67 | |
| 68 | import os |
| 69 | |
| 70 | +from cloudinit import log as logging |
| 71 | from cloudinit.settings import PER_ALWAYS |
| 72 | -from cloudinit import log as logging |
| 73 | from cloudinit import util |
| 74 | |
| 75 | frequency = PER_ALWAYS |
| 76 | |
| 77 | === modified file 'cloudinit/config/cc_fan.py' |
| 78 | --- cloudinit/config/cc_fan.py 2015-10-09 16:39:23 +0000 |
| 79 | +++ cloudinit/config/cc_fan.py 2016-05-12 18:35:40 +0000 |
| 80 | @@ -37,8 +37,8 @@ |
| 81 | """ |
| 82 | |
| 83 | from cloudinit import log as logging |
| 84 | +from cloudinit.settings import PER_INSTANCE |
| 85 | from cloudinit import util |
| 86 | -from cloudinit.settings import PER_INSTANCE |
| 87 | |
| 88 | LOG = logging.getLogger(__name__) |
| 89 | |
| 90 | |
| 91 | === modified file 'cloudinit/config/cc_final_message.py' |
| 92 | --- cloudinit/config/cc_final_message.py 2016-03-04 06:45:58 +0000 |
| 93 | +++ cloudinit/config/cc_final_message.py 2016-05-12 18:35:40 +0000 |
| 94 | @@ -66,7 +66,7 @@ |
| 95 | try: |
| 96 | contents = "%s - %s - v. %s\n" % (uptime, ts, cver) |
| 97 | util.write_file(boot_fin_fn, contents) |
| 98 | - except: |
| 99 | + except Exception: |
| 100 | util.logexc(log, "Failed to write boot finished file %s", boot_fin_fn) |
| 101 | |
| 102 | if cloud.datasource.is_disconnected: |
| 103 | |
| 104 | === modified file 'cloudinit/config/cc_grub_dpkg.py' |
| 105 | --- cloudinit/config/cc_grub_dpkg.py 2016-03-04 06:45:58 +0000 |
| 106 | +++ cloudinit/config/cc_grub_dpkg.py 2016-05-12 18:35:40 +0000 |
| 107 | @@ -69,5 +69,5 @@ |
| 108 | |
| 109 | try: |
| 110 | util.subp(['debconf-set-selections'], dconf_sel) |
| 111 | - except: |
| 112 | + except Exception: |
| 113 | util.logexc(log, "Failed to run debconf-set-selections for grub-dpkg") |
| 114 | |
| 115 | === modified file 'cloudinit/config/cc_keys_to_console.py' |
| 116 | --- cloudinit/config/cc_keys_to_console.py 2016-03-03 22:20:10 +0000 |
| 117 | +++ cloudinit/config/cc_keys_to_console.py 2016-05-12 18:35:40 +0000 |
| 118 | @@ -57,6 +57,6 @@ |
| 119 | (stdout, _stderr) = util.subp(cmd) |
| 120 | util.multi_log("%s\n" % (stdout.strip()), |
| 121 | stderr=False, console=True) |
| 122 | - except: |
| 123 | + except Exception: |
| 124 | log.warn("Writing keys to the system console failed!") |
| 125 | raise |
| 126 | |
| 127 | === modified file 'cloudinit/config/cc_lxd.py' |
| 128 | --- cloudinit/config/cc_lxd.py 2016-04-11 19:08:08 +0000 |
| 129 | +++ cloudinit/config/cc_lxd.py 2016-05-12 18:35:40 +0000 |
| 130 | @@ -111,7 +111,7 @@ |
| 131 | data = "\n".join(["set %s %s" % (k, v) |
| 132 | for k, v in debconf.items()]) + "\n" |
| 133 | util.subp(['debconf-communicate'], data) |
| 134 | - except: |
| 135 | + except Exception: |
| 136 | util.logexc(log, "Failed to run '%s' for lxd with" % dconf_comm) |
| 137 | |
| 138 | # Remove the existing configuration file (forces re-generation) |
| 139 | |
| 140 | === modified file 'cloudinit/config/cc_mounts.py' |
| 141 | --- cloudinit/config/cc_mounts.py 2016-03-03 22:20:10 +0000 |
| 142 | +++ cloudinit/config/cc_mounts.py 2016-05-12 18:35:40 +0000 |
| 143 | @@ -244,7 +244,7 @@ |
| 144 | LOG.debug("swap file %s already in use.", fname) |
| 145 | return fname |
| 146 | LOG.debug("swap file %s existed, but not in /proc/swaps", fname) |
| 147 | - except: |
| 148 | + except Exception: |
| 149 | LOG.warn("swap file %s existed. Error reading /proc/swaps", fname) |
| 150 | return fname |
| 151 | |
| 152 | @@ -379,7 +379,7 @@ |
| 153 | toks = WS.split(line) |
| 154 | if toks[3].find(comment) != -1: |
| 155 | continue |
| 156 | - except: |
| 157 | + except Exception: |
| 158 | pass |
| 159 | fstab_lines.append(line) |
| 160 | |
| 161 | @@ -390,16 +390,16 @@ |
| 162 | if needswap: |
| 163 | try: |
| 164 | util.subp(("swapon", "-a")) |
| 165 | - except: |
| 166 | + except Exception: |
| 167 | util.logexc(log, "Activating swap via 'swapon -a' failed") |
| 168 | |
| 169 | for d in dirs: |
| 170 | try: |
| 171 | util.ensure_dir(d) |
| 172 | - except: |
| 173 | + except Exception: |
| 174 | util.logexc(log, "Failed to make '%s' config-mount", d) |
| 175 | |
| 176 | try: |
| 177 | util.subp(("mount", "-a")) |
| 178 | - except: |
| 179 | + except Exception: |
| 180 | util.logexc(log, "Activating mounts via 'mount -a' failed") |
| 181 | |
| 182 | === modified file 'cloudinit/config/cc_phone_home.py' |
| 183 | --- cloudinit/config/cc_phone_home.py 2016-04-13 16:35:50 +0000 |
| 184 | +++ cloudinit/config/cc_phone_home.py 2016-05-12 18:35:40 +0000 |
| 185 | @@ -65,7 +65,7 @@ |
| 186 | tries = ph_cfg.get('tries') |
| 187 | try: |
| 188 | tries = int(tries) |
| 189 | - except: |
| 190 | + except Exception: |
| 191 | tries = 10 |
| 192 | util.logexc(log, "Configuration entry 'tries' is not an integer, " |
| 193 | "using %s instead", tries) |
| 194 | @@ -87,7 +87,7 @@ |
| 195 | for (n, path) in pubkeys.items(): |
| 196 | try: |
| 197 | all_keys[n] = util.load_file(path) |
| 198 | - except: |
| 199 | + except Exception: |
| 200 | util.logexc(log, "%s: failed to open, can not phone home that " |
| 201 | "data!", path) |
| 202 | |
| 203 | @@ -117,6 +117,6 @@ |
| 204 | util.read_file_or_url(url, data=real_submit_keys, |
| 205 | retries=tries, sec_between=3, |
| 206 | ssl_details=util.fetch_ssl_details(cloud.paths)) |
| 207 | - except: |
| 208 | + except Exception: |
| 209 | util.logexc(log, "Failed to post phone home data to %s in %s tries", |
| 210 | url, tries) |
| 211 | |
| 212 | === modified file 'cloudinit/config/cc_rightscale_userdata.py' |
| 213 | --- cloudinit/config/cc_rightscale_userdata.py 2015-06-29 14:58:59 +0000 |
| 214 | +++ cloudinit/config/cc_rightscale_userdata.py 2016-05-12 18:35:40 +0000 |
| 215 | @@ -52,7 +52,7 @@ |
| 216 | def handle(name, _cfg, cloud, log, _args): |
| 217 | try: |
| 218 | ud = cloud.get_userdata_raw() |
| 219 | - except: |
| 220 | + except Exception: |
| 221 | log.debug("Failed to get raw userdata in module %s", name) |
| 222 | return |
| 223 | |
| 224 | @@ -63,7 +63,7 @@ |
| 225 | "did not find %s in parsed" |
| 226 | " raw userdata"), name, MY_HOOKNAME) |
| 227 | return |
| 228 | - except: |
| 229 | + except Exception: |
| 230 | util.logexc(log, "Failed to parse query string %s into a dictionary", |
| 231 | ud) |
| 232 | raise |
| 233 | |
| 234 | === modified file 'cloudinit/config/cc_runcmd.py' |
| 235 | --- cloudinit/config/cc_runcmd.py 2015-01-27 19:24:22 +0000 |
| 236 | +++ cloudinit/config/cc_runcmd.py 2016-05-12 18:35:40 +0000 |
| 237 | @@ -34,5 +34,5 @@ |
| 238 | try: |
| 239 | content = util.shellify(cmd) |
| 240 | util.write_file(out_fn, content, 0o700) |
| 241 | - except: |
| 242 | + except Exception: |
| 243 | util.logexc(log, "Failed to shellify %s into file %s", cmd, out_fn) |
| 244 | |
| 245 | === modified file 'cloudinit/config/cc_scripts_per_boot.py' |
| 246 | --- cloudinit/config/cc_scripts_per_boot.py 2012-06-21 16:12:16 +0000 |
| 247 | +++ cloudinit/config/cc_scripts_per_boot.py 2016-05-12 18:35:40 +0000 |
| 248 | @@ -35,7 +35,7 @@ |
| 249 | runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR) |
| 250 | try: |
| 251 | util.runparts(runparts_path) |
| 252 | - except: |
| 253 | + except Exception: |
| 254 | log.warn("Failed to run module %s (%s in %s)", |
| 255 | name, SCRIPT_SUBDIR, runparts_path) |
| 256 | raise |
| 257 | |
| 258 | === modified file 'cloudinit/config/cc_scripts_per_instance.py' |
| 259 | --- cloudinit/config/cc_scripts_per_instance.py 2012-06-21 16:12:16 +0000 |
| 260 | +++ cloudinit/config/cc_scripts_per_instance.py 2016-05-12 18:35:40 +0000 |
| 261 | @@ -35,7 +35,7 @@ |
| 262 | runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR) |
| 263 | try: |
| 264 | util.runparts(runparts_path) |
| 265 | - except: |
| 266 | + except Exception: |
| 267 | log.warn("Failed to run module %s (%s in %s)", |
| 268 | name, SCRIPT_SUBDIR, runparts_path) |
| 269 | raise |
| 270 | |
| 271 | === modified file 'cloudinit/config/cc_scripts_per_once.py' |
| 272 | --- cloudinit/config/cc_scripts_per_once.py 2012-06-21 16:12:16 +0000 |
| 273 | +++ cloudinit/config/cc_scripts_per_once.py 2016-05-12 18:35:40 +0000 |
| 274 | @@ -35,7 +35,7 @@ |
| 275 | runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR) |
| 276 | try: |
| 277 | util.runparts(runparts_path) |
| 278 | - except: |
| 279 | + except Exception: |
| 280 | log.warn("Failed to run module %s (%s in %s)", |
| 281 | name, SCRIPT_SUBDIR, runparts_path) |
| 282 | raise |
| 283 | |
| 284 | === modified file 'cloudinit/config/cc_scripts_user.py' |
| 285 | --- cloudinit/config/cc_scripts_user.py 2012-06-21 16:12:16 +0000 |
| 286 | +++ cloudinit/config/cc_scripts_user.py 2016-05-12 18:35:40 +0000 |
| 287 | @@ -36,7 +36,7 @@ |
| 288 | runparts_path = os.path.join(cloud.get_ipath_cur(), SCRIPT_SUBDIR) |
| 289 | try: |
| 290 | util.runparts(runparts_path) |
| 291 | - except: |
| 292 | + except Exception: |
| 293 | log.warn("Failed to run module %s (%s in %s)", |
| 294 | name, SCRIPT_SUBDIR, runparts_path) |
| 295 | raise |
| 296 | |
| 297 | === modified file 'cloudinit/config/cc_scripts_vendor.py' |
| 298 | --- cloudinit/config/cc_scripts_vendor.py 2014-01-15 22:13:24 +0000 |
| 299 | +++ cloudinit/config/cc_scripts_vendor.py 2016-05-12 18:35:40 +0000 |
| 300 | @@ -37,7 +37,7 @@ |
| 301 | |
| 302 | try: |
| 303 | util.runparts(runparts_path, exe_prefix=prefix) |
| 304 | - except: |
| 305 | + except Exception: |
| 306 | log.warn("Failed to run module %s (%s in %s)", |
| 307 | name, SCRIPT_SUBDIR, runparts_path) |
| 308 | raise |
| 309 | |
| 310 | === modified file 'cloudinit/config/cc_seed_random.py' |
| 311 | --- cloudinit/config/cc_seed_random.py 2016-03-08 02:31:25 +0000 |
| 312 | +++ cloudinit/config/cc_seed_random.py 2016-05-12 18:35:40 +0000 |
| 313 | @@ -24,8 +24,8 @@ |
| 314 | |
| 315 | from six import BytesIO |
| 316 | |
| 317 | +from cloudinit import log as logging |
| 318 | from cloudinit.settings import PER_INSTANCE |
| 319 | -from cloudinit import log as logging |
| 320 | from cloudinit import util |
| 321 | |
| 322 | frequency = PER_INSTANCE |
| 323 | |
| 324 | === modified file 'cloudinit/config/cc_set_passwords.py' |
| 325 | --- cloudinit/config/cc_set_passwords.py 2016-03-14 18:24:27 +0000 |
| 326 | +++ cloudinit/config/cc_set_passwords.py 2016-05-12 18:35:40 +0000 |
| 327 | @@ -155,7 +155,7 @@ |
| 328 | cmd = filter(None, cmd) # Remove empty arguments |
| 329 | util.subp(cmd) |
| 330 | log.debug("Restarted the ssh daemon") |
| 331 | - except: |
| 332 | + except Exception: |
| 333 | util.logexc(log, "Restarting of the ssh daemon failed") |
| 334 | |
| 335 | if len(errors): |
| 336 | |
| 337 | === modified file 'cloudinit/config/cc_snappy.py' |
| 338 | --- cloudinit/config/cc_snappy.py 2015-09-15 17:53:36 +0000 |
| 339 | +++ cloudinit/config/cc_snappy.py 2016-05-12 18:35:40 +0000 |
| 340 | @@ -47,12 +47,12 @@ |
| 341 | """ |
| 342 | |
| 343 | from cloudinit import log as logging |
| 344 | +from cloudinit.settings import PER_INSTANCE |
| 345 | from cloudinit import util |
| 346 | -from cloudinit.settings import PER_INSTANCE |
| 347 | |
| 348 | import glob |
| 349 | +import os |
| 350 | import tempfile |
| 351 | -import os |
| 352 | |
| 353 | LOG = logging.getLogger(__name__) |
| 354 | |
| 355 | |
| 356 | === modified file 'cloudinit/config/cc_ssh.py' |
| 357 | --- cloudinit/config/cc_ssh.py 2016-03-03 22:20:10 +0000 |
| 358 | +++ cloudinit/config/cc_ssh.py 2016-05-12 18:35:40 +0000 |
| 359 | @@ -57,7 +57,7 @@ |
| 360 | for f in glob.glob(key_pth): |
| 361 | try: |
| 362 | util.del_file(f) |
| 363 | - except: |
| 364 | + except Exception: |
| 365 | util.logexc(log, "Failed deleting key file %s", f) |
| 366 | |
| 367 | if "ssh_keys" in cfg: |
| 368 | @@ -78,7 +78,7 @@ |
| 369 | with util.SeLinuxGuard("/etc/ssh", recursive=True): |
| 370 | util.subp(cmd, capture=False) |
| 371 | log.debug("Generated a key for %s from %s", pair[0], pair[1]) |
| 372 | - except: |
| 373 | + except Exception: |
| 374 | util.logexc(log, "Failed generated a key for %s from %s", |
| 375 | pair[0], pair[1]) |
| 376 | else: |
| 377 | @@ -122,7 +122,7 @@ |
| 378 | keys.extend(cfgkeys) |
| 379 | |
| 380 | apply_credentials(keys, user, disable_root, disable_root_opts) |
| 381 | - except: |
| 382 | + except Exception: |
| 383 | util.logexc(log, "Applying ssh credentials failed!") |
| 384 | |
| 385 | |
| 386 | |
| 387 | === modified file 'cloudinit/config/cc_ssh_import_id.py' |
| 388 | --- cloudinit/config/cc_ssh_import_id.py 2014-09-10 18:32:37 +0000 |
| 389 | +++ cloudinit/config/cc_ssh_import_id.py 2016-05-12 18:35:40 +0000 |
| 390 | @@ -52,14 +52,14 @@ |
| 391 | else: |
| 392 | try: |
| 393 | import_ids = user_cfg['ssh_import_id'] |
| 394 | - except: |
| 395 | + except Exception: |
| 396 | log.debug("User %s is not configured for ssh_import_id", user) |
| 397 | continue |
| 398 | |
| 399 | try: |
| 400 | import_ids = util.uniq_merge(import_ids) |
| 401 | import_ids = [str(i) for i in import_ids] |
| 402 | - except: |
| 403 | + except Exception: |
| 404 | log.debug("User %s is not correctly configured for ssh_import_id", |
| 405 | user) |
| 406 | continue |
| 407 | |
| 408 | === modified file 'cloudinit/config/cc_ubuntu_init_switch.py' |
| 409 | --- cloudinit/config/cc_ubuntu_init_switch.py 2014-10-24 01:02:37 +0000 |
| 410 | +++ cloudinit/config/cc_ubuntu_init_switch.py 2016-05-12 18:35:40 +0000 |
| 411 | @@ -40,10 +40,10 @@ |
| 412 | mechanism you've used to switch the init system. |
| 413 | """ |
| 414 | |
| 415 | +from cloudinit.distros import ubuntu |
| 416 | +from cloudinit import log as logging |
| 417 | from cloudinit.settings import PER_INSTANCE |
| 418 | -from cloudinit import log as logging |
| 419 | from cloudinit import util |
| 420 | -from cloudinit.distros import ubuntu |
| 421 | |
| 422 | import os |
| 423 | import time |
| 424 | |
| 425 | === modified file 'cloudinit/distros/__init__.py' |
| 426 | --- cloudinit/distros/__init__.py 2016-04-06 15:23:47 +0000 |
| 427 | +++ cloudinit/distros/__init__.py 2016-05-12 18:35:40 +0000 |
| 428 | @@ -50,8 +50,8 @@ |
| 429 | LOG = logging.getLogger(__name__) |
| 430 | |
| 431 | |
| 432 | +@six.add_metaclass(abc.ABCMeta) |
| 433 | class Distro(object): |
| 434 | - __metaclass__ = abc.ABCMeta |
| 435 | |
| 436 | usr_lib_exec = "/usr/lib" |
| 437 | hosts_fn = "/etc/hosts" |
| 438 | @@ -97,7 +97,7 @@ |
| 439 | try: |
| 440 | res = os.lstat('/run/systemd/system') |
| 441 | return stat.S_ISDIR(res.st_mode) |
| 442 | - except: |
| 443 | + except Exception: |
| 444 | return False |
| 445 | |
| 446 | @abc.abstractmethod |
| 447 | |
| 448 | === modified file 'cloudinit/distros/debian.py' |
| 449 | --- cloudinit/distros/debian.py 2016-04-15 16:02:51 +0000 |
| 450 | +++ cloudinit/distros/debian.py 2016-05-12 18:35:40 +0000 |
| 451 | @@ -25,8 +25,8 @@ |
| 452 | from cloudinit import distros |
| 453 | from cloudinit import helpers |
| 454 | from cloudinit import log as logging |
| 455 | +from cloudinit import net |
| 456 | from cloudinit import util |
| 457 | -from cloudinit import net |
| 458 | |
| 459 | from cloudinit.distros.parsers.hostname import HostnameConf |
| 460 | |
| 461 | @@ -221,7 +221,7 @@ |
| 462 | msg = "removed %s with known contents" % path |
| 463 | else: |
| 464 | msg = (bmsg + " '%s' exists with user configured content." % path) |
| 465 | - except: |
| 466 | + except Exception: |
| 467 | msg = bmsg + " %s exists, but could not be read." % path |
| 468 | |
| 469 | LOG.warn(msg) |
| 470 | |
| 471 | === modified file 'cloudinit/handlers/__init__.py' |
| 472 | --- cloudinit/handlers/__init__.py 2015-04-16 21:00:19 +0000 |
| 473 | +++ cloudinit/handlers/__init__.py 2016-05-12 18:35:40 +0000 |
| 474 | @@ -71,8 +71,8 @@ |
| 475 | key=(lambda e: 0 - len(e))) |
| 476 | |
| 477 | |
| 478 | +@six.add_metaclass(abc.ABCMeta) |
| 479 | class Handler(object): |
| 480 | - __metaclass__ = abc.ABCMeta |
| 481 | |
| 482 | def __init__(self, frequency, version=2): |
| 483 | self.handler_version = version |
| 484 | @@ -118,7 +118,7 @@ |
| 485 | mod.handle_part(data, content_type, filename, payload) |
| 486 | else: |
| 487 | raise ValueError("Unknown module version %s" % (mod_ver)) |
| 488 | - except: |
| 489 | + except Exception: |
| 490 | util.logexc(LOG, "Failed calling handler %s (%s, %s, %s) with " |
| 491 | "frequency %s", mod, content_type, filename, mod_ver, |
| 492 | frequency) |
| 493 | @@ -157,7 +157,7 @@ |
| 494 | # register if it fails starting. |
| 495 | handlers.register(mod, initialized=True) |
| 496 | pdata['handlercount'] = curcount + 1 |
| 497 | - except: |
| 498 | + except Exception: |
| 499 | util.logexc(LOG, "Failed at registering python file: %s (part " |
| 500 | "handler %s)", modfname, curcount) |
| 501 | |
| 502 | |
| 503 | === modified file 'cloudinit/handlers/cloud_config.py' |
| 504 | --- cloudinit/handlers/cloud_config.py 2015-01-21 22:56:53 +0000 |
| 505 | +++ cloudinit/handlers/cloud_config.py 2016-05-12 18:35:40 +0000 |
| 506 | @@ -158,6 +158,6 @@ |
| 507 | for i in ("\n", "\r", "\t"): |
| 508 | filename = filename.replace(i, " ") |
| 509 | self.file_names.append(filename.strip()) |
| 510 | - except: |
| 511 | + except Exception: |
| 512 | util.logexc(LOG, "Failed at merging in cloud config part from %s", |
| 513 | filename) |
| 514 | |
| 515 | === modified file 'cloudinit/handlers/upstart_job.py' |
| 516 | --- cloudinit/handlers/upstart_job.py 2015-01-21 22:56:53 +0000 |
| 517 | +++ cloudinit/handlers/upstart_job.py 2016-05-12 18:35:40 +0000 |
| 518 | @@ -80,7 +80,7 @@ |
| 519 | return False |
| 520 | try: |
| 521 | (version_out, _err) = util.subp(["initctl", "version"]) |
| 522 | - except: |
| 523 | + except Exception: |
| 524 | util.logexc(LOG, "initctl version failed") |
| 525 | return False |
| 526 | |
| 527 | |
| 528 | === modified file 'cloudinit/helpers.py' |
| 529 | --- cloudinit/helpers.py 2016-04-29 15:23:08 +0000 |
| 530 | +++ cloudinit/helpers.py 2016-05-12 18:35:40 +0000 |
| 531 | @@ -86,7 +86,7 @@ |
| 532 | name = canon_sem_name(name) |
| 533 | try: |
| 534 | yield self._acquire(name, freq) |
| 535 | - except: |
| 536 | + except Exception: |
| 537 | if clear_on_fail: |
| 538 | self.clear(name, freq) |
| 539 | raise |
| 540 | @@ -219,7 +219,7 @@ |
| 541 | ds_cfg = self._ds.get_config_obj() |
| 542 | if ds_cfg and isinstance(ds_cfg, (dict)): |
| 543 | d_cfgs.append(ds_cfg) |
| 544 | - except: |
| 545 | + except Exception: |
| 546 | util.logexc(LOG, "Failed loading of datasource config object " |
| 547 | "from %s", self._ds) |
| 548 | return d_cfgs |
| 549 | @@ -230,7 +230,7 @@ |
| 550 | e_fn = os.environ[CFG_ENV_NAME] |
| 551 | try: |
| 552 | e_cfgs.append(util.read_conf(e_fn)) |
| 553 | - except: |
| 554 | + except Exception: |
| 555 | util.logexc(LOG, 'Failed loading of env. config from %s', |
| 556 | e_fn) |
| 557 | return e_cfgs |
| 558 | @@ -251,7 +251,7 @@ |
| 559 | if cc_fn and os.path.isfile(cc_fn): |
| 560 | try: |
| 561 | i_cfgs.append(util.read_conf(cc_fn)) |
| 562 | - except: |
| 563 | + except Exception: |
| 564 | util.logexc(LOG, 'Failed loading of cloud-config from %s', |
| 565 | cc_fn) |
| 566 | return i_cfgs |
| 567 | @@ -268,7 +268,7 @@ |
| 568 | for c_fn in self._fns: |
| 569 | try: |
| 570 | cfgs.append(util.read_conf(c_fn)) |
| 571 | - except: |
| 572 | + except Exception: |
| 573 | util.logexc(LOG, "Failed loading of configuration from %s", |
| 574 | c_fn) |
| 575 | |
| 576 | |
| 577 | === modified file 'cloudinit/net/__init__.py' |
| 578 | --- cloudinit/net/__init__.py 2016-04-15 20:21:05 +0000 |
| 579 | +++ cloudinit/net/__init__.py 2016-05-12 18:35:40 +0000 |
| 580 | @@ -26,9 +26,9 @@ |
| 581 | import shlex |
| 582 | |
| 583 | from cloudinit import log as logging |
| 584 | +from cloudinit.net import network_state |
| 585 | +from cloudinit.net.udev import generate_udev_rule |
| 586 | from cloudinit import util |
| 587 | -from .udev import generate_udev_rule |
| 588 | -from . import network_state |
| 589 | |
| 590 | LOG = logging.getLogger(__name__) |
| 591 | |
| 592 | @@ -40,16 +40,16 @@ |
| 593 | "pointtopoint", "media", "mtu", "hostname", "leasehours", "leasetime", |
| 594 | "vendor", "client", "bootfile", "server", "hwaddr", "provider", "frame", |
| 595 | "netnum", "endpoint", "local", "ttl", |
| 596 | - ] |
| 597 | +] |
| 598 | |
| 599 | NET_CONFIG_COMMANDS = [ |
| 600 | "pre-up", "up", "post-up", "down", "pre-down", "post-down", |
| 601 | - ] |
| 602 | +] |
| 603 | |
| 604 | NET_CONFIG_BRIDGE_OPTIONS = [ |
| 605 | "bridge_ageing", "bridge_bridgeprio", "bridge_fd", "bridge_gcinit", |
| 606 | "bridge_hello", "bridge_maxage", "bridge_maxwait", "bridge_stp", |
| 607 | - ] |
| 608 | +] |
| 609 | |
| 610 | DEFAULT_PRIMARY_INTERFACE = 'eth0' |
| 611 | |
| 612 | @@ -399,9 +399,7 @@ |
| 613 | |
| 614 | |
| 615 | def render_persistent_net(network_state): |
| 616 | - ''' Given state, emit udev rules to map |
| 617 | - mac to ifname |
| 618 | - ''' |
| 619 | + '''Given state, emit udev rules to map mac to ifname.''' |
| 620 | content = "" |
| 621 | interfaces = network_state.get('interfaces') |
| 622 | for iface in interfaces.values(): |
| 623 | @@ -465,7 +463,7 @@ |
| 624 | |
| 625 | |
| 626 | def render_route(route, indent=""): |
| 627 | - """ When rendering routes for an iface, in some cases applying a route |
| 628 | + """When rendering routes for an iface, in some cases applying a route |
| 629 | may result in the route command returning non-zero which produces |
| 630 | some confusing output for users manually using ifup/ifdown[1]. To |
| 631 | that end, we will optionally include an '|| true' postfix to each |
| 632 | @@ -530,7 +528,7 @@ |
| 633 | |
| 634 | |
| 635 | def render_interfaces(network_state): |
| 636 | - ''' Given state, emit etc/network/interfaces content ''' |
| 637 | + '''Given state, emit etc/network/interfaces content.''' |
| 638 | |
| 639 | content = "" |
| 640 | interfaces = network_state.get('interfaces') |
| 641 | |
| 642 | === modified file 'cloudinit/net/network_state.py' |
| 643 | --- cloudinit/net/network_state.py 2016-03-23 16:05:22 +0000 |
| 644 | +++ cloudinit/net/network_state.py 2016-05-12 18:35:40 +0000 |
| 645 | @@ -36,7 +36,7 @@ |
| 646 | return network_state |
| 647 | |
| 648 | |
| 649 | -class NetworkState: |
| 650 | +class NetworkState(object): |
| 651 | def __init__(self, version=NETWORK_STATE_VERSION, config=None): |
| 652 | self.version = version |
| 653 | self.config = config |
| 654 | @@ -53,7 +53,7 @@ |
| 655 | def get_command_handlers(self): |
| 656 | METHOD_PREFIX = 'handle_' |
| 657 | methods = filter(lambda x: callable(getattr(self, x)) and |
| 658 | - x.startswith(METHOD_PREFIX), dir(self)) |
| 659 | + x.startswith(METHOD_PREFIX), dir(self)) |
| 660 | handlers = {} |
| 661 | for m in methods: |
| 662 | key = m.replace(METHOD_PREFIX, '') |
| 663 | @@ -379,8 +379,9 @@ |
| 664 | |
| 665 | |
| 666 | if __name__ == '__main__': |
| 667 | + import random |
| 668 | import sys |
| 669 | - import random |
| 670 | + |
| 671 | from cloudinit import net |
| 672 | |
| 673 | def load_config(nc): |
| 674 | |
| 675 | === modified file 'cloudinit/net/udev.py' |
| 676 | --- cloudinit/net/udev.py 2016-03-10 21:37:30 +0000 |
| 677 | +++ cloudinit/net/udev.py 2016-05-12 18:35:40 +0000 |
| 678 | @@ -48,7 +48,7 @@ |
| 679 | compose_udev_equality('DRIVERS', '?*'), |
| 680 | compose_udev_attr_equality('address', mac), |
| 681 | compose_udev_setting('NAME', interface), |
| 682 | - ]) |
| 683 | + ]) |
| 684 | return '%s\n' % rule |
| 685 | |
| 686 | # vi: ts=4 expandtab syntax=python |
| 687 | |
| 688 | === modified file 'cloudinit/netinfo.py' |
| 689 | --- cloudinit/netinfo.py 2015-01-21 22:56:53 +0000 |
| 690 | +++ cloudinit/netinfo.py 2016-05-12 18:35:40 +0000 |
| 691 | @@ -20,10 +20,11 @@ |
| 692 | # You should have received a copy of the GNU General Public License |
| 693 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 694 | |
| 695 | -import cloudinit.util as util |
| 696 | -from cloudinit.log import logging |
| 697 | import re |
| 698 | |
| 699 | +from cloudinit import log as logging |
| 700 | +from cloudinit import util |
| 701 | + |
| 702 | from prettytable import PrettyTable |
| 703 | |
| 704 | LOG = logging.getLogger() |
| 705 | @@ -163,7 +164,7 @@ |
| 706 | def getgateway(): |
| 707 | try: |
| 708 | routes = route_info() |
| 709 | - except: |
| 710 | + except Exception: |
| 711 | pass |
| 712 | else: |
| 713 | for r in routes.get('ipv4', []): |
| 714 | |
| 715 | === modified file 'cloudinit/reporting/handlers.py' |
| 716 | --- cloudinit/reporting/handlers.py 2015-09-17 19:56:51 +0000 |
| 717 | +++ cloudinit/reporting/handlers.py 2016-05-12 18:35:40 +0000 |
| 718 | @@ -4,9 +4,9 @@ |
| 719 | import json |
| 720 | import six |
| 721 | |
| 722 | -from ..registry import DictRegistry |
| 723 | -from .. import (url_helper, util) |
| 724 | -from .. import log as logging |
| 725 | +from cloudinit import log as logging |
| 726 | +from cloudinit.registry import DictRegistry |
| 727 | +from cloudinit import (url_helper, util) |
| 728 | |
| 729 | |
| 730 | LOG = logging.getLogger(__name__) |
| 731 | @@ -36,7 +36,7 @@ |
| 732 | input_level = level |
| 733 | try: |
| 734 | level = getattr(logging, level.upper()) |
| 735 | - except: |
| 736 | + except Exception: |
| 737 | LOG.warn("invalid level '%s', using WARN", input_level) |
| 738 | level = logging.WARN |
| 739 | self.level = level |
| 740 | @@ -81,7 +81,7 @@ |
| 741 | self.endpoint, data=json.dumps(event.as_dict()), |
| 742 | timeout=self.timeout, |
| 743 | retries=self.retries, ssl_details=self.ssl_details) |
| 744 | - except: |
| 745 | + except Exception: |
| 746 | LOG.warn("failed posting event: %s" % event.as_string()) |
| 747 | |
| 748 | |
| 749 | |
| 750 | === modified file 'cloudinit/sources/DataSourceAzure.py' |
| 751 | --- cloudinit/sources/DataSourceAzure.py 2016-03-24 16:51:31 +0000 |
| 752 | +++ cloudinit/sources/DataSourceAzure.py 2016-05-12 18:35:40 +0000 |
| 753 | @@ -27,11 +27,12 @@ |
| 754 | |
| 755 | from xml.dom import minidom |
| 756 | |
| 757 | +from cloudinit.sources.helpers.azure import get_metadata_from_fabric |
| 758 | + |
| 759 | from cloudinit import log as logging |
| 760 | from cloudinit.settings import PER_ALWAYS |
| 761 | from cloudinit import sources |
| 762 | from cloudinit import util |
| 763 | -from cloudinit.sources.helpers.azure import get_metadata_from_fabric |
| 764 | |
| 765 | LOG = logging.getLogger(__name__) |
| 766 | |
| 767 | @@ -40,7 +41,8 @@ |
| 768 | AGENT_START = ['service', 'walinuxagent', 'start'] |
| 769 | BOUNCE_COMMAND = [ |
| 770 | 'sh', '-xc', |
| 771 | - "i=$interface; x=0; ifdown $i || x=$?; ifup $i || x=$?; exit $x"] |
| 772 | + "i=$interface; x=0; ifdown $i || x=$?; ifup $i || x=$?; exit $x" |
| 773 | +] |
| 774 | |
| 775 | BUILTIN_DS_CONFIG = { |
| 776 | 'agent_command': AGENT_START, |
| 777 | @@ -51,7 +53,7 @@ |
| 778 | 'policy': True, |
| 779 | 'command': BOUNCE_COMMAND, |
| 780 | 'hostname_command': 'hostname', |
| 781 | - }, |
| 782 | + }, |
| 783 | 'disk_aliases': {'ephemeral0': '/dev/sdb'}, |
| 784 | } |
| 785 | |
| 786 | @@ -60,7 +62,7 @@ |
| 787 | 'ephemeral0': {'table_type': 'gpt', |
| 788 | 'layout': [100], |
| 789 | 'overwrite': True}, |
| 790 | - }, |
| 791 | + }, |
| 792 | 'fs_setup': [{'filesystem': 'ext4', |
| 793 | 'device': 'ephemeral0.1', |
| 794 | 'replace_fs': 'ntfs'}], |
| 795 | @@ -312,7 +314,7 @@ |
| 796 | file_count = 0 |
| 797 | try: |
| 798 | file_count = util.mount_cb(device, count_files) |
| 799 | - except: |
| 800 | + except Exception: |
| 801 | return None |
| 802 | LOG.debug("fabric prepared ephmeral0.1 has %s files on it", file_count) |
| 803 | |
| 804 | |
| 805 | === modified file 'cloudinit/sources/DataSourceBigstep.py' |
| 806 | --- cloudinit/sources/DataSourceBigstep.py 2016-03-07 12:30:08 +0000 |
| 807 | +++ cloudinit/sources/DataSourceBigstep.py 2016-05-12 18:35:40 +0000 |
| 808 | @@ -4,13 +4,13 @@ |
| 809 | # Author: Alexandru Sirbu <alexandru.sirbu@bigstep.com> |
| 810 | # |
| 811 | |
| 812 | +import errno |
| 813 | import json |
| 814 | -import errno |
| 815 | |
| 816 | from cloudinit import log as logging |
| 817 | from cloudinit import sources |
| 818 | +from cloudinit import url_helper |
| 819 | from cloudinit import util |
| 820 | -from cloudinit import url_helper |
| 821 | |
| 822 | LOG = logging.getLogger(__name__) |
| 823 | |
| 824 | |
| 825 | === modified file 'cloudinit/sources/DataSourceCloudSigma.py' |
| 826 | --- cloudinit/sources/DataSourceCloudSigma.py 2016-04-12 16:57:50 +0000 |
| 827 | +++ cloudinit/sources/DataSourceCloudSigma.py 2016-05-12 18:35:40 +0000 |
| 828 | @@ -19,10 +19,11 @@ |
| 829 | import os |
| 830 | import re |
| 831 | |
| 832 | +from cloudinit.cs_utils import Cepko |
| 833 | + |
| 834 | from cloudinit import log as logging |
| 835 | from cloudinit import sources |
| 836 | from cloudinit import util |
| 837 | -from cloudinit.cs_utils import Cepko |
| 838 | |
| 839 | LOG = logging.getLogger(__name__) |
| 840 | |
| 841 | @@ -77,7 +78,7 @@ |
| 842 | try: |
| 843 | server_context = self.cepko.all().result |
| 844 | server_meta = server_context['meta'] |
| 845 | - except: |
| 846 | + except Exception: |
| 847 | # TODO: check for explicit "config on", and then warn |
| 848 | # but since no explicit config is available now, just debug. |
| 849 | LOG.debug("CloudSigma: Unable to read from serial port") |
| 850 | |
| 851 | === modified file 'cloudinit/sources/DataSourceCloudStack.py' |
| 852 | --- cloudinit/sources/DataSourceCloudStack.py 2016-04-28 15:33:43 +0000 |
| 853 | +++ cloudinit/sources/DataSourceCloudStack.py 2016-05-12 18:35:40 +0000 |
| 854 | @@ -25,14 +25,15 @@ |
| 855 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 856 | |
| 857 | import os |
| 858 | -import time |
| 859 | from socket import inet_ntoa |
| 860 | from struct import pack |
| 861 | +import time |
| 862 | |
| 863 | from cloudinit import ec2_utils as ec2 |
| 864 | from cloudinit import log as logging |
| 865 | +from cloudinit import sources |
| 866 | from cloudinit import url_helper as uhelp |
| 867 | -from cloudinit import sources, util |
| 868 | +from cloudinit import util |
| 869 | |
| 870 | LOG = logging.getLogger(__name__) |
| 871 | |
| 872 | |
| 873 | === modified file 'cloudinit/sources/DataSourceDigitalOcean.py' |
| 874 | --- cloudinit/sources/DataSourceDigitalOcean.py 2016-03-04 06:45:58 +0000 |
| 875 | +++ cloudinit/sources/DataSourceDigitalOcean.py 2016-05-12 18:35:40 +0000 |
| 876 | @@ -14,10 +14,10 @@ |
| 877 | # You should have received a copy of the GNU General Public License |
| 878 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 879 | |
| 880 | +from cloudinit import ec2_utils |
| 881 | from cloudinit import log as logging |
| 882 | +from cloudinit import sources |
| 883 | from cloudinit import util |
| 884 | -from cloudinit import sources |
| 885 | -from cloudinit import ec2_utils |
| 886 | |
| 887 | import functools |
| 888 | |
| 889 | |
| 890 | === modified file 'cloudinit/sources/DataSourceGCE.py' |
| 891 | --- cloudinit/sources/DataSourceGCE.py 2015-07-22 12:06:34 +0000 |
| 892 | +++ cloudinit/sources/DataSourceGCE.py 2016-05-12 18:35:40 +0000 |
| 893 | @@ -18,9 +18,9 @@ |
| 894 | from base64 import b64decode |
| 895 | |
| 896 | from cloudinit import log as logging |
| 897 | -from cloudinit import util |
| 898 | from cloudinit import sources |
| 899 | from cloudinit import url_helper |
| 900 | +from cloudinit import util |
| 901 | |
| 902 | LOG = logging.getLogger(__name__) |
| 903 | |
| 904 | @@ -71,7 +71,7 @@ |
| 905 | index = public_key.index(':') |
| 906 | if index > 0: |
| 907 | return public_key[(index + 1):] |
| 908 | - except: |
| 909 | + except Exception: |
| 910 | return public_key |
| 911 | |
| 912 | def get_data(self): |
| 913 | |
| 914 | === modified file 'cloudinit/sources/DataSourceNoCloud.py' |
| 915 | --- cloudinit/sources/DataSourceNoCloud.py 2016-04-12 15:54:31 +0000 |
| 916 | +++ cloudinit/sources/DataSourceNoCloud.py 2016-05-12 18:35:40 +0000 |
| 917 | @@ -61,7 +61,7 @@ |
| 918 | if parse_cmdline_data(self.cmdline_id, md): |
| 919 | found.append("cmdline") |
| 920 | mydata = _merge_new_seed(mydata, {'meta-data': md}) |
| 921 | - except: |
| 922 | + except Exception: |
| 923 | util.logexc(LOG, "Unable to parse command line data") |
| 924 | return False |
| 925 | |
| 926 | @@ -288,7 +288,7 @@ |
| 927 | continue |
| 928 | try: |
| 929 | (k, v) = item.split("=", 1) |
| 930 | - except: |
| 931 | + except Exception: |
| 932 | k = item |
| 933 | v = None |
| 934 | if k in s2l: |
| 935 | |
| 936 | === modified file 'cloudinit/sources/DataSourceOVF.py' |
| 937 | --- cloudinit/sources/DataSourceOVF.py 2016-03-29 18:38:47 +0000 |
| 938 | +++ cloudinit/sources/DataSourceOVF.py 2016-05-12 18:35:40 +0000 |
| 939 | @@ -30,13 +30,20 @@ |
| 940 | from cloudinit import log as logging |
| 941 | from cloudinit import sources |
| 942 | from cloudinit import util |
| 943 | -from .helpers.vmware.imc.config import Config |
| 944 | -from .helpers.vmware.imc.config_file import ConfigFile |
| 945 | -from .helpers.vmware.imc.config_nic import NicConfigurator |
| 946 | -from .helpers.vmware.imc.guestcust_event import GuestCustEventEnum |
| 947 | -from .helpers.vmware.imc.guestcust_state import GuestCustStateEnum |
| 948 | -from .helpers.vmware.imc.guestcust_error import GuestCustErrorEnum |
| 949 | -from .helpers.vmware.imc.guestcust_util import ( |
| 950 | + |
| 951 | +from cloudinit.sources.helpers.vmware.imc.config \ |
| 952 | + import Config |
| 953 | +from cloudinit.sources.helpers.vmware.imc.config_file \ |
| 954 | + import ConfigFile |
| 955 | +from cloudinit.sources.helpers.vmware.imc.config_nic \ |
| 956 | + import NicConfigurator |
| 957 | +from cloudinit.sources.helpers.vmware.imc.guestcust_event \ |
| 958 | + import GuestCustEventEnum |
| 959 | +from cloudinit.sources.helpers.vmware.imc.guestcust_state \ |
| 960 | + import GuestCustStateEnum |
| 961 | +from cloudinit.sourceshelpers.vmware.imc.guestcust_error \ |
| 962 | + import GuestCustErrorEnum |
| 963 | +from cloudinit.sourceshelpers.vmware.imc.guestcust_util import ( |
| 964 | set_customization_status, |
| 965 | get_nics_to_enable, |
| 966 | enable_nics |
| 967 | @@ -262,7 +269,7 @@ |
| 968 | elif prop == "user-data": |
| 969 | try: |
| 970 | ud = base64.decodestring(val) |
| 971 | - except: |
| 972 | + except Exception: |
| 973 | ud = val |
| 974 | return (md, ud, cfg) |
| 975 | |
| 976 | @@ -277,7 +284,7 @@ |
| 977 | try: |
| 978 | contents = util.load_file(full_fn) |
| 979 | return (fname, contents) |
| 980 | - except: |
| 981 | + except Exception: |
| 982 | util.logexc(LOG, "Failed loading ovf file %s", full_fn) |
| 983 | return (None, False) |
| 984 | |
| 985 | |
| 986 | === modified file 'cloudinit/sources/__init__.py' |
| 987 | --- cloudinit/sources/__init__.py 2016-04-04 16:31:28 +0000 |
| 988 | +++ cloudinit/sources/__init__.py 2016-05-12 18:35:40 +0000 |
| 989 | @@ -45,10 +45,9 @@ |
| 990 | pass |
| 991 | |
| 992 | |
| 993 | +@six.add_metaclass(abc.ABCMeta) |
| 994 | class DataSource(object): |
| 995 | |
| 996 | - __metaclass__ = abc.ABCMeta |
| 997 | - |
| 998 | def __init__(self, sys_cfg, distro, paths, ud_proc=None): |
| 999 | self.sys_cfg = sys_cfg |
| 1000 | self.distro = distro |
| 1001 | |
| 1002 | === modified file 'cloudinit/sources/helpers/azure.py' |
| 1003 | --- cloudinit/sources/helpers/azure.py 2016-02-16 22:00:29 +0000 |
| 1004 | +++ cloudinit/sources/helpers/azure.py 2016-05-12 18:35:40 +0000 |
| 1005 | @@ -5,6 +5,7 @@ |
| 1006 | import struct |
| 1007 | import tempfile |
| 1008 | import time |
| 1009 | + |
| 1010 | from contextlib import contextmanager |
| 1011 | from xml.etree import ElementTree |
| 1012 | |
| 1013 | |
| 1014 | === modified file 'cloudinit/sources/helpers/openstack.py' |
| 1015 | --- cloudinit/sources/helpers/openstack.py 2016-03-23 19:17:10 +0000 |
| 1016 | +++ cloudinit/sources/helpers/openstack.py 2016-05-12 18:35:40 +0000 |
| 1017 | @@ -145,8 +145,8 @@ |
| 1018 | return device |
| 1019 | |
| 1020 | |
| 1021 | +@six.add_metaclass(abc.ABCMeta) |
| 1022 | class BaseReader(object): |
| 1023 | - __metaclass__ = abc.ABCMeta |
| 1024 | |
| 1025 | def __init__(self, base_path): |
| 1026 | self.base_path = base_path |
| 1027 | @@ -475,7 +475,7 @@ |
| 1028 | |
| 1029 | |
| 1030 | def convert_vendordata_json(data, recurse=True): |
| 1031 | - """ data: a loaded json *object* (strings, arrays, dicts). |
| 1032 | + """data: a loaded json *object* (strings, arrays, dicts). |
| 1033 | return something suitable for cloudinit vendordata_raw. |
| 1034 | |
| 1035 | if data is: |
| 1036 | |
| 1037 | === modified file 'cloudinit/sources/helpers/vmware/imc/boot_proto.py' |
| 1038 | --- cloudinit/sources/helpers/vmware/imc/boot_proto.py 2016-01-20 02:24:54 +0000 |
| 1039 | +++ cloudinit/sources/helpers/vmware/imc/boot_proto.py 2016-05-12 18:35:40 +0000 |
| 1040 | @@ -18,7 +18,7 @@ |
| 1041 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1042 | |
| 1043 | |
| 1044 | -class BootProtoEnum: |
| 1045 | +class BootProtoEnum(object): |
| 1046 | """Specifies the NIC Boot Settings.""" |
| 1047 | |
| 1048 | DHCP = 'dhcp' |
| 1049 | |
| 1050 | === modified file 'cloudinit/sources/helpers/vmware/imc/config.py' |
| 1051 | --- cloudinit/sources/helpers/vmware/imc/config.py 2016-01-20 02:24:54 +0000 |
| 1052 | +++ cloudinit/sources/helpers/vmware/imc/config.py 2016-05-12 18:35:40 +0000 |
| 1053 | @@ -20,7 +20,7 @@ |
| 1054 | from .nic import Nic |
| 1055 | |
| 1056 | |
| 1057 | -class Config: |
| 1058 | +class Config(object): |
| 1059 | """ |
| 1060 | Stores the Contents specified in the Customization |
| 1061 | Specification file. |
| 1062 | |
| 1063 | === modified file 'cloudinit/sources/helpers/vmware/imc/config_nic.py' |
| 1064 | --- cloudinit/sources/helpers/vmware/imc/config_nic.py 2016-03-11 19:29:15 +0000 |
| 1065 | +++ cloudinit/sources/helpers/vmware/imc/config_nic.py 2016-05-12 18:35:40 +0000 |
| 1066 | @@ -26,7 +26,7 @@ |
| 1067 | logger = logging.getLogger(__name__) |
| 1068 | |
| 1069 | |
| 1070 | -class NicConfigurator: |
| 1071 | +class NicConfigurator(object): |
| 1072 | def __init__(self, nics): |
| 1073 | """ |
| 1074 | Initialize the Nic Configurator |
| 1075 | |
| 1076 | === modified file 'cloudinit/sources/helpers/vmware/imc/config_source.py' |
| 1077 | --- cloudinit/sources/helpers/vmware/imc/config_source.py 2016-01-05 20:05:11 +0000 |
| 1078 | +++ cloudinit/sources/helpers/vmware/imc/config_source.py 2016-05-12 18:35:40 +0000 |
| 1079 | @@ -18,6 +18,6 @@ |
| 1080 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1081 | |
| 1082 | |
| 1083 | -class ConfigSource: |
| 1084 | +class ConfigSource(object): |
| 1085 | """Specifies a source for the Config Content.""" |
| 1086 | pass |
| 1087 | |
| 1088 | === modified file 'cloudinit/sources/helpers/vmware/imc/guestcust_error.py' |
| 1089 | --- cloudinit/sources/helpers/vmware/imc/guestcust_error.py 2016-03-08 20:41:08 +0000 |
| 1090 | +++ cloudinit/sources/helpers/vmware/imc/guestcust_error.py 2016-05-12 18:35:40 +0000 |
| 1091 | @@ -18,7 +18,7 @@ |
| 1092 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1093 | |
| 1094 | |
| 1095 | -class GuestCustErrorEnum: |
| 1096 | +class GuestCustErrorEnum(object): |
| 1097 | """Specifies different errors of Guest Customization engine""" |
| 1098 | |
| 1099 | GUESTCUST_ERROR_SUCCESS = 0 |
| 1100 | |
| 1101 | === modified file 'cloudinit/sources/helpers/vmware/imc/guestcust_event.py' |
| 1102 | --- cloudinit/sources/helpers/vmware/imc/guestcust_event.py 2016-03-08 20:41:08 +0000 |
| 1103 | +++ cloudinit/sources/helpers/vmware/imc/guestcust_event.py 2016-05-12 18:35:40 +0000 |
| 1104 | @@ -18,7 +18,7 @@ |
| 1105 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1106 | |
| 1107 | |
| 1108 | -class GuestCustEventEnum: |
| 1109 | +class GuestCustEventEnum(object): |
| 1110 | """Specifies different types of Guest Customization Events""" |
| 1111 | |
| 1112 | GUESTCUST_EVENT_CUSTOMIZE_FAILED = 100 |
| 1113 | |
| 1114 | === modified file 'cloudinit/sources/helpers/vmware/imc/guestcust_state.py' |
| 1115 | --- cloudinit/sources/helpers/vmware/imc/guestcust_state.py 2016-03-08 20:41:08 +0000 |
| 1116 | +++ cloudinit/sources/helpers/vmware/imc/guestcust_state.py 2016-05-12 18:35:40 +0000 |
| 1117 | @@ -18,7 +18,7 @@ |
| 1118 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1119 | |
| 1120 | |
| 1121 | -class GuestCustStateEnum: |
| 1122 | +class GuestCustStateEnum(object): |
| 1123 | """Specifies different states of Guest Customization engine""" |
| 1124 | |
| 1125 | GUESTCUST_STATE_RUNNING = 4 |
| 1126 | |
| 1127 | === modified file 'cloudinit/sources/helpers/vmware/imc/guestcust_util.py' |
| 1128 | --- cloudinit/sources/helpers/vmware/imc/guestcust_util.py 2016-03-11 21:29:28 +0000 |
| 1129 | +++ cloudinit/sources/helpers/vmware/imc/guestcust_util.py 2016-05-12 18:35:40 +0000 |
| 1130 | @@ -23,8 +23,8 @@ |
| 1131 | |
| 1132 | from cloudinit import util |
| 1133 | |
| 1134 | +from .guestcust_event import GuestCustEventEnum |
| 1135 | from .guestcust_state import GuestCustStateEnum |
| 1136 | -from .guestcust_event import GuestCustEventEnum |
| 1137 | |
| 1138 | logger = logging.getLogger(__name__) |
| 1139 | |
| 1140 | |
| 1141 | === modified file 'cloudinit/sources/helpers/vmware/imc/ipv4_mode.py' |
| 1142 | --- cloudinit/sources/helpers/vmware/imc/ipv4_mode.py 2016-01-20 02:24:54 +0000 |
| 1143 | +++ cloudinit/sources/helpers/vmware/imc/ipv4_mode.py 2016-05-12 18:35:40 +0000 |
| 1144 | @@ -18,7 +18,7 @@ |
| 1145 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1146 | |
| 1147 | |
| 1148 | -class Ipv4ModeEnum: |
| 1149 | +class Ipv4ModeEnum(object): |
| 1150 | """ |
| 1151 | The IPv4 configuration mode which directly represents the user's goal. |
| 1152 | |
| 1153 | |
| 1154 | === modified file 'cloudinit/sources/helpers/vmware/imc/nic_base.py' |
| 1155 | --- cloudinit/sources/helpers/vmware/imc/nic_base.py 2016-01-20 02:24:54 +0000 |
| 1156 | +++ cloudinit/sources/helpers/vmware/imc/nic_base.py 2016-05-12 18:35:40 +0000 |
| 1157 | @@ -18,7 +18,7 @@ |
| 1158 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1159 | |
| 1160 | |
| 1161 | -class NicBase: |
| 1162 | +class NicBase(object): |
| 1163 | """ |
| 1164 | Define what are expected of each nic. |
| 1165 | The following properties should be provided in an implementation class. |
| 1166 | @@ -93,7 +93,7 @@ |
| 1167 | raise NotImplementedError('Check constraints on properties') |
| 1168 | |
| 1169 | |
| 1170 | -class StaticIpv4Base: |
| 1171 | +class StaticIpv4Base(object): |
| 1172 | """ |
| 1173 | Define what are expected of a static IPv4 setting |
| 1174 | The following properties should be provided in an implementation class. |
| 1175 | @@ -124,7 +124,7 @@ |
| 1176 | raise NotImplementedError('Ipv4 GATEWAY') |
| 1177 | |
| 1178 | |
| 1179 | -class StaticIpv6Base: |
| 1180 | +class StaticIpv6Base(object): |
| 1181 | """Define what are expected of a static IPv6 setting |
| 1182 | The following properties should be provided in an implementation class. |
| 1183 | """ |
| 1184 | |
| 1185 | === modified file 'cloudinit/stages.py' |
| 1186 | --- cloudinit/stages.py 2016-04-15 16:16:14 +0000 |
| 1187 | +++ cloudinit/stages.py 2016-05-12 18:35:40 +0000 |
| 1188 | @@ -44,10 +44,10 @@ |
| 1189 | from cloudinit import importer |
| 1190 | from cloudinit import log as logging |
| 1191 | from cloudinit import net |
| 1192 | +from cloudinit.reporting import events |
| 1193 | from cloudinit import sources |
| 1194 | from cloudinit import type_utils |
| 1195 | from cloudinit import util |
| 1196 | -from cloudinit.reporting import events |
| 1197 | |
| 1198 | LOG = logging.getLogger(__name__) |
| 1199 | |
| 1200 | @@ -483,7 +483,7 @@ |
| 1201 | c_handlers.initialized.remove(mod) |
| 1202 | try: |
| 1203 | handlers.call_end(mod, data, frequency) |
| 1204 | - except: |
| 1205 | + except Exception: |
| 1206 | util.logexc(LOG, "Failed to finalize handler: %s", mod) |
| 1207 | |
| 1208 | try: |
| 1209 | |
| 1210 | === modified file 'cloudinit/url_helper.py' |
| 1211 | --- cloudinit/url_helper.py 2016-03-03 22:20:10 +0000 |
| 1212 | +++ cloudinit/url_helper.py 2016-05-12 18:35:40 +0000 |
| 1213 | @@ -28,8 +28,9 @@ |
| 1214 | |
| 1215 | from email.utils import parsedate |
| 1216 | from functools import partial |
| 1217 | + |
| 1218 | +import oauthlib.oauth1 as oauth1 |
| 1219 | from requests import exceptions |
| 1220 | -import oauthlib.oauth1 as oauth1 |
| 1221 | |
| 1222 | from six.moves.urllib.parse import ( |
| 1223 | urlparse, urlunparse, |
| 1224 | @@ -61,7 +62,7 @@ |
| 1225 | SSL_ENABLED = True |
| 1226 | if _REQ_VER >= LooseVersion('0.7.0') and _REQ_VER < LooseVersion('1.0.0'): |
| 1227 | CONFIG_ENABLED = True |
| 1228 | -except: |
| 1229 | +except ImportError: |
| 1230 | pass |
| 1231 | |
| 1232 | |
| 1233 | |
| 1234 | === modified file 'cloudinit/user_data.py' |
| 1235 | --- cloudinit/user_data.py 2015-04-16 21:00:19 +0000 |
| 1236 | +++ cloudinit/user_data.py 2016-05-12 18:35:40 +0000 |
| 1237 | @@ -178,7 +178,7 @@ |
| 1238 | payload = util.load_yaml(msg.get_payload(decode=True)) |
| 1239 | if payload: |
| 1240 | payload_idx = payload.get('launch-index') |
| 1241 | - except: |
| 1242 | + except Exception: |
| 1243 | pass |
| 1244 | # Header overrides contents, for now (?) or the other way around? |
| 1245 | if header_idx is not None: |
| 1246 | |
| 1247 | === modified file 'cloudinit/util.py' |
| 1248 | --- cloudinit/util.py 2016-03-24 19:30:03 +0000 |
| 1249 | +++ cloudinit/util.py 2016-05-12 18:35:40 +0000 |
| 1250 | @@ -288,7 +288,7 @@ |
| 1251 | try: |
| 1252 | child_cb(*args, **kwargs) |
| 1253 | os._exit(0) |
| 1254 | - except: |
| 1255 | + except Exception: |
| 1256 | logexc(LOG, "Failed forking and calling callback %s", |
| 1257 | type_utils.obj_name(child_cb)) |
| 1258 | os._exit(1) |
| 1259 | @@ -472,7 +472,7 @@ |
| 1260 | |
| 1261 | try: |
| 1262 | toks = [x for x in toks if int(x) < 256 and int(x) >= 0] |
| 1263 | - except: |
| 1264 | + except Exception: |
| 1265 | return False |
| 1266 | |
| 1267 | return len(toks) == 4 |
| 1268 | @@ -1210,7 +1210,7 @@ |
| 1269 | else: |
| 1270 | try: |
| 1271 | cmdline = load_file("/proc/cmdline").strip() |
| 1272 | - except: |
| 1273 | + except Exception: |
| 1274 | cmdline = "" |
| 1275 | |
| 1276 | PROC_CMDLINE = cmdline |
| 1277 | @@ -1380,7 +1380,7 @@ |
| 1278 | if not os.path.exists(target_fn): |
| 1279 | try: |
| 1280 | (key, url, content) = get_cmdline_url() |
| 1281 | - except: |
| 1282 | + except Exception: |
| 1283 | logexc(LOG, "Failed fetching command line url") |
| 1284 | return |
| 1285 | try: |
| 1286 | @@ -1391,7 +1391,7 @@ |
| 1287 | elif key and not content: |
| 1288 | LOG.debug(("Command line key %s with url" |
| 1289 | " %s had no contents"), key, url) |
| 1290 | - except: |
| 1291 | + except Exception: |
| 1292 | logexc(LOG, "Failed writing url content to %s", target_fn) |
| 1293 | |
| 1294 | |
| 1295 | @@ -1449,7 +1449,7 @@ |
| 1296 | mp = m.group(2) |
| 1297 | fstype = m.group(3) |
| 1298 | opts = m.group(4) |
| 1299 | - except: |
| 1300 | + except Exception: |
| 1301 | continue |
| 1302 | # If the name of the mount point contains spaces these |
| 1303 | # can be escaped as '\040', so undo that.. |
| 1304 | @@ -1575,7 +1575,7 @@ |
| 1305 | def time_rfc2822(): |
| 1306 | try: |
| 1307 | ts = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime()) |
| 1308 | - except: |
| 1309 | + except Exception: |
| 1310 | ts = "??" |
| 1311 | return ts |
| 1312 | |
| 1313 | @@ -1601,7 +1601,7 @@ |
| 1314 | bootup = buf.value |
| 1315 | uptime_str = now - bootup |
| 1316 | |
| 1317 | - except: |
| 1318 | + except Exception: |
| 1319 | logexc(LOG, "Unable to read uptime using method: %s" % method) |
| 1320 | return uptime_str |
| 1321 | |
| 1322 | @@ -2055,7 +2055,7 @@ |
| 1323 | tmsg += " (N/A)" |
| 1324 | try: |
| 1325 | logfunc(msg + tmsg) |
| 1326 | - except: |
| 1327 | + except Exception: |
| 1328 | pass |
| 1329 | return ret |
| 1330 | |
| 1331 | |
| 1332 | === modified file 'test-requirements.txt' |
| 1333 | --- test-requirements.txt 2015-02-10 20:32:32 +0000 |
| 1334 | +++ test-requirements.txt 2016-05-12 18:35:40 +0000 |
| 1335 | @@ -1,7 +1,14 @@ |
| 1336 | +# Needed generally in tests |
| 1337 | httpretty>=0.7.1 |
| 1338 | mock |
| 1339 | nose |
| 1340 | -pep8==1.5.7 |
| 1341 | -pyflakes |
| 1342 | + |
| 1343 | +# Only really needed on older versions of python |
| 1344 | contextlib2 |
| 1345 | setuptools |
| 1346 | + |
| 1347 | +# Used for syle checking |
| 1348 | +pep8==1.7.0 |
| 1349 | +pyflakes==1.1.0 |
| 1350 | +flake8==2.5.4 |
| 1351 | +hacking==0.10.2 |
| 1352 | |
| 1353 | === modified file 'tox.ini' |
| 1354 | --- tox.ini 2016-03-04 06:45:58 +0000 |
| 1355 | +++ tox.ini 2016-05-12 18:35:40 +0000 |
| 1356 | @@ -30,3 +30,8 @@ |
| 1357 | pyflakes |
| 1358 | setenv = |
| 1359 | LC_ALL = C |
| 1360 | + |
| 1361 | +[flake8] |
| 1362 | + |
| 1363 | +ignore=H404,H405,H105,H301,H104,H403,H101 |
| 1364 | +exclude = .venv,.tox,dist,doc,*egg,.git,build,tools,tests |


Hey,
this looks fine.
pull from lp:~smoser/cloud-init/cloud-init-flake8-fixups
and then you can merge into trunk.
I just fixed the tests/ and made 'tox' use flake8 instead of pyflakes.