Commit 1450948c authored by Arkadiusz Hiler's avatar Arkadiusz Hiler
Browse files

pep8: Fix compatiblity with the newest revision



Rather crude attempt to make things silent again.

patchwork/lock.py:232:13: E741 ambiguous variable name 'l'
patchwork/filters.py:105:9: E722 do not use bare except'
patchwork/filters.py:170:9: E722 do not use bare except'
patchwork/filters.py:352:9: E722 do not use bare except'
patchwork/models.py:344:9: E722 do not use bare except'
patchwork/tests/browser.py:26:1: E722 do not use bare except'
patchwork/tests/test_lock.py:68:9: E741 ambiguous variable name 'l'
patchwork/bin/parsemail.py:852:5: E741 ambiguous variable name 'l'
patchwork/bin/parsemail.py:857:5: E741 ambiguous variable name 'l'
patchwork/bin/parsemail.py:884:5: E722 do not use bare except'
patchwork/views/api.py:25:1: E722 do not use bare except'
patchwork/views/bundle.py:76:17: E722 do not use bare except'
patchwork/views/xmlrpc.py:95:9: E722 do not use bare except'
patchwork/views/xmlrpc.py:127:9: E722 do not use bare except'
patchwork/bin/pwclient:271:5: E722 do not use bare except'
patchwork/bin/pwclient:279:5: E722 do not use bare except'
patchwork/bin/pwclient:357:5: E722 do not use bare except'
patchwork/bin/pwclient:549:9: E722 do not use bare except'
patchwork/bin/pwclient:555:9: E722 do not use bare except'
patchwork/bin/pwclient:600:9: E722 do not use bare except'
patchwork/bin/pwclient:650:5: E722 do not use bare except'
git-pw/git-pw:540:9: E722 do not use bare except'
git-pw/git-pw:555:9: E722 do not use bare except'
git-pw/git-pw:567:9: E722 do not use bare except'
git-pw/git-pw:586:9: E722 do not use bare except'

"except Exception" should be chosen more carefully.
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 51a0dfe2
......@@ -537,7 +537,7 @@ class GitPatchwork(object):
default_config = None
try:
default_config = config.get('patchwork', 'defaultconfig')
except:
except Exception:
pass
if not self.cmd.config and default_config:
......@@ -552,7 +552,7 @@ class GitPatchwork(object):
# optional, not all commands need one and we allow not setting it.
try:
web_root = config.get(section, 'url')
except:
except Exception:
die("git-pw isn't configured.\n\n"
"Please set up the patchwork url and project, e.g.:\n\n"
" git config patchwork.%(config)s.url "
......@@ -564,7 +564,7 @@ class GitPatchwork(object):
project = None
try:
project = config.get(section, 'project')
except:
except Exception:
pass
if not project and self.cmd.need_project:
......@@ -583,7 +583,7 @@ class GitPatchwork(object):
username = config.get(section, 'user')
password = config.get(section, 'password')
user = User(username, password)
except:
except Exception:
pass
if not user and self.cmd.need_auth:
......
......@@ -849,14 +849,14 @@ _lockref = None
def lock():
global _lockref
l = _lockref and _lockref()
if l is not None and l.held:
l.lock()
return l
lk = _lockref and _lockref()
if lk is not None and lk.held:
lk.lock()
return lk
l = lockmod.lock("/tmp/patchwork.parsemail.lock", timeout=60)
_lockref = weakref.ref(l)
return l
lk = lockmod.lock("/tmp/patchwork.parsemail.lock", timeout=60)
_lockref = weakref.ref(lk)
return lk
def main(args):
......@@ -881,7 +881,7 @@ def main(args):
try:
parse_lock = lock()
return parse_mail(mail)
except:
except Exception:
if logger:
logger.exception('Error when parsing incoming email', extra={
'mail': mail.as_string(),
......
......@@ -268,7 +268,7 @@ def action_get(rpc, patch_id):
try:
f = open(fname, "w")
except:
except Exception:
sys.stderr.write("Unable to open %s for writing\n" % fname)
sys.exit(1)
......@@ -276,7 +276,7 @@ def action_get(rpc, patch_id):
f.write(unicode(s).encode("utf-8"))
f.close()
print('Saved patch to %s' % fname)
except:
except Exception:
sys.stderr.write("Failed to write to %s\n" % fname)
sys.exit(1)
......@@ -354,7 +354,7 @@ def patch_id_from_hash(rpc, project, hash):
# be super paranoid
try:
patch_id = int(patch_id)
except:
except Exception:
sys.stderr.write("Invalid patch ID obtained from server\n")
sys.exit(1)
return patch_id
......@@ -546,13 +546,13 @@ def main():
if args.get('n') is not None:
try:
filt.add("max_count", args.get('n'))
except:
except Exception:
action_parser.error("Invalid maximum count '%s'" % args.get('n'))
if args.get('N') is not None:
try:
filt.add("max_count", 0 - args.get('N'))
except:
except Exception:
action_parser.error("Invalid maximum count '%s'" % args.get('N'))
do_signoff = args.get('signoff')
......@@ -597,7 +597,7 @@ def main():
if not project_str:
try:
project_str = config.get('options', 'default')
except:
except Exception:
action_parser.error(
"No default project configured in ~/.pwclientrc")
......@@ -647,7 +647,7 @@ def main():
try:
rpc = xmlrpclib.Server(url, transport=transport)
except:
except Exception:
sys.stderr.write("Unable to connect to %s\n" % url)
sys.exit(1)
......
......@@ -102,7 +102,7 @@ class SubmitterFilter(Filter):
submitter_id = int(str)
except ValueError:
pass
except:
except Exception:
return
if submitter_id:
......@@ -167,7 +167,7 @@ class StateFilter(Filter):
try:
self.state = State.objects.get(id=int(str))
except:
except Exception:
return
self.applied = True
......@@ -349,7 +349,7 @@ class DelegateFilter(Filter):
try:
self.delegate = User.objects.get(id=str)
self.applied = True
except:
except Exception:
pass
def kwargs(self):
......
......@@ -229,9 +229,9 @@ class lock(object):
# if locker dead, break lock. must do this with another lock
# held, or can race and break valid lock.
try:
l = lock(self.f + '.break', timeout=0)
lk = lock(self.f + '.break', timeout=0)
os.unlink(self.f)
l.release()
lk.release()
except LockError:
return locker
......
......@@ -341,7 +341,7 @@ class Patch(models.Model):
try:
rev = SeriesRevisionPatch.objects.filter(patch=self)[0].revision
return rev.series
except:
except Exception:
return None
def _set_tag(self, tag, count):
......
......@@ -23,7 +23,7 @@ import time
try: # django 1.7+
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
except:
except ImportError:
from django.test import LiveServerTestCase as StaticLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
......
......@@ -65,11 +65,11 @@ class teststate(object):
self._pidoffset = pidoffset
def makelock(self, *args, **kwargs):
l = lockwrapper(self._pidoffset, testlockname,
releasefn=self.releasefn, acquirefn=self.acquirefn,
*args, **kwargs)
l.postrelease.append(self.postreleasefn)
return l
lw = lockwrapper(self._pidoffset, testlockname,
releasefn=self.releasefn, acquirefn=self.acquirefn,
*args, **kwargs)
lw.postrelease.append(self.postreleasefn)
return lw
def acquirefn(self):
self._acquirecalled = True
......
......@@ -22,7 +22,7 @@
try:
# django 1.8+
from django.core.exceptions import FieldDoesNotExist
except:
except ImportError:
from django.db.models.fields import FieldDoesNotExist
from django.core.exceptions import ValidationError
from django.conf import settings
......
......@@ -73,7 +73,7 @@ def setbundle(request):
try:
patch = Patch.objects.get(id=id)
bundle.append_patch(patch)
except:
except Exception:
pass
bundle.save()
......
......@@ -92,7 +92,7 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher,
try:
decoded = base64.decodestring(header)
username, password = decoded.split(':', 1)
except:
except Exception:
raise Exception('Invalid authentication credentials')
return authenticate(username=username, password=password)
......@@ -124,7 +124,7 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher,
response = self.dumps(response, methodresponse=1)
except six.moves.xmlrpc_client.Fault as fault:
response = self.dumps(fault)
except:
except Exception:
# report exception back to server
response = self.dumps(
six.moves.xmlrpc_client.Fault(1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment