jdahlin - in flumotion/trunk: . flumotion/admin/command
flumotion/common flumotion/component/base
flumotion/component/bouncers flumotion/component/consumers/disker
flumotion/component/consumers/httpstreamer
flumotion/component/misc/porter flumotion/extern/log
flumotion/manager flumotion/test flumotion/twisted flumotion/worker
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Wed Dec 26 16:43:39 CET 2007
Author: jdahlin
Date: Wed Dec 26 16:39:08 2007
New Revision: 6038
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/admin/command/commands.py
flumotion/trunk/flumotion/common/common.py
flumotion/trunk/flumotion/common/netutils.py
flumotion/trunk/flumotion/component/base/http.py
flumotion/trunk/flumotion/component/bouncers/icalbouncer.py
flumotion/trunk/flumotion/component/consumers/disker/disker.py
flumotion/trunk/flumotion/component/consumers/httpstreamer/admin_gtk.py
flumotion/trunk/flumotion/component/misc/porter/porter.py
flumotion/trunk/flumotion/extern/log/termcolor.py
flumotion/trunk/flumotion/manager/main.py
flumotion/trunk/flumotion/test/test_twisted_integration.py
flumotion/trunk/flumotion/twisted/integration.py
flumotion/trunk/flumotion/worker/base.py
Log:
2007-12-26 Johan Dahlin <johan at gnome.org>
* flumotion/*.py: Some simple low-hanging fruit cases of except:
removed, part of bug #791
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Wed Dec 26 16:39:08 2007
@@ -1,5 +1,8 @@
2007-12-26 Johan Dahlin <johan at gnome.org>
+ * flumotion/*.py: Some simple low-hanging fruit cases of except:
+ removed, part of bug #791
+
* flumotion/ui/wizard.py (_WalkableStack.skip_to): Cleanup, use
enumerate instead of range+len+getitem.
Modified: flumotion/trunk/flumotion/admin/command/commands.py
==============================================================================
--- flumotion/trunk/flumotion/admin/command/commands.py (original)
+++ flumotion/trunk/flumotion/admin/command/commands.py Wed Dec 26 16:39:08 2007
@@ -176,7 +176,7 @@
contents = f.read()
f.close()
return contents
- except:
+ except OSError:
raise ParseException("Failed to read file %s" % (filename,))
def _do_parse_typed_args(spec, args):
@@ -256,8 +256,6 @@
print "No method '%s' on component '%s'" % (methodName, avatarId)
except errors.SleepingComponentError:
print "Component %s not running." % avatarId[1]
- except Exception, e:
- raise
quit()
do_invoke = defer_generator(do_invoke)
@@ -279,8 +277,6 @@
print v
except errors.NoMethodError:
print "No method '%s' on component '%s'" % (methodName, workerName)
- except Exception, e:
- raise
quit()
do_workerinvoke = defer_generator(do_workerinvoke)
@@ -301,8 +297,6 @@
print v
except errors.NoMethodError:
print "No method '%s' on component '%s'" % (methodName, workerName)
- except Exception, e:
- raise
quit()
do_workerremoteinvoke = defer_generator(do_workerremoteinvoke)
@@ -323,8 +317,6 @@
print v
except errors.NoMethodError:
print "No method '%s' on manager" % (methodName,)
- except Exception, e:
- raise
quit()
do_managerinvoke = defer_generator(do_managerinvoke)
Modified: flumotion/trunk/flumotion/common/common.py
==============================================================================
--- flumotion/trunk/flumotion/common/common.py (original)
+++ flumotion/trunk/flumotion/common/common.py Wed Dec 26 16:39:08 2007
@@ -308,10 +308,11 @@
if not os.path.exists(dir):
try:
os.makedirs(dir)
- except:
+ except OSError, e:
from flumotion.common import errors
- raise errors.SystemError, "could not create %s directory %s" % (
- description, dir)
+ raise errors.SystemError(
+ "could not create %s directory %s: %s" % (
+ description, dir, str(e)))
def getPidPath(type, name=None):
"""
Modified: flumotion/trunk/flumotion/common/netutils.py
==============================================================================
--- flumotion/trunk/flumotion/common/netutils.py (original)
+++ flumotion/trunk/flumotion/common/netutils.py Wed Dec 26 16:39:08 2007
@@ -91,7 +91,7 @@
try:
return socket.gethostbyaddr(ip)[0]
- except:
+ except socket.error:
return ip
def ipv4StringToInt(s):
Modified: flumotion/trunk/flumotion/component/base/http.py
==============================================================================
--- flumotion/trunk/flumotion/component/base/http.py (original)
+++ flumotion/trunk/flumotion/component/base/http.py Wed Dec 26 16:39:08 2007
@@ -401,7 +401,7 @@
mask = ~((1 << (32 - prefixlen)) - 1)
try:
net = struct.unpack(">I", socket.inet_pton(socket.AF_INET, net))[0]
- except:
+ except socket.error:
raise errors.ConfigError("Failed to parse network address %s" % net)
net = net & mask # just in case
Modified: flumotion/trunk/flumotion/component/bouncers/icalbouncer.py
==============================================================================
--- flumotion/trunk/flumotion/component/bouncers/icalbouncer.py (original)
+++ flumotion/trunk/flumotion/component/bouncers/icalbouncer.py Wed Dec 26 16:39:08 2007
@@ -40,7 +40,7 @@
from icalendar import Calendar
from dateutil import rrule
HAS_ICAL = True
-except:
+except ImportError:
HAS_ICAL = False
class IcalBouncer(bouncer.Bouncer):
Modified: flumotion/trunk/flumotion/component/consumers/disker/disker.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/disker/disker.py (original)
+++ flumotion/trunk/flumotion/component/consumers/disker/disker.py Wed Dec 26 16:39:08 2007
@@ -67,7 +67,7 @@
from icalendar import Calendar
from dateutil import rrule
HAS_ICAL = True
-except:
+except ImportError:
HAS_ICAL = False
class DiskerMedium(feedcomponent.FeedComponentMedium):
Modified: flumotion/trunk/flumotion/component/consumers/httpstreamer/admin_gtk.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/httpstreamer/admin_gtk.py (original)
+++ flumotion/trunk/flumotion/component/consumers/httpstreamer/admin_gtk.py Wed Dec 26 16:39:08 2007
@@ -42,7 +42,7 @@
try:
__import__('gnomevfs')
self._hasgnomevfs = True
- except:
+ except ImportError:
pass
def error_dialog(self, message):
Modified: flumotion/trunk/flumotion/component/misc/porter/porter.py
==============================================================================
--- flumotion/trunk/flumotion/component/misc/porter/porter.py (original)
+++ flumotion/trunk/flumotion/component/misc/porter/porter.py Wed Dec 26 16:39:08 2007
@@ -310,7 +310,7 @@
# creates Transports that we know how to pass FDs over.
try:
os.unlink(self._socketPath)
- except:
+ except OSError:
pass
self._socketlistener = reactor.listenWith(
@@ -330,7 +330,7 @@
try:
proto = reflect.namedAny(self._porterProtocol)
self.debug("Created proto %r" % proto)
- except:
+ except (ImportError, AttributeError):
self.warning("Failed to import protocol '%s', defaulting to HTTP" %
self._porterProtocol)
proto = HTTPPorterProtocol
Modified: flumotion/trunk/flumotion/extern/log/termcolor.py
==============================================================================
--- flumotion/trunk/flumotion/extern/log/termcolor.py (original)
+++ flumotion/trunk/flumotion/extern/log/termcolor.py Wed Dec 26 16:39:08 2007
@@ -91,16 +91,20 @@
assumed to be a dumb terminal (i.e., have no capabilities).
"""
# Curses isn't available on all platforms
- try: import curses
- except: return
+ try:
+ import curses
+ except ImportError:
+ return
# If the stream isn't a tty, then assume it has no capabilities.
if not term_stream.isatty(): return
# Check the terminal type. If we fail, then assume that the
# terminal has no capabilities.
- try: curses.setupterm()
- except: return
+ try:
+ curses.setupterm()
+ except:
+ return
# Look up numeric capabilities.
self.COLS = curses.tigetnum('cols')
Modified: flumotion/trunk/flumotion/manager/main.py
==============================================================================
--- flumotion/trunk/flumotion/manager/main.py (original)
+++ flumotion/trunk/flumotion/manager/main.py Wed Dec 26 16:39:08 2007
@@ -180,19 +180,17 @@
if not options.certificate and options.transport == 'ssl':
options.certificate = 'default.pem'
if not options.name:
- try:
- # if the file is in a directory under a 'managers' directory,
- # use the parent directory name
- head, filename = os.path.split(os.path.abspath(planetFile))
- head, name = os.path.split(head)
- head, managers = os.path.split(head)
- if managers != 'managers':
- raise
- options.name = name
- log.debug('manager', 'Setting name to %s based on path' % name)
- except:
+ # if the file is in a directory under a 'managers' directory,
+ # use the parent directory name
+ head, filename = os.path.split(os.path.abspath(planetFile))
+ head, name = os.path.split(head)
+ head, managers = os.path.split(head)
+ if managers != 'managers':
options.name = 'unnamed'
log.debug('manager', 'Setting name to unnamed')
+ else:
+ options.name = name
+ log.debug('manager', 'Setting name to %s based on path' % name)
# check for wrong options/arguments
if not options.transport in ['ssl', 'tcp']:
Modified: flumotion/trunk/flumotion/test/test_twisted_integration.py
==============================================================================
--- flumotion/trunk/flumotion/test/test_twisted_integration.py (original)
+++ flumotion/trunk/flumotion/test/test_twisted_integration.py Wed Dec 26 16:39:08 2007
@@ -42,7 +42,7 @@
return d
try:
test.__name__ = proc.__name__
- except Exception:
+ except TypeError:
# can only set procedure names in python >= 2.4
pass
return test
Modified: flumotion/trunk/flumotion/twisted/integration.py
==============================================================================
--- flumotion/trunk/flumotion/twisted/integration.py (original)
+++ flumotion/trunk/flumotion/twisted/integration.py Wed Dec 26 16:39:08 2007
@@ -456,7 +456,7 @@
return plan.execute()
try:
wrappedtest.__name__ = testName
- except Exception:
+ except TypeError:
# can only set procedure names in python >= 2.4
pass
# trial seems to require a timeout, at least in twisted 2.4, so give
Modified: flumotion/trunk/flumotion/worker/base.py
==============================================================================
--- flumotion/trunk/flumotion/worker/base.py (original)
+++ flumotion/trunk/flumotion/worker/base.py Wed Dec 26 16:39:08 2007
@@ -176,7 +176,7 @@
f = pb.PBServerFactory(p)
try:
os.unlink(self._socketPath)
- except:
+ except OSError:
pass
# Rather than a listenUNIX(), we use listenWith so that we can specify
More information about the flumotion-commit
mailing list