# HG changeset patch # User Mads Kiilerich # Date 1439079434 -7200 # Node ID d69aa464f373925e6148dd93d416bf5a34b6e5c7 # Parent e84c2738fbd84569492c56e5a9361ee94af5d420 cleanup: consistently use 'except ... as ...:' Use the Python 2.6+ syntax instead of the old confusing 'except ..., ...' syntax. diff -r e84c2738fbd8 -r d69aa464f373 kallithea/bin/base.py --- a/kallithea/bin/base.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/bin/base.py Sun Aug 09 02:17:14 2015 +0200 @@ -146,7 +146,7 @@ try: with open(self._conf_name, 'rb') as conf: config = json.load(conf) - except IOError, e: + except IOError as e: sys.stderr.write(str(e) + '\n') config.update(new_config) @@ -159,6 +159,6 @@ try: with open(self._conf_name, 'rb') as conf: return json.load(conf) - except IOError, e: + except IOError as e: #sys.stderr.write(str(e) + '\n') pass diff -r e84c2738fbd8 -r d69aa464f373 kallithea/bin/kallithea_gist.py --- a/kallithea/bin/kallithea_gist.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/bin/kallithea_gist.py Sun Aug 09 02:17:14 2015 +0200 @@ -164,7 +164,7 @@ try: return _run(argv) - except Exception, e: + except Exception as e: print e return 1 diff -r e84c2738fbd8 -r d69aa464f373 kallithea/bin/rebranddb.py --- a/kallithea/bin/rebranddb.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/bin/rebranddb.py Sun Aug 09 02:17:14 2015 +0200 @@ -57,7 +57,7 @@ t = metadata.tables[old_ui_name] print 'Renaming', t, 'to', new_ui_name migrate.changeset.rename_table(t, new_ui_name) - except KeyError, e: + except KeyError as e: print 'Not renaming ui:', e if new_settings_name == old_settings_name: @@ -67,7 +67,7 @@ t = metadata.tables[old_settings_name] print 'Renaming', t, 'to', new_settings_name migrate.changeset.rename_table(t, new_settings_name) - except KeyError, e: + except KeyError as e: print 'Not renaming settings:', e old_auth_name = 'internal' if old == 'kallithea' else old diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/auth_settings.py --- a/kallithea/controllers/admin/auth_settings.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/auth_settings.py Sun Aug 09 02:17:14 2015 +0200 @@ -134,7 +134,7 @@ Session().commit() h.flash(_('Auth settings updated successfully'), category='success') - except formencode.Invalid, errors: + except formencode.Invalid as errors: log.error(traceback.format_exc()) e = errors.error_dict or {} return self.__render( diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/defaults.py --- a/kallithea/controllers/admin/defaults.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/defaults.py Sun Aug 09 02:17:14 2015 +0200 @@ -97,7 +97,7 @@ h.flash(_('Default settings updated successfully'), category='success') - except formencode.Invalid, errors: + except formencode.Invalid as errors: defaults = errors.value return htmlfill.render( diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/gists.py --- a/kallithea/controllers/admin/gists.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/gists.py Sun Aug 09 02:17:14 2015 +0200 @@ -130,7 +130,7 @@ ) Session().commit() new_gist_id = gist.gist_access_id - except formencode.Invalid, errors: + except formencode.Invalid as errors: defaults = errors.value return formencode.htmlfill.render( @@ -141,7 +141,7 @@ encoding="UTF-8", force_defaults=False) - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('Error occurred during gist creation'), category='error') return redirect(url('new_gist')) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/my_account.py --- a/kallithea/controllers/admin/my_account.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/my_account.py Sun Aug 09 02:17:14 2015 +0200 @@ -132,7 +132,7 @@ Session().commit() update = True - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/my_account/my_account.html'), defaults=errors.value, @@ -219,7 +219,7 @@ UserModel().add_extra_email(self.authuser.user_id, email) Session().commit() h.flash(_("Added email %s to user") % email, category='success') - except formencode.Invalid, error: + except formencode.Invalid as error: msg = error.error_dict['email'] h.flash(msg, category='error') except Exception: diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/permissions.py --- a/kallithea/controllers/admin/permissions.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/permissions.py Sun Aug 09 02:17:14 2015 +0200 @@ -125,7 +125,7 @@ h.flash(_('Global permissions updated successfully'), category='success') - except formencode.Invalid, errors: + except formencode.Invalid as errors: defaults = errors.value return htmlfill.render( diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/repo_groups.py Sun Aug 09 02:17:14 2015 +0200 @@ -175,7 +175,7 @@ ) Session().commit() #TODO: in futureaction_logger(, '', '', '', self.sa) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/repo_groups/repo_group_add.html'), defaults=errors.value, @@ -252,7 +252,7 @@ # we now have new name ! group_name = new_gr.group_name #TODO: in future action_logger(, '', '', '', self.sa) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/repo_groups/repo_group_edit.html'), diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/repos.py --- a/kallithea/controllers/admin/repos.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/repos.py Sun Aug 09 02:17:14 2015 +0200 @@ -137,7 +137,7 @@ from celery.result import BaseAsyncResult if isinstance(task, BaseAsyncResult): task_id = task.task_id - except formencode.Invalid, errors: + except formencode.Invalid as errors: log.info(errors) return htmlfill.render( render('admin/repos/repo_add.html'), @@ -265,7 +265,7 @@ action_logger(self.authuser, 'admin_updated_repo', changed_name, self.ip_addr, self.sa) Session().commit() - except formencode.Invalid, errors: + except formencode.Invalid as errors: log.info(errors) defaults = self.__load_data(repo_name) defaults.update(errors.value) @@ -425,7 +425,7 @@ new_field.field_label = form_result['new_field_label'] Session().add(new_field) Session().commit() - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) msg = _('An error occurred during creation of field') if isinstance(e, formencode.Invalid): @@ -439,7 +439,7 @@ try: Session().delete(field) Session().commit() - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) msg = _('An error occurred during removal of field') h.flash(msg, category='error') @@ -513,10 +513,10 @@ Session().commit() h.flash(_('Marked repo %s as fork of %s') % (repo_name, fork), category='success') - except RepositoryError, e: + except RepositoryError as e: log.error(traceback.format_exc()) h.flash(str(e), category='error') - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('An error occurred during this operation'), category='error') @@ -538,7 +538,7 @@ elif request.POST.get('set_unlock'): Repository.unlock(repo) h.flash(_('Unlocked repository'), category='success') - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('An error occurred during unlocking'), category='error') @@ -565,7 +565,7 @@ h.flash(_('Repository has been %s') % action, category='success') - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('An error occurred during unlocking'), category='error') @@ -583,7 +583,7 @@ Session().commit() h.flash(_('Cache invalidation successful'), category='success') - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('An error occurred during cache invalidation'), category='error') @@ -601,7 +601,7 @@ try: ScmModel().pull_changes(repo_name, self.authuser.username) h.flash(_('Pulled from remote location'), category='success') - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('An error occurred during pull from remote location'), category='error') @@ -634,7 +634,7 @@ try: RepoModel().delete_stats(repo_name) Session().commit() - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) h.flash(_('An error occurred during deletion of repository stats'), category='error') diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/settings.py --- a/kallithea/controllers/admin/settings.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/settings.py Sun Aug 09 02:17:14 2015 +0200 @@ -94,7 +94,7 @@ application_form = ApplicationUiSettingsForm()() try: form_result = application_form.to_python(dict(request.POST)) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/settings/settings.html'), defaults=errors.value, @@ -235,7 +235,7 @@ application_form = ApplicationSettingsForm()() try: form_result = application_form.to_python(dict(request.POST)) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/settings/settings.html'), defaults=errors.value, @@ -295,7 +295,7 @@ application_form = ApplicationVisualisationForm()() try: form_result = application_form.to_python(dict(request.POST)) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/settings/settings.html'), defaults=errors.value, @@ -503,10 +503,10 @@ response = opener.open(_update_url) response_data = response.read() data = json.loads(response_data) - except urllib2.URLError, e: + except urllib2.URLError as e: log.error(traceback.format_exc()) return _err('Failed to contact upgrade server: %r' % e) - except ValueError, e: + except ValueError as e: log.error(traceback.format_exc()) return _err('Bad data sent from update server') diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/user_groups.py --- a/kallithea/controllers/admin/user_groups.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/user_groups.py Sun Aug 09 02:17:14 2015 +0200 @@ -150,7 +150,7 @@ h.flash(h.literal(_('Created user group %s') % h.link_to(h.escape(gr), url('edit_users_group', id=ug.users_group_id))), category='success') Session().commit() - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/user_groups/user_group_add.html'), defaults=errors.value, @@ -200,7 +200,7 @@ None, self.ip_addr, self.sa) h.flash(_('Updated user group %s') % gr, category='success') Session().commit() - except formencode.Invalid, errors: + except formencode.Invalid as errors: ug_model = UserGroupModel() defaults = errors.value e = errors.error_dict or {} @@ -240,7 +240,7 @@ UserGroupModel().delete(usr_gr) Session().commit() h.flash(_('Successfully deleted user group'), category='success') - except UserGroupsAssignedException, e: + except UserGroupsAssignedException as e: h.flash(e, category='error') except Exception: log.error(traceback.format_exc()) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/admin/users.py Sun Aug 09 02:17:14 2015 +0200 @@ -133,7 +133,7 @@ h.flash(h.literal(_('Created user %s') % h.link_to(h.escape(usr), url('edit_user', id=user.user_id))), category='success') Session().commit() - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('admin/users/user_add.html'), defaults=errors.value, @@ -141,7 +141,7 @@ prefix_error=False, encoding="UTF-8", force_defaults=False) - except UserCreationError, e: + except UserCreationError as e: h.flash(e, 'error') except Exception: log.error(traceback.format_exc()) @@ -183,7 +183,7 @@ None, self.ip_addr, self.sa) h.flash(_('User updated successfully'), category='success') Session().commit() - except formencode.Invalid, errors: + except formencode.Invalid as errors: defaults = errors.value e = errors.error_dict or {} defaults.update({ @@ -218,7 +218,7 @@ UserModel().delete(usr) Session().commit() h.flash(_('Successfully deleted user'), category='success') - except (UserOwnsReposException, DefaultUserException), e: + except (UserOwnsReposException, DefaultUserException) as e: h.flash(e, category='warning') except Exception: log.error(traceback.format_exc()) @@ -411,7 +411,7 @@ user_model.add_extra_email(id, email) Session().commit() h.flash(_("Added email %s to user") % email, category='success') - except formencode.Invalid, error: + except formencode.Invalid as error: msg = error.error_dict['email'] h.flash(msg, category='error') except Exception: @@ -459,7 +459,7 @@ user_model.add_extra_ip(id, ip) Session().commit() h.flash(_("Added IP address %s to user whitelist") % ip, category='success') - except formencode.Invalid, error: + except formencode.Invalid as error: msg = error.error_dict['ip'] h.flash(msg, category='error') except Exception: diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/api/__init__.py --- a/kallithea/controllers/api/__init__.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/api/__init__.py Sun Aug 09 02:17:14 2015 +0200 @@ -128,7 +128,7 @@ try: json_body = json.loads(raw_body) - except ValueError, e: + except ValueError as e: # catch JSON errors Here return jsonrpc_error(retid=self._req_id, message="JSON parse error ERR:%s RAW:%r" @@ -147,7 +147,7 @@ 'method: %s, params: %s' % (self._req_method, self._request_params) ) - except KeyError, e: + except KeyError as e: return jsonrpc_error(retid=self._req_id, message='Incorrect JSON query missing %s' % e) @@ -165,14 +165,14 @@ else: log.info('Access for IP:%s allowed' % (ip_addr,)) - except Exception, e: + except Exception as e: return jsonrpc_error(retid=self._req_id, message='Invalid API key') self._error = None try: self._func = self._find_method() - except AttributeError, e: + except AttributeError as e: return jsonrpc_error(retid=self._req_id, message=str(e)) @@ -258,9 +258,9 @@ raw_response = self._inspect_call(self._func) if isinstance(raw_response, HTTPError): self._error = str(raw_response) - except JSONRPCError, e: + except JSONRPCError as e: self._error = safe_str(e) - except Exception, e: + except Exception as e: log.error('Encountered unhandled exception: %s' % (traceback.format_exc(),)) json_exc = JSONRPCError('Internal server error') @@ -272,7 +272,7 @@ response = dict(id=self._req_id, result=raw_response, error=self._error) try: return json.dumps(response) - except TypeError, e: + except TypeError as e: log.error('API FAILED. Error encoding response: %s' % e) return json.dumps( dict( diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/api/api.py Sun Aug 09 02:17:14 2015 +0200 @@ -1066,7 +1066,7 @@ (user_group.users_group_id, user_group.users_group_name), user_group=None ) - except UserGroupsAssignedException, e: + except UserGroupsAssignedException as e: log.error(traceback.format_exc()) raise JSONRPCError(str(e)) except Exception: diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/changelog.py --- a/kallithea/controllers/changelog.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/changelog.py Sun Aug 09 02:17:14 2015 +0200 @@ -82,10 +82,10 @@ try: return c.db_repo_scm_instance.get_changeset(rev) - except EmptyRepositoryError, e: + except EmptyRepositoryError as e: h.flash(h.literal(_('There are no changesets yet')), category='error') - except RepositoryError, e: + except RepositoryError as e: log.error(traceback.format_exc()) h.flash(safe_str(e), category='error') raise HTTPBadRequest() @@ -139,7 +139,7 @@ try: cs = self.__get_cs(revision, repo_name) collection = cs.get_file_history(f_path) - except RepositoryError, e: + except RepositoryError as e: h.flash(safe_str(e), category='warning') redirect(h.url('changelog_home', repo_name=repo_name)) collection = list(reversed(collection)) @@ -154,10 +154,10 @@ page_revisions = [x.raw_id for x in c.pagination] c.comments = c.db_repo.get_comments(page_revisions) c.statuses = c.db_repo.statuses(page_revisions) - except (EmptyRepositoryError), e: + except EmptyRepositoryError as e: h.flash(safe_str(e), category='warning') return redirect(url('summary_home', repo_name=c.repo_name)) - except (RepositoryError, ChangesetDoesNotExistError, Exception), e: + except (RepositoryError, ChangesetDoesNotExistError, Exception) as e: log.error(traceback.format_exc()) h.flash(safe_str(e), category='error') return redirect(url('changelog_home', repo_name=c.repo_name)) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/changeset.py Sun Aug 09 02:17:14 2015 +0200 @@ -443,7 +443,7 @@ if request.is_xhr: try: return c.db_repo_scm_instance.get_changeset(revision) - except ChangesetDoesNotExistError, e: + except ChangesetDoesNotExistError as e: return EmptyChangeset(message=str(e)) else: raise HTTPBadRequest() diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/files.py --- a/kallithea/controllers/files.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/files.py Sun Aug 09 02:17:14 2015 +0200 @@ -83,7 +83,7 @@ try: return c.db_repo_scm_instance.get_changeset(rev) - except EmptyRepositoryError, e: + except EmptyRepositoryError as e: if silent_empty: return None url_ = url('files_add_home', @@ -97,7 +97,7 @@ msg = _('Such revision does not exist for this repository') h.flash(msg, category='error') raise HTTPNotFound() - except RepositoryError, e: + except RepositoryError as e: h.flash(safe_str(e), category='error') raise HTTPNotFound() @@ -117,7 +117,7 @@ msg = _('Such revision does not exist for this repository') h.flash(msg, category='error') raise HTTPNotFound() - except RepositoryError, e: + except RepositoryError as e: h.flash(safe_str(e), category='error') raise HTTPNotFound() @@ -182,7 +182,7 @@ c.authors.append((h.email(a), h.person(a))) else: c.authors = c.file_history = [] - except RepositoryError, e: + except RepositoryError as e: h.flash(safe_str(e), category='error') raise HTTPNotFound() @@ -490,12 +490,12 @@ h.flash(_('Successfully committed to %s') % node_path, category='success') - except NonRelativePathError, e: + except NonRelativePathError as e: h.flash(_('Location must be relative path and must not ' 'contain .. in path'), category='warning') return redirect(url('changeset_home', repo_name=c.repo_name, revision='tip')) - except (NodeError, NodeAlreadyExistsError), e: + except (NodeError, NodeAlreadyExistsError) as e: h.flash(_(e), category='error') except Exception: log.error(traceback.format_exc()) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/forks.py --- a/kallithea/controllers/forks.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/forks.py Sun Aug 09 02:17:14 2015 +0200 @@ -174,7 +174,7 @@ from celery.result import BaseAsyncResult if isinstance(task, BaseAsyncResult): task_id = task.task_id - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('forks/fork.html'), defaults=errors.value, diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/login.py --- a/kallithea/controllers/login.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/login.py Sun Aug 09 02:17:14 2015 +0200 @@ -98,7 +98,7 @@ # form checks for username/password, now we're authenticated username = c.form_result['username'] user = User.get_by_username(username, case_insensitive=True) - except formencode.Invalid, errors: + except formencode.Invalid as errors: defaults = errors.value # remove password from filling in form again del defaults['password'] @@ -109,7 +109,7 @@ prefix_error=False, encoding="UTF-8", force_defaults=False) - except UserCreationError, e: + except UserCreationError as e: # container auth or other auth functions that create users on # the fly can throw this exception signaling that there's issue # with user creation, explanation should be provided in @@ -158,7 +158,7 @@ Session().commit() return redirect(url('login_home')) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('/register.html'), defaults=errors.value, @@ -166,7 +166,7 @@ prefix_error=False, encoding="UTF-8", force_defaults=False) - except UserCreationError, e: + except UserCreationError as e: # container auth or other auth functions that create users on # the fly can throw this exception signaling that there's issue # with user creation, explanation should be provided in @@ -202,7 +202,7 @@ category='success') return redirect(url('login_home')) - except formencode.Invalid, errors: + except formencode.Invalid as errors: return htmlfill.render( render('/password_reset.html'), defaults=errors.value, @@ -222,7 +222,7 @@ h.flash(_('Your password reset was successful, ' 'new password has been sent to your email'), category='success') - except Exception, e: + except Exception as e: log.error(e) return redirect(url('reset_password')) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/controllers/pullrequests.py Sun Aug 09 02:17:14 2015 +0200 @@ -244,7 +244,7 @@ org_scm_instance = org_repo.scm_instance try: org_scm_instance.get_changeset() - except EmptyRepositoryError, e: + except EmptyRepositoryError as e: h.flash(h.literal(_('There are no changesets yet')), category='warning') redirect(url('summary_home', repo_name=org_repo.repo_name)) @@ -307,7 +307,7 @@ repo = RepoModel()._get_repo(repo_name) try: _form = PullRequestForm(repo.repo_id)().to_python(request.POST) - except formencode.Invalid, errors: + except formencode.Invalid as errors: log.error(traceback.format_exc()) log.error(str(errors)) msg = _('Error creating pull request: %s') % errors.msg @@ -365,7 +365,7 @@ Session().commit() h.flash(_('Successfully opened new pull request'), category='success') - except UserInvalidException, u: + except UserInvalidException as u: h.flash(_('Invalid reviewer "%s" specified') % u, category='error') raise HTTPBadRequest() except Exception: @@ -452,7 +452,7 @@ old_pull_request.other_repo.repo_name, new_other_ref, revisions, reviewers_ids, title, description ) - except UserInvalidException, u: + except UserInvalidException as u: h.flash(_('Invalid reviewer "%s" specified') % u, category='error') raise HTTPBadRequest() except Exception: @@ -507,7 +507,7 @@ try: PullRequestModel().mention_from_description(pull_request, old_description) PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) - except UserInvalidException, u: + except UserInvalidException as u: h.flash(_('Invalid reviewer "%s" specified') % u, category='error') raise HTTPBadRequest() diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/__init__.py --- a/kallithea/lib/__init__.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/__init__.py Sun Aug 09 02:17:14 2015 +0200 @@ -45,7 +45,7 @@ wk_dir = repo.workdir cur_rev = wk_dir.get_changeset() return (cur_rev.revision, cur_rev.short_id) - except Exception, err: + except Exception as err: if not quiet: print ("WARNING: Cannot retrieve kallithea's revision. " "disregard this if you don't know what that means. " diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/auth_modules/__init__.py --- a/kallithea/lib/auth_modules/__init__.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/auth_modules/__init__.py Sun Aug 09 02:17:14 2015 +0200 @@ -366,7 +366,7 @@ for module in auth_plugins: try: plugin = loadplugin(module) - except (ImportError, AttributeError, TypeError), e: + except (ImportError, AttributeError, TypeError) as e: raise ImportError('Failed to load authentication module %s : %s' % (module, str(e))) log.debug('Trying authentication using ** %s **' % (module,)) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/auth_modules/auth_crowd.py --- a/kallithea/lib/auth_modules/auth_crowd.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/auth_modules/auth_crowd.py Sun Aug 09 02:17:14 2015 +0200 @@ -106,7 +106,7 @@ rval["status"] = True else: rval = "".join(rdoc.readlines()) - except Exception, e: + except Exception as e: if not noformat: rval = {"status": False, "body": body, diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/celerylib/__init__.py --- a/kallithea/lib/celerylib/__init__.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/celerylib/__init__.py Sun Aug 09 02:17:14 2015 +0200 @@ -65,15 +65,15 @@ log.info('running task %s:%s' % (t.task_id, task)) return t - except socket.error, e: + except socket.error as e: if isinstance(e, IOError) and e.errno == 111: log.debug('Unable to connect to celeryd. Sync execution') CELERY_ON = False else: log.error(traceback.format_exc()) - except KeyError, e: + except KeyError as e: log.debug('Unable to connect to celeryd. Sync execution') - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) log.debug('executing task %s in sync mode' % task) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/celerylib/tasks.py --- a/kallithea/lib/celerylib/tasks.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/celerylib/tasks.py Sun Aug 09 02:17:14 2015 +0200 @@ -377,7 +377,7 @@ # set new created state repo.set_state(Repository.STATE_CREATED) DBS.commit() - except Exception, e: + except Exception as e: log.warning('Exception %s occurred when forking repository, ' 'doing cleanup...' % e) # rollback things manually ! @@ -462,7 +462,7 @@ # set new created state repo.set_state(Repository.STATE_CREATED) DBS.commit() - except Exception, e: + except Exception as e: log.warning('Exception %s occurred when forking repository, ' 'doing cleanup...' % e) #rollback things manually ! diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/dbmigrate/migrate/versioning/repository.py --- a/kallithea/lib/dbmigrate/migrate/versioning/repository.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/dbmigrate/migrate/versioning/repository.py Sun Aug 09 02:17:14 2015 +0200 @@ -95,7 +95,7 @@ cls.require_found(path) cls.require_found(os.path.join(path, cls._config)) cls.require_found(os.path.join(path, cls._versions)) - except exceptions.PathNotFoundError, e: + except exceptions.PathNotFoundError as e: raise exceptions.InvalidRepositoryError(path) @classmethod diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/dbmigrate/migrate/versioning/script/py.py --- a/kallithea/lib/dbmigrate/migrate/versioning/script/py.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/dbmigrate/migrate/versioning/script/py.py Sun Aug 09 02:17:14 2015 +0200 @@ -96,7 +96,7 @@ module = import_path(path) try: assert callable(module.upgrade) - except Exception, e: + except Exception as e: raise InvalidScriptError(path + ': %s' % str(e)) return module diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/dbmigrate/migrate/versioning/shell.py --- a/kallithea/lib/dbmigrate/migrate/versioning/shell.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/dbmigrate/migrate/versioning/shell.py Sun Aug 09 02:17:14 2015 +0200 @@ -207,7 +207,7 @@ ret = command_func(**kwargs) if ret is not None: log.info(ret) - except (exceptions.UsageError, exceptions.KnownError), e: + except (exceptions.UsageError, exceptions.KnownError) as e: parser.error(e.args[0]) if __name__ == "__main__": diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/dbmigrate/migrate/versioning/util/__init__.py --- a/kallithea/lib/dbmigrate/migrate/versioning/util/__init__.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/dbmigrate/migrate/versioning/util/__init__.py Sun Aug 09 02:17:14 2015 +0200 @@ -87,7 +87,7 @@ try: return f(*a, **kw) - except exceptions.PathFoundError, e: + except exceptions.PathFoundError as e: raise exceptions.KnownError("The path %s already exists" % e.args[0]) def construct_engine(engine, **opts): diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/dbmigrate/versions/005_version_1_3_0.py --- a/kallithea/lib/dbmigrate/versions/005_version_1_3_0.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/dbmigrate/versions/005_version_1_3_0.py Sun Aug 09 02:17:14 2015 +0200 @@ -33,7 +33,7 @@ if old_cons: try: old_cons.drop() - except Exception, e: + except Exception as e: # we don't care if this fails really... better to pass migration than # leave this in intermidiate state print 'Failed to remove Unique for user_id, repository_id reason %s' % e @@ -61,7 +61,7 @@ if old_cons: try: old_cons.drop() - except Exception, e: + except Exception as e: # we don't care if this fails really... better to pass migration than # leave this in intermidiate state print 'Failed to remove Unique for user_id, repository_id reason %s' % e diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/dbmigrate/versions/022_version_2_0_2.py --- a/kallithea/lib/dbmigrate/versions/022_version_2_0_2.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/dbmigrate/versions/022_version_2_0_2.py Sun Aug 09 02:17:14 2015 +0200 @@ -50,7 +50,7 @@ _rev_type = 'branch' elif _rev in known_bookmarks: _rev_type = 'book' - except Exception, e: + except Exception as e: print e print 'continue...' #we don't want any error to break the process diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/middleware/pygrack.py --- a/kallithea/lib/middleware/pygrack.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/middleware/pygrack.py Sun Aug 09 02:17:14 2015 +0200 @@ -89,7 +89,7 @@ out = subprocessio.SubprocessIOChunker(cmd, starting_values=[packet_len + server_advert + '0000'] ) - except EnvironmentError, e: + except EnvironmentError as e: log.error(traceback.format_exc()) raise exc.HTTPExpectationFailed() resp = Response() @@ -129,7 +129,7 @@ env=gitenv, cwd=self.content_path, ) - except EnvironmentError, e: + except EnvironmentError as e: log.error(traceback.format_exc()) raise exc.HTTPExpectationFailed() @@ -157,10 +157,10 @@ app = self.backend try: resp = app(request, environ) - except exc.HTTPException, e: + except exc.HTTPException as e: resp = e log.error(traceback.format_exc()) - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) resp = exc.HTTPInternalServerError() return resp(environ, start_response) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/middleware/simplegit.py --- a/kallithea/lib/middleware/simplegit.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/middleware/simplegit.py Sun Aug 09 02:17:14 2015 +0200 @@ -204,7 +204,7 @@ (action, str_repo_name, safe_str(username), ip_addr)) app = self.__make_app(repo_name, repo_path, extras) return app(environ, start_response) - except HTTPLockedRC, e: + except HTTPLockedRC as e: _code = CONFIG.get('lock_ret_code') log.debug('Repository LOCKED ret code %s!' % (_code)) return e(environ, start_response) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/middleware/simplehg.py --- a/kallithea/lib/middleware/simplehg.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/middleware/simplehg.py Sun Aug 09 02:17:14 2015 +0200 @@ -206,10 +206,10 @@ (action, str_repo_name, safe_str(username), ip_addr)) app = self.__make_app(repo_path, baseui, extras) return app(environ, start_response) - except RepoError, e: + except RepoError as e: if str(e).find('not found') != -1: return HTTPNotFound()(environ, start_response) - except HTTPLockedRC, e: + except HTTPLockedRC as e: _code = CONFIG.get('lock_ret_code') log.debug('Repository LOCKED ret code %s!' % (_code)) return e(environ, start_response) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/pidlock.py --- a/kallithea/lib/pidlock.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/pidlock.py Sun Aug 09 02:17:14 2015 +0200 @@ -88,7 +88,7 @@ if running_pid: try: kill(running_pid, 0) - except OSError, exc: + except OSError as exc: if exc.errno in (errno.ESRCH, errno.EPERM): print ("Lock File is there but" " the program is not running") @@ -101,7 +101,7 @@ print "It is running as process %s" % running_pid raise LockHeld() - except IOError, e: + except IOError as e: if e.errno != 2: raise @@ -121,7 +121,7 @@ print 'removing pidfile %s' % self.pidfile os.remove(self.pidfile) self.held = False - except OSError, e: + except OSError as e: if self.debug: print 'removing pidfile failed %s' % e pass diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/rcmail/response.py --- a/kallithea/lib/rcmail/response.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/rcmail/response.py Sun Aug 09 02:17:14 2015 +0200 @@ -338,7 +338,7 @@ try: out = MIMEPart(ctype, **params) - except TypeError, exc: # pragma: no cover + except TypeError as exc: # pragma: no cover raise EncodingError("Content-Type malformed, not allowed: %r; " "%r (Python ERROR: %s" % (ctype, params, exc.message)) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/utils2.py Sun Aug 09 02:17:14 2015 +0200 @@ -630,7 +630,7 @@ for k in ['username', 'repository', 'locked_by', 'scm', 'make_lock', 'action', 'ip']: extras[k] - except KeyError, e: + except KeyError as e: raise Exception('Missing key %s in os.environ %s' % (e, extras)) return AttributeDict(extras) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/vcs/backends/base.py --- a/kallithea/lib/vcs/backends/base.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/vcs/backends/base.py Sun Aug 09 02:17:14 2015 +0200 @@ -127,7 +127,7 @@ for f in files: size += tip.get_file_size(f.path) - except RepositoryError, e: + except RepositoryError as e: pass return size diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/vcs/backends/git/repository.py --- a/kallithea/lib/vcs/backends/git/repository.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/vcs/backends/git/repository.py Sun Aug 09 02:17:14 2015 +0200 @@ -141,7 +141,7 @@ ) _opts.update(opts) p = subprocessio.SubprocessIOChunker(cmd, **_opts) - except (EnvironmentError, OSError), err: + except (EnvironmentError, OSError) as err: tb_err = ("Couldn't run git command (%s).\n" "Original error was:%s\n" % (cmd, err)) log.error(tb_err) @@ -209,7 +209,7 @@ resp = o.open(req) if resp.code != 200: raise Exception('Return Code is not 200') - except Exception, e: + except Exception as e: # means it cannot be cloned raise urllib2.URLError("[%s] org_exc: %s" % (cleaned_uri, e)) @@ -241,7 +241,7 @@ return Repo.init(self.path) else: return self._repo - except (NotGitRepository, OSError), err: + except (NotGitRepository, OSError) as err: raise RepositoryError(err) def _get_all_revisions(self): @@ -446,7 +446,7 @@ os.remove(tagpath) self._parsed_refs = self._get_parsed_refs() self.tags = self._get_tags() - except OSError, e: + except OSError as e: raise RepositoryError(e.strerror) @LazyProperty @@ -675,7 +675,7 @@ from dulwich.server import update_server_info try: update_server_info(self._repo) - except OSError, e: + except OSError as e: if e.errno != errno.ENOENT: raise # Workaround for dulwich crashing on for example its own dulwich/tests/data/repos/simple_merge.git/info/refs.lock diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/vcs/backends/hg/repository.py Sun Aug 09 02:17:14 2015 +0200 @@ -177,7 +177,7 @@ try: self._repo.tag(name, changeset._ctx.node(), message, local, user, date) - except Abort, e: + except Abort as e: raise RepositoryError(e.message) # Reinitialize tags @@ -208,7 +208,7 @@ try: self._repo.tag(name, nullid, message, local, user, date) self.tags = self._get_tags() - except Abort, e: + except Abort as e: raise RepositoryError(e.message) @LazyProperty @@ -321,7 +321,7 @@ resp = o.open(req) if resp.code != 200: raise Exception('Return Code is not 200') - except Exception, e: + except Exception as e: # means it cannot be cloned raise urllib2.URLError("[%s] org_exc: %s" % (cleaned_uri, e)) @@ -329,7 +329,7 @@ # now check if it's a proper hg repo try: httppeer(repoui or ui.ui(), url).lookup('tip') - except Exception, e: + except Exception as e: raise urllib2.URLError( "url [%s] does not look like an hg repo org_exc: %s" % (cleaned_uri, e)) @@ -359,7 +359,7 @@ # Don't try to create if we've already cloned repo create = False return localrepository(self.baseui, self.path, create=create) - except (Abort, RepoError), err: + except (Abort, RepoError) as err: if create: msg = "Cannot create repository at %s. Original error was %s"\ % (self.path, err) @@ -565,7 +565,7 @@ exchange.pull(self._repo, other, heads=None, force=None) except ImportError: self._repo.pull(other, heads=None, force=None) - except Abort, err: + except Abort as err: # Propagate error but with vcs's type raise RepositoryError(str(err)) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/vcs/utils/imports.py --- a/kallithea/lib/vcs/utils/imports.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/vcs/utils/imports.py Sun Aug 09 02:17:14 2015 +0200 @@ -18,7 +18,7 @@ class_name = splitted[-1] try: class_mod = __import__(mod_path, {}, {}, [class_name]) - except ImportError, err: + except ImportError as err: msg = "There was problem while trying to import backend class. "\ "Original error was:\n%s" % err raise VCSError(msg) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/lib/vcs/utils/lockfiles.py --- a/kallithea/lib/vcs/utils/lockfiles.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/lib/vcs/utils/lockfiles.py Sun Aug 09 02:17:14 2015 +0200 @@ -42,7 +42,7 @@ try: fd = os.open(lock_file, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0) os.close(fd) - except OSError,e: + except OSError as e: raise IOError(str(e)) self._owns_lock = True diff -r e84c2738fbd8 -r d69aa464f373 kallithea/model/notification.py --- a/kallithea/model/notification.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/model/notification.py Sun Aug 09 02:17:14 2015 +0200 @@ -315,7 +315,7 @@ tmpl = self._subj_map[type_] try: subj = tmpl % kwargs - except KeyError, e: + except KeyError as e: log.error('error generating email subject for %r from %s: %s', type_, ','.join(self._subj_map.keys()), e) raise l = [safe_unicode(x) for x in [kwargs.get('status_change'), kwargs.get('closing_pr') and _('Closing')] if x] diff -r e84c2738fbd8 -r d69aa464f373 kallithea/model/scm.py --- a/kallithea/model/scm.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/model/scm.py Sun Aug 09 02:17:14 2015 +0200 @@ -557,7 +557,7 @@ try: tip = imc.commit(message=message, author=author, parents=[cs], branch=cs.branch) - except Exception, e: + except Exception as e: log.error(traceback.format_exc()) raise IMCCommitError(str(e)) finally: @@ -880,7 +880,7 @@ tmpl = tmpl.replace('_TMPL_', kallithea.__version__) f.write(tmpl) os.chmod(_hook_file, 0755) - except IOError, e: + except IOError as e: log.error('error writing %s: %s' % (_hook_file, e)) else: log.debug('skipping writing hook file') diff -r e84c2738fbd8 -r d69aa464f373 kallithea/model/validators.py --- a/kallithea/model/validators.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/model/validators.py Sun Aug 09 02:17:14 2015 +0200 @@ -857,7 +857,7 @@ next_to_load=plugin_name) raise formencode.Invalid(msg, value, state) unique_names[plugin_name] = plugin - except (ImportError, AttributeError, TypeError), e: + except (ImportError, AttributeError, TypeError) as e: raise formencode.Invalid(str(e), value, state) return _validator diff -r e84c2738fbd8 -r d69aa464f373 kallithea/tests/parameterized.py --- a/kallithea/tests/parameterized.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/tests/parameterized.py Sun Aug 09 02:17:14 2015 +0200 @@ -161,7 +161,7 @@ def assert_raises(func, exc_type, str_contains=None, repr_contains=None): try: func() - except exc_type, e: + except exc_type as e: if str_contains is not None and str_contains not in str(e): raise AssertionError("%s raised, but %r does not contain %r" % (exc_type, str(e), str_contains)) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/tests/scripts/manual_test_concurrency.py --- a/kallithea/tests/scripts/manual_test_concurrency.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/tests/scripts/manual_test_concurrency.py Sun Aug 09 02:17:14 2015 +0200 @@ -218,5 +218,5 @@ test_clone_with_credentials(repo=sys.argv[1], method=METHOD, seq=seq, backend=backend) print 'time taken %.3f' % (time.time() - s) - except Exception, e: + except Exception as e: sys.exit('stop on %s' % e) diff -r e84c2738fbd8 -r d69aa464f373 kallithea/tests/scripts/manual_test_crawler.py --- a/kallithea/tests/scripts/manual_test_crawler.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/tests/scripts/manual_test_crawler.py Sun Aug 09 02:17:14 2015 +0200 @@ -157,7 +157,7 @@ for f in files: paths_.add(f.path) - except RepositoryError, e: + except RepositoryError as e: pass cnt = 0 diff -r e84c2738fbd8 -r d69aa464f373 kallithea/tests/vcs/__init__.py --- a/kallithea/tests/vcs/__init__.py Thu Aug 06 11:42:57 2015 +0200 +++ b/kallithea/tests/vcs/__init__.py Sun Aug 09 02:17:14 2015 +0200 @@ -49,7 +49,7 @@ for scm, fetcher_info in fetchers.items(): fetcher = SCMFetcher(**fetcher_info) fetcher.setup() - except VCSTestError, err: + except VCSTestError as err: raise RuntimeError(str(err)) diff -r e84c2738fbd8 -r d69aa464f373 setup.py --- a/setup.py Thu Aug 06 11:42:57 2015 +0200 +++ b/setup.py Sun Aug 09 02:17:14 2015 +0200 @@ -110,7 +110,7 @@ long_description = open(README_FILE).read() + '\n\n' + \ open(CHANGELOG_FILE).read() -except IOError, err: +except IOError as err: sys.stderr.write( "[WARNING] Cannot find file specified as long_description (%s)\n or " "changelog (%s) skipping that file" % (README_FILE, CHANGELOG_FILE)