[node-patches] Change in ovirt-node[master]: Fix the codebase up so it passes code smells again
rbarry at redhat.com
rbarry at redhat.com
Fri Feb 21 15:22:57 UTC 2014
Ryan Barry has uploaded a new change for review.
Change subject: Fix the codebase up so it passes code smells again
......................................................................
Fix the codebase up so it passes code smells again
Codebase got pretty battered. Make it pass check-local.
Change-Id: If722aafb59c777b4f85dc07c3f50911ecfe96ae7
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/config/migrate.py
M src/ovirt/node/installer/core/installation_device_page.py
M src/ovirt/node/installer/core/storage_vol_page.py
M src/ovirt/node/setup/core/network_page.py
M src/ovirt/node/setup/puppet/puppet_page.py
M src/ovirt/node/utils/fs.py
M src/ovirt/node/utils/network.py
M src/ovirt/node/utils/process.py
M src/ovirt/node/utils/storage.py
M src/ovirt/node/valid.py
10 files changed, 19 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/68/24868/1
diff --git a/src/ovirt/node/config/migrate.py b/src/ovirt/node/config/migrate.py
index 270c633..6267109 100644
--- a/src/ovirt/node/config/migrate.py
+++ b/src/ovirt/node/config/migrate.py
@@ -19,7 +19,6 @@
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
from ovirt.node import base
-from ovirt.node.config import defaults
from ovirt.node.utils import AugeasWrapper, network, parse_bool
from ovirt.node.utils.fs import Config
from ovirtnode import iscsi, log, ovirtfunctions
diff --git a/src/ovirt/node/installer/core/installation_device_page.py b/src/ovirt/node/installer/core/installation_device_page.py
index 75bf52b..364d099 100644
--- a/src/ovirt/node/installer/core/installation_device_page.py
+++ b/src/ovirt/node/installer/core/installation_device_page.py
@@ -61,7 +61,7 @@
def validators(self):
def has_selection(v):
if (self.widgets["installation.device.current"].selection() or
- "installation.device.custom" in self._model):
+ "installation.device.custom" in self._model):
return True
else:
return "Please select at least one installation device."
diff --git a/src/ovirt/node/installer/core/storage_vol_page.py b/src/ovirt/node/installer/core/storage_vol_page.py
index eaef02c..e67af34 100644
--- a/src/ovirt/node/installer/core/storage_vol_page.py
+++ b/src/ovirt/node/installer/core/storage_vol_page.py
@@ -23,6 +23,7 @@
"""
from ovirt.node import plugins, ui, valid
+from ovirt.node.utils import process
from ovirt.node.exceptions import InvalidData
diff --git a/src/ovirt/node/setup/core/network_page.py b/src/ovirt/node/setup/core/network_page.py
index c337557..73fc40f 100644
--- a/src/ovirt/node/setup/core/network_page.py
+++ b/src/ovirt/node/setup/core/network_page.py
@@ -130,7 +130,8 @@
fqdn_ip_or_empty = valid.FQDNOrIPAddress() | valid.Empty()
valid_bond_name = valid.RegexValidator("^(bond[0-9]{1,2}|007)$",
- "a valid bond name (bond[0-99])")
+ "a valid bond name (bond[0-99])"
+ )
# No regex, but for users ^
return {"hostname": fqdn_ip_or_empty,
diff --git a/src/ovirt/node/setup/puppet/puppet_page.py b/src/ovirt/node/setup/puppet/puppet_page.py
index dc829d4..57ae961 100644
--- a/src/ovirt/node/setup/puppet/puppet_page.py
+++ b/src/ovirt/node/setup/puppet/puppet_page.py
@@ -24,7 +24,6 @@
from ovirt.node.utils import system, fs
from ovirt.node.utils.fs import File
import re
-import socket
"""
Configure Puppet
diff --git a/src/ovirt/node/utils/fs.py b/src/ovirt/node/utils/fs.py
index 33b40f7..0cf6385 100644
--- a/src/ovirt/node/utils/fs.py
+++ b/src/ovirt/node/utils/fs.py
@@ -24,8 +24,10 @@
"""
from ovirt.node import log
+from ovirt.node.utils import process
import shutil
import os
+import re
import StringIO
from ovirt.node import base
diff --git a/src/ovirt/node/utils/network.py b/src/ovirt/node/utils/network.py
index bd04142..407a938 100644
--- a/src/ovirt/node/utils/network.py
+++ b/src/ovirt/node/utils/network.py
@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
-from ovirt.node import config, base, utils, config, valid, log
+from ovirt.node import base, utils, config, valid, log
from ovirt.node.config.network import NicConfig
from ovirt.node.utils import fs
from ovirt.node.utils.fs import File
@@ -327,15 +327,15 @@
# Fallback
cmd = "ip -o addr show {ifname}".format(ifname=self.ifname)
for line in process.pipe(cmd, shell=True).split("\n"):
- matches = re.search("\s(inet[6]?)\s(.+)/([^\s]+).*scope ([^\s]+).*",
- line)
+ matches = re.search("\s(inet[6]?)\s(.+)/([^\s]+)"
+ ".*scope ([^\s]+).*", line)
if matches and matches.groups():
family, addr, mask, scope = matches.groups()
if family not in families:
continue
if family == "inet":
mask = calcDottedNetmask(mask)
- if scope == "global" or addresses[family].address == None:
+ if scope == "global" or addresses[family].address is None:
addresses[family] = IPAddress(addr, mask, scope)
return addresses
@@ -630,9 +630,11 @@
return candidate
def is_configured(self):
- """The NodeNetwork is either configered when we or a mgmt instance configured it
+ """The NodeNetwork is either configered when we or a mgmt instance
+ configured it
"""
- mgmtInterface = config.defaults.Management().retrieve()["managed_ifnames"]
+ mgmtInterface = config.defaults.Management().retrieve()[
+ "managed_ifnames"]
return any([self.configured_nic(), mgmtInterface])
@@ -783,7 +785,7 @@
if not data_block:
continue
vdev, vid, hdev = [field.strip()
- for field in line.split("|")]
+ for field in line.split("|")]
if not hdev in vlans:
vlans[hdev] = []
vlans[hdev].append((vdev, vid))
diff --git a/src/ovirt/node/utils/process.py b/src/ovirt/node/utils/process.py
index 30dd8a0..3cee5e5 100644
--- a/src/ovirt/node/utils/process.py
+++ b/src/ovirt/node/utils/process.py
@@ -54,7 +54,6 @@
def masked(masks):
"""A context manager to hide certain args before logging
- >>> import sys
>>> with masked(["Lemmings"]):
... log_call("Beware", ["Domminated", "By",
... "Lemmings"], {"Save": "Lemmings"},
@@ -67,6 +66,7 @@
def __enter__(self):
self.old_masks = log_call.masks
log_call.masks = masks
+
def __exit__(self, exc_type, exc_value, traceback):
log_call.masks = self.old_masks
diff --git a/src/ovirt/node/utils/storage.py b/src/ovirt/node/utils/storage.py
index da98012..5792af4 100644
--- a/src/ovirt/node/utils/storage.py
+++ b/src/ovirt/node/utils/storage.py
@@ -20,7 +20,6 @@
# also available at http://www.gnu.org/copyleft/gpl.html.
from ovirt.node import base
-from ovirt.node.utils import process
from ovirt.node.utils.fs import File
import os
@@ -68,7 +67,6 @@
return self.__get_domain()
def __set_domain(self, domain):
- current_domain = self.__get_domain()
cfg = File(self.configfilename)
if domain:
diff --git a/src/ovirt/node/valid.py b/src/ovirt/node/valid.py
index f969ea0..0441b93 100644
--- a/src/ovirt/node/valid.py
+++ b/src/ovirt/node/valid.py
@@ -469,7 +469,6 @@
True
"""
-
description = "a valid URL"
requires_scheme = True
@@ -477,9 +476,9 @@
requires_path = False
def __init__(self, scheme=True, netloc=True, path=False):
- self.requires_scheme = scheme
- self.requires_netloc = netloc
- self.requires_path = path
+ self.requires_scheme = scheme
+ self.requires_netloc = netloc
+ self.requires_path = path
def validate(self, value):
p = urlparse.urlparse(value)
--
To view, visit http://gerrit.ovirt.org/24868
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If722aafb59c777b4f85dc07c3f50911ecfe96ae7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
More information about the node-patches
mailing list