[fpaste] Another patch to gracefully handle server errors.

Ankur Sinha ankursinha at fedoraproject.org
Thu Jan 23 08:50:07 UTC 2014


commit 6e6017bb15f40c0fb637441b8b0923dbaf606cfb
Author: Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur at gmail.com>
Date:   Thu Jan 23 19:50:19 2014 +1100

    Another patch to gracefully handle server errors.

 0012-fpaste-0.3.7.1-handle-server-errors.patch |   26 ++++++++++++++++++++++++
 fpaste.spec                                    |    9 +++++++-
 2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/0012-fpaste-0.3.7.1-handle-server-errors.patch b/0012-fpaste-0.3.7.1-handle-server-errors.patch
new file mode 100644
index 0000000..4685808
--- /dev/null
+++ b/0012-fpaste-0.3.7.1-handle-server-errors.patch
@@ -0,0 +1,26 @@
+--- fpaste.orig	2014-01-23 19:31:38.279079278 +1100
++++ fpaste	2014-01-23 19:46:01.387908129 +1100
+@@ -134,6 +134,23 @@
+ 
+ #    response = f.read()
+     response = json.loads(f.read())
++
++    if 'error' in response['result']:
++        error = response['result']['error']
++        if error == 'err_spamguard_php':
++            print >> sys.stderr, "Error: Poster's IP address is listed as malicious"
++        elif error == 'err_spamguard_noflood':
++            print >> sys.stderr, "Error: Poster is trying to flood"
++        elif error == 'err_spamguard_stealth':
++            print >> sys.stderr, "Error: The paste triggered the spam filter"
++        elif error == 'err_spamguard_ipban':
++            print >> sys.stderr, "Error: Poster's IP address is banned"
++        elif error == 'err_author_numeric':
++            print >> sys.stderr, "Error: Poster's alias should be alphanumeric"
++        else: 
++            print >> sys.stderr, "Error: %s" % error
++        sys.exit(-1)
++
+     id = [i[1]["id"] for i in response.iteritems()].pop()
+ #        for k,j in i.iteritems():
+ #            print j, k
diff --git a/fpaste.spec b/fpaste.spec
index b09a815..fcc805a 100644
--- a/fpaste.spec
+++ b/fpaste.spec
@@ -1,6 +1,6 @@
 Name:		fpaste
 Version:	0.3.7.1
-Release:	10%{?dist}
+Release:	11%{?dist}
 Summary:	A simple tool for pasting info onto sticky notes instances
 BuildArch:	noarch
 Group:		Applications/Internet
@@ -47,6 +47,9 @@ Patch9:     0010-%{name}-0.3.7.1-correct-paste-error-return.patch
 # Reactivate the nick and password options
 Patch10:    0011-%{name}-0.3.7.1-reactivate-nick-password-options.patch
 
+# Handle server errors properly
+Patch11:    0012-%{name}-0.3.7.1-handle-server-errors.patch
+
 %description
 It is often useful to be able to easily paste text to the Fedora
 Pastebin at http://paste.fedoraproject.org and this simple script 
@@ -70,6 +73,7 @@ reason they may be unable to paste something into the pastebin
 %patch8
 %patch9
 %patch10
+%patch11
 
 %build
 #nothing required
@@ -89,6 +93,9 @@ rm -rf %{buildroot}
 %{_mandir}/man1/fpaste.1.gz
 
 %changelog
+* Thu Jan 23 2014 Ankur Sinha <ankursinha AT fedoraproject DOT org> 0.3.7.1-11
+- Another patch to handle server errors
+
 * Thu Jan 23 2014 Ankur Sinha <ankursinha AT fedoraproject DOT org> 0.3.7.1-10
 - new patches
 - correct syntax options


More information about the scm-commits mailing list