[lnst] Config: add new options, update lnst-ctl.conf
by Jiří Pírko
commit f93ce47b06b916f3ef760e224895f9330f6f9c0f
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Oct 23 15:55:41 2012 +0200
Config: add new options, update lnst-ctl.conf
This patch adds 2 new options:
'test_module_dirs' which specifies a list of dirs where to look for
Test*.py files
'test_tool_dirs' which specifies a list of dirs where to look for
test_tool packages to be used by slaves
We agreed to use += for some options that work with lists. After this
patch, options that specify a list of values can be used with both '='
and '+='.
To specify a new list replacing the list loaded from previous
configuration files use '=', e.g.
'machine_pool_dirs = ~/.lnst/pool1/ ~/.lnst/pool2/'
To append to the values loaded from previous configuration files use
'+=', e.g.
'machine_pool_dirs += ~/.lnst/pool/'
This patch also updates the lnst-ctl.conf file to the current format.
The default values for the new options will be added later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/Config.py | 28 ++++++++++++++++++++++------
lnst-ctl.conf | 4 +++-
2 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/Common/Config.py b/Common/Config.py
index 5376f35..889ac4e 100644
--- a/Common/Config.py
+++ b/Common/Config.py
@@ -48,6 +48,8 @@ class Config():
['52:54:01:00:00:01', '52:54:01:FF:FF:FF']
self.options['environment']['rpcport'] = DefaultRPCPort
self.options['environment']['pool_dirs'] = []
+ self.options['environment']['tool_dirs'] = []
+ self.options['environment']['module_dirs'] = []
def init_slave(self):
pass
@@ -120,7 +122,22 @@ class Config():
elif option == 'rpcport':
section['rpcport'] = self.optionPort(config[option])
elif option == 'machine_pool_dirs':
- section['pool_dirs'] = self.optionPoolDirs(config[option],
+ section['pool_dirs'] = self.optionDirList(config[option],
+ cfg_path)
+ elif re.match(r'^machine_pool_dirs\s+\+$', option):
+ section['pool_dirs'] += self.optionDirList(config[option],
+ cfg_path)
+ elif option == 'test_module_dirs':
+ section['module_dirs'] = self.optionDirList(config[option],
+ cfg_path)
+ elif re.match(r'^test_module_dirs\s+\+$', option):
+ section['module_dirs'] += self.optionDirList(config[option],
+ cfg_path)
+ elif option == 'test_tool_dirs':
+ section['tool_dirs'] = self.optionDirList(config[option],
+ cfg_path)
+ elif re.match(r'^test_tool_dirs\s+\+$', option):
+ section['tool_dirs'] += self.optionDirList(config[option],
cfg_path)
else:
msg = "Unknown option: %s in section environment" % option
@@ -154,17 +171,16 @@ class Config():
raise ConfigError(msg)
return vals
- def optionPoolDirs(self, option, cfg_path):
- env = self.get_section('environment')
+ def optionDirList(self, option, cfg_path):
paths = re.split(r'(?<!\\)\s', option)
- pool_dirs = env['pool_dirs']
+ dirs = []
for path in paths:
if path == '':
continue
exp_path = os.path.expanduser(path)
abs_path = os.path.join(os.path.dirname(cfg_path), exp_path)
norm_path = os.path.normpath(abs_path)
- pool_dirs.append(norm_path)
+ dirs.append(norm_path)
- return pool_dirs
+ return dirs
diff --git a/lnst-ctl.conf b/lnst-ctl.conf
index 422804c..79451b3 100644
--- a/lnst-ctl.conf
+++ b/lnst-ctl.conf
@@ -2,5 +2,7 @@
mac_pool_range = 52:54:01:00:00:01 52:54:01:FF:FF:FF
rpcport = 9999
machine_pool_dirs =
+test_tool_dirs =
+test_module_dirs =
[log]
-path = ./
+path = ./Logs
11 years, 5 months
[lnst] Config: new configuration files
by Jiří Pírko
commit c4f983d9ef16ec94a2dd9871c6688d993c5d8e2a
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Oct 23 15:55:40 2012 +0200
Config: new configuration files
This commit renames the lnst.conf.example file to lnst-ctl.conf also the
file lnst-slave.conf has been added.
In the git tree these files will contain the default configuration
values. They will also be used for configuration in case you are using
the git version of the scripts.
The lnst-slave.conf is empty, options and values will be added later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst.conf.example => lnst-ctl.conf | 0
1 files changed, 0 insertions(+), 0 deletions(-)
---
diff --git a/lnst.conf.example b/lnst-ctl.conf
similarity index 100%
rename from lnst.conf.example
rename to lnst-ctl.conf
diff --git a/lnst-slave.conf b/lnst-slave.conf
new file mode 100644
index 0000000..e69de29
11 years, 5 months
[lnst] Config: change in hierarchy of config files
by Jiří Pírko
commit 80a786dd3e3370bec8d33dacf7d6b531056717f6
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Oct 23 15:55:39 2012 +0200
Config: change in hierarchy of config files
This patch changes the hierarchy by which we load configuration files to
the following:
1. We check for the existence of a configuration file located in the
same directory as the launched binary. This is for cases when the
application is launched from the git version. This configuration file
MUST NOT exist otherwise.
This configuration file has the HIGHEST priority and if it exists other
configuration files will not be loaded. This is to ensure that we can
run the git version and have the packaged version installed at the same
time without unnecessary conflicts.
2. We load the configuration file in /etc/ this should be the
system-wide configuration. We need this file mostly because of the slave
application which will be running as a daemon in the future. For
convention purposes and to not confuse the users this file will exist
even on the controller machines.
This file should be heavily documented and explain the available
options.
3. On the controller we load the configuration file located in the
~/.lnst directory. This can't be done on the slave machines as the slave
application will be running as a daemon and it would make sense to put
its configuration into the home directory of any user.
This patch also changes the names of the configuration files to:
lnst-ctl.conf
lnst-slave.conf
to distinguish the different schemes used in these files.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
nettestctl.py | 8 +++++++-
nettestslave.py | 10 ++++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/nettestctl.py b/nettestctl.py
index 6da53f2..e97733c 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -100,7 +100,13 @@ def main():
sys.exit()
config = Config("controller")
- config.load_config('~/.lnst/lnst.conf')
+ dirname = os.path.dirname(sys.argv[0])
+ gitcfg = os.path.join(dirname, "lnst-ctl.conf")
+ if os.path.isfile(gitcfg):
+ config.load_config(gitcfg)
+ else:
+ config.load_config('/etc/lnst-ctl.conf')
+ config.load_config('~/.lnst/lnst-ctl.conf')
debug = 0
recipe_path = None
diff --git a/nettestslave.py b/nettestslave.py
index 29528ff..c9cb0c9 100755
--- a/nettestslave.py
+++ b/nettestslave.py
@@ -13,10 +13,12 @@ jpirko(a)redhat.com (Jiri Pirko)
import getopt
import sys
+import os
import logging
from NetTest.NetTestSlave import NetTestSlave
from Common.Daemon import Daemon
from Common.Logs import Logs
+from Common.Config import Config
def usage():
"""
@@ -46,6 +48,14 @@ def main():
usage()
sys.exit()
+ config = Config("slave")
+ dirname = os.path.dirname(sys.argv[0])
+ gitcfg = os.path.join(dirname, "lnst-slave.conf")
+ if os.path.isfile(gitcfg):
+ config.load_config(gitcfg)
+ else:
+ config.load_config('/etc/lnst-slave.conf')
+
debug = False
daemon = False
pidfile = "nettestslave.pid"
11 years, 5 months
[lnst] Config: support for different config schemes
by Jiří Pírko
commit 775b14963d38a39430846f44adff4e4148a20c88
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Oct 23 15:55:38 2012 +0200
Config: support for different config schemes
The Config class now accepts an argument which specifies which
configuration scheme should be used. Currently I added a scheme
'controller', which was used until now as the configuration for the
controller, and 'slave' which will be used by the slave. The details of
the slave scheme will be added later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/Config.py | 35 ++++++++++++++++++++++++++++++++---
nettestctl.py | 2 +-
2 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/Common/Config.py b/Common/Config.py
index 297ebea..5376f35 100644
--- a/Common/Config.py
+++ b/Common/Config.py
@@ -23,10 +23,22 @@ class ConfigError(Exception):
class Config():
options = None
+ _scheme = None
- def __init__(self):
+ def __init__(self, scheme):
self.options = dict()
+ self._scheme = scheme
+ if self._scheme == "controller":
+ self.init_controller()
+ elif self._scheme == "slave":
+ self.init_slave()
+ else:
+ msg = "Unknow scheme: '%s', can't set up configuration"\
+ % self._scheme
+ raise ConfigError(msg)
+
+ def init_controller(self):
self.options['log'] = dict()
self.options['log']['path'] = os.path.join(
os.path.dirname(sys.argv[0]), './Logs')
@@ -37,6 +49,9 @@ class Config():
self.options['environment']['rpcport'] = DefaultRPCPort
self.options['environment']['pool_dirs'] = []
+ def init_slave(self):
+ pass
+
def get_config(self):
return self.options
@@ -61,15 +76,29 @@ class Config():
parser.read(abs_path)
sections = parser._sections
+
+ if self._scheme == "controller":
+ self.sectionsCntl(sections, abs_path)
+ elif self._scheme == "slave":
+ self.sectionsSlave(sections, abs_path)
+ else:
+ msg = "Unknow scheme: '%s', can't parse sections." \
+ % self._scheme
+ raise ConfigError(msg)
+
+ def sectionsCntl(self, sections, path):
for section in sections:
if section == "log":
- self.sectionLogs(sections[section], abs_path)
+ self.sectionLogs(sections[section], path)
elif section == "environment":
- self.sectionEnvironment(sections[section], abs_path)
+ self.sectionEnvironment(sections[section], path)
else:
msg = "Unknown section: %s" % section
raise ConfigError(msg)
+ def sectionsSlave(self, sections, path):
+ pass
+
def sectionLogs(self, config, cfg_path):
section = self.options['log']
diff --git a/nettestctl.py b/nettestctl.py
index d4178f4..6da53f2 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -99,7 +99,7 @@ def main():
usage()
sys.exit()
- config = Config()
+ config = Config("controller")
config.load_config('~/.lnst/lnst.conf')
debug = 0
11 years, 5 months
[lnst trac] #31: quick guides
by fedora-badges
#31: quick guides
------------------------+-------------------------------------------------
Reporter: jtluka | Owner: somebody
Type: task | Status: new
Priority: major | Milestone: Push LNST as a package into Fedora
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
------------------------+-------------------------------------------------
For the first time users it would be nice to have really quick ready-to-
use guidelines. See further quick-guide tickets for details.
The structure should be:
1. Simple description what's going to be achieved
2. Recipe sample with as little modification needed as possible
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/31>
lnst <http://example.org/>
My example project
11 years, 5 months
[lnst trac] #24: support for urls in recipes
by fedora-badges
#24: support for urls in recipes
-------------------------+-----------------------
Reporter: olichtne | Owner: somebody
Type: enhancement | Status: new
Priority: major | Milestone:
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
-------------------------+-----------------------
We discussed adding support of urls. The could be used instead of paths
for recipes either directly when starting tests or even when sourcing
other files inside recipes.
Sourcing other files is done in one function _get_referenced_xml_path in
file XmlProcessing which should be easy to modify.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/24>
lnst <http://example.org/>
My example project
11 years, 5 months
[lnst trac] #42: Redirection of logs into /var/log through syslog
by fedora-badges
#42: Redirection of logs into /var/log through syslog
------------------------+-------------------------------------------------
Reporter: olichtne | Owner: somebody
Type: defect | Status: new
Priority: major | Milestone: Push LNST as a package into Fedora
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
------------------------+-------------------------------------------------
In todays meeting we agreed that it would be ideal if logs were
centralized somewhere in the /var/log path. However since we cannot
guarantee that we have root access we can't directly create them here.
Therefore we would like to use syslog for this purpose. If this is
possible to do with our current logging system.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/42>
lnst <http://example.org/>
My example project
11 years, 5 months
[PATCH 1/4] Config: support for different config schemes
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The Config class now accepts an argument which specifies which
configuration scheme should be used. Currently I added a scheme
'controller', which was used until now as the configuration for the
controller, and 'slave' which will be used by the slave. The details of
the slave scheme will be added later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
Common/Config.py | 35 ++++++++++++++++++++++++++++++++---
nettestctl.py | 2 +-
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/Common/Config.py b/Common/Config.py
index 297ebea..5376f35 100644
--- a/Common/Config.py
+++ b/Common/Config.py
@@ -23,10 +23,22 @@ class ConfigError(Exception):
class Config():
options = None
+ _scheme = None
- def __init__(self):
+ def __init__(self, scheme):
self.options = dict()
+ self._scheme = scheme
+ if self._scheme == "controller":
+ self.init_controller()
+ elif self._scheme == "slave":
+ self.init_slave()
+ else:
+ msg = "Unknow scheme: '%s', can't set up configuration"\
+ % self._scheme
+ raise ConfigError(msg)
+
+ def init_controller(self):
self.options['log'] = dict()
self.options['log']['path'] = os.path.join(
os.path.dirname(sys.argv[0]), './Logs')
@@ -37,6 +49,9 @@ class Config():
self.options['environment']['rpcport'] = DefaultRPCPort
self.options['environment']['pool_dirs'] = []
+ def init_slave(self):
+ pass
+
def get_config(self):
return self.options
@@ -61,15 +76,29 @@ class Config():
parser.read(abs_path)
sections = parser._sections
+
+ if self._scheme == "controller":
+ self.sectionsCntl(sections, abs_path)
+ elif self._scheme == "slave":
+ self.sectionsSlave(sections, abs_path)
+ else:
+ msg = "Unknow scheme: '%s', can't parse sections." \
+ % self._scheme
+ raise ConfigError(msg)
+
+ def sectionsCntl(self, sections, path):
for section in sections:
if section == "log":
- self.sectionLogs(sections[section], abs_path)
+ self.sectionLogs(sections[section], path)
elif section == "environment":
- self.sectionEnvironment(sections[section], abs_path)
+ self.sectionEnvironment(sections[section], path)
else:
msg = "Unknown section: %s" % section
raise ConfigError(msg)
+ def sectionsSlave(self, sections, path):
+ pass
+
def sectionLogs(self, config, cfg_path):
section = self.options['log']
diff --git a/nettestctl.py b/nettestctl.py
index d4178f4..6da53f2 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -99,7 +99,7 @@ def main():
usage()
sys.exit()
- config = Config()
+ config = Config("controller")
config.load_config('~/.lnst/lnst.conf')
debug = 0
--
1.7.11.7
11 years, 5 months
[lnst] cleanup: Adjusting except statement syntax
by Jiří Pírko
commit 97b87769efdb48d85f292b5a9f6aad189aff9eab
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Oct 19 11:41:51 2012 +0200
cleanup: Adjusting except statement syntax
This patch replaces the old python's except statement syntax
except Exception, exc:
with the current one
except Exception as exc:
in the whole project.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Common/Daemon.py | 4 ++--
Common/Logs.py | 2 +-
Common/RecipePath.py | 2 +-
Common/SshUtils.py | 10 +++++-----
Common/XmlProcessing.py | 14 +++++++-------
Common/XmlTemplates.py | 2 +-
NetTest/NetTestController.py | 4 ++--
Tests/TestTCPConnect.py | 10 +++++-----
Tests/TestTCPListen.py | 14 +++++++-------
netconfig.py | 2 +-
nettestslave.py | 2 +-
switchconfig.py | 2 +-
swswitch.py | 2 +-
13 files changed, 35 insertions(+), 35 deletions(-)
---
diff --git a/Common/Daemon.py b/Common/Daemon.py
index 38bacf8..cf7dd22 100644
--- a/Common/Daemon.py
+++ b/Common/Daemon.py
@@ -41,7 +41,7 @@ class Daemon:
def _del_pidfile(self):
try:
os.remove(self._pidfile)
- except OSError, e:
+ except OSError as e:
if e.errno != 2:
raise(e)
@@ -67,6 +67,6 @@ class Daemon:
pid = os.getpid()
self._write_pid(pid)
logging.info("deamonized with pid %d" % pid)
- except OSError, e:
+ except OSError as e:
logging.error("fork failed: %d (%s)\n" % (e.errno, e.strerror))
sys.exit(1)
diff --git a/Common/Logs.py b/Common/Logs.py
index 745ed5b..8dde988 100644
--- a/Common/Logs.py
+++ b/Common/Logs.py
@@ -189,7 +189,7 @@ class Logs:
def clean_root_log_folder(cls, logRootPath):
try:
shutil.rmtree(logRootPath)
- except OSError, e:
+ except OSError as e:
if e.errno != 2:
raise
os.makedirs(logRootPath)
diff --git a/Common/RecipePath.py b/Common/RecipePath.py
index 60d035d..84c6acc 100644
--- a/Common/RecipePath.py
+++ b/Common/RecipePath.py
@@ -92,7 +92,7 @@ class HttpRecipePath(RecipePathGeneric):
try:
f = urlopen(url)
self._data = f.read()
- except IOError, err:
+ except IOError as err:
msg = "Unable to resolve path: %s (%s)" % (url, str(err))
raise Exception(msg)
diff --git a/Common/SshUtils.py b/Common/SshUtils.py
index f44f603..d287970 100644
--- a/Common/SshUtils.py
+++ b/Common/SshUtils.py
@@ -154,9 +154,9 @@ def _remote_login(session, username, password, prompt, timeout=10):
elif match == 6: # prompt
logging.log(logging.INFO, "Got shell prompt -- logged in")
break
- except ShellProcess.ProcessTimeoutError, e:
+ except ShellProcess.ProcessTimeoutError as e:
raise LoginTimeoutError(e.output)
- except ShellProcess.ProcessTerminatedError, e:
+ except ShellProcess.ProcessTerminatedError as e:
raise LoginProcessTerminatedError(e.status, e.output)
@@ -225,7 +225,7 @@ def wait_for_login(host, port, username, password, prompt, linesep="\n",
return remote_login(host, port, username, password, prompt,
linesep, log_filename, internal_timeout,
command)
- except LoginError, e:
+ except LoginError as e:
logging.debug(e)
time.sleep(2)
# Timeout expired; try one more time but don't catch exceptions
@@ -302,12 +302,12 @@ def _remote_scp(session, password_list, transfer_timeout=600, login_timeout=10):
"""elif match == 3: #Exit transfer correctly.
logging.log(logging.DEBUG2, "SCP process terminated with status 0")
break"""
- except ShellProcess.ProcessTimeoutError, e:
+ except ShellProcess.ProcessTimeoutError as e:
if authentication_done:
raise SCPTransferTimeoutError(e.output)
else:
raise SCPAuthenticationTimeoutError(e.output)
- except ShellProcess.ProcessTerminatedError, e:
+ except ShellProcess.ProcessTerminatedError as e:
if e.status == 0:
logging.log(logging.DEBUG2, "SCP process terminated with status 0")
break
diff --git a/Common/XmlProcessing.py b/Common/XmlProcessing.py
index 42057dc..d313be5 100644
--- a/Common/XmlProcessing.py
+++ b/Common/XmlProcessing.py
@@ -114,7 +114,7 @@ class XmlDomTreeInit:
self._filename = os.path.basename(filename)
try:
dom = parseString(xml_text, self._sax)
- except sax.SAXParseException, err:
+ except sax.SAXParseException as err:
pos = {"file": self._filename,
"line": err.getLineNumber(),
"col": err.getColumnNumber()}
@@ -172,7 +172,7 @@ class XmlParser(object):
if conversion_cb:
try:
converted = conversion_cb(string)
- except ValueError, err:
+ except ValueError as err:
raise XmlProcessingError("Conversion error: " + str(err), node)
return converted
@@ -259,7 +259,7 @@ class RecipeParser(XmlParser):
try:
handler = self._event_handlers[event_id]
- except KeyError, err:
+ except KeyError as err:
logging.warn("No handler found for %s event, ignoring", event_id)
return
@@ -299,7 +299,7 @@ class RecipeParser(XmlParser):
try:
dom = dom_init.parse_string(xmlstr,
filename=source_rp.abs_path())
- except IOError, err:
+ except IOError as err:
msg = "Unable to resolve include: %s" % str(err)
raise XmlProcessingError(msg, node)
@@ -335,7 +335,7 @@ class RecipeParser(XmlParser):
try:
attr_val = self._template_proc.expand_string(raw_attr_val)
- except XmlTemplateError, err:
+ except XmlTemplateError as err:
raise XmlProcessingError(str(err), node)
return self._convert_string(node, attr_val, conversion_cb)
@@ -346,7 +346,7 @@ class RecipeParser(XmlParser):
try:
content = self._template_proc.expand_string(raw_content)
- except XmlTemplateError, err:
+ except XmlTemplateError as err:
raise XmlProcessingError(str(err), node)
return self._convert_string(node, content, conversion_cb)
@@ -369,5 +369,5 @@ class RecipeParser(XmlParser):
try:
self._template_proc.define_alias(name, value)
- except XmlTemplateError, err:
+ except XmlTemplateError as err:
raise XmlProcessingError(str(err), node)
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py
index 9a62481..8f0d6e3 100644
--- a/Common/XmlTemplates.py
+++ b/Common/XmlTemplates.py
@@ -306,7 +306,7 @@ class XmlTemplates:
try:
recipe = self._find_definition("recipe")
return recipe
- except XmlTemplateError, err:
+ except XmlTemplateError as err:
msg = "Cannot resolve %s(): " % template_name
msg += str(err)
raise XmlTemplateError(msg)
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 3d01310..13eefb4 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -294,7 +294,7 @@ class NetTestController:
slave_root_path = os.path.join(self._log_root_path, address)
try:
os.mkdir(slave_root_path)
- except OSError, e:
+ except OSError as e:
if e.errno != 17:
raise
@@ -484,7 +484,7 @@ class NetTestController:
slave_logging_dir = os.path.join(logging_root, hostname)
try:
os.mkdir(slave_logging_dir)
- except OSError, err:
+ except OSError as err:
if err.errno != 17:
msg = "Cannot access the logging directory %s" \
% slave_logging_dir
diff --git a/Tests/TestTCPConnect.py b/Tests/TestTCPConnect.py
index f4020f0..50e9748 100644
--- a/Tests/TestTCPConnect.py
+++ b/Tests/TestTCPConnect.py
@@ -52,7 +52,7 @@ class ConnectionWorker():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- except socket.error, msg:
+ except socket.error as msg:
logging.debug(msg)
return
@@ -60,12 +60,12 @@ class ConnectionWorker():
try:
s.connect((self._host, self._port))
- except socket.timeout, msg:
+ except socket.timeout as msg:
logging.debug("Could not connect to %s port %s" %
(self._host, self._port))
s.close()
continue
- except socket.error, msg:
+ except socket.error as msg:
logging.debug(msg)
s.close()
break
@@ -91,7 +91,7 @@ class ConnectionWorker():
data = s.sendall(rnd_str)
except socket.timeout:
continue
- except socket.error, msg:
+ except socket.error as msg:
logging.debug(msg)
s.settimeout(0)
try:
@@ -196,7 +196,7 @@ class TestTCPConnect(TestGeneric):
for w in workers:
try:
w.join()
- except OSError, e:
+ except OSError as e:
continue
workers.remove(w)
diff --git a/Tests/TestTCPListen.py b/Tests/TestTCPListen.py
index 3cf0798..4de1083 100644
--- a/Tests/TestTCPListen.py
+++ b/Tests/TestTCPListen.py
@@ -67,7 +67,7 @@ class TestTCPListen(TestGeneric):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
- except socket.error, msg:
+ except socket.error as msg:
logging.debug(msg)
return
@@ -75,7 +75,7 @@ class TestTCPListen(TestGeneric):
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(1)
- except socket.error, msg:
+ except socket.error as msg:
logging.debug(msg)
s.close()
return
@@ -87,9 +87,9 @@ class TestTCPListen(TestGeneric):
while conn == None and not closecon.value:
try:
conn, addr = s.accept()
- except socket.timeout, e:
+ except socket.timeout as e:
continue
- except socket.error, e:
+ except socket.error as e:
logging.debug(e)
s.close()
return
@@ -110,9 +110,9 @@ class TestTCPListen(TestGeneric):
while not closecon.value:
try:
data = conn.recv(1024)
- except socket.timeout, e:
+ except socket.timeout as e:
continue
- except socket.error, e:
+ except socket.error as e:
logging.debug(e)
if conn:
conn.shutdown(socket.SHUT_RDWR)
@@ -129,7 +129,7 @@ class TestTCPListen(TestGeneric):
try:
conn.shutdown(socket.SHUT_RDWR)
conn.close()
- except socket.error, msg:
+ except socket.error as msg:
logging.debug(msg)
s.close()
return
diff --git a/netconfig.py b/netconfig.py
index c0baf97..6012667 100755
--- a/netconfig.py
+++ b/netconfig.py
@@ -120,7 +120,7 @@ def main():
"dhc:m:a:",
["debug", "help", "config=", "machine-config=", "action="]
)
- except getopt.GetoptError, err:
+ except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
diff --git a/nettestslave.py b/nettestslave.py
index 365ebdd..29528ff 100755
--- a/nettestslave.py
+++ b/nettestslave.py
@@ -41,7 +41,7 @@ def main():
"dhei:p:",
["debug", "help", "daemonize", "pidfile", "port"]
)[0]
- except getopt.GetoptError, err:
+ except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
diff --git a/switchconfig.py b/switchconfig.py
index ef38581..ed2b95e 100755
--- a/switchconfig.py
+++ b/switchconfig.py
@@ -38,7 +38,7 @@ def main():
"dhc:m:a:",
["debug", "help", "config=", "machine-config=", "action="]
)
- except getopt.GetoptError, err:
+ except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
diff --git a/swswitch.py b/swswitch.py
index aa8716d..42ef900 100755
--- a/swswitch.py
+++ b/swswitch.py
@@ -44,7 +44,7 @@ def main():
"dhm:p:",
["debug", "help", "machine-config=", "port="]
)
- except getopt.GetoptError, err:
+ except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
11 years, 5 months