042f160
From 319b7c0d8f3956e5a2d0e4d4a4cd40c5b18e386c Mon Sep 17 00:00:00 2001
042f160
From: Clint Savage <herlo1@gmail.com>
042f160
Date: Fri, 12 Oct 2012 13:04:12 -0600
042f160
Subject: [PATCH] replace fpaste.org with sticky-notes version fpaste.stg.fp.o
042f160
042f160
---
042f160
 fpaste | 40 +++++++++++++++++++++++++---------------
042f160
 1 file changed, 25 insertions(+), 15 deletions(-)
042f160
042f160
diff --git a/fpaste b/fpaste
042f160
index 8899397..7073dcd 100755
042f160
--- a/fpaste
042f160
+++ b/fpaste
042f160
@@ -19,9 +19,10 @@
042f160
 VERSION = '0.3.7.1'
042f160
 USER_AGENT = 'fpaste/' + VERSION
042f160
 SET_DESCRIPTION_IF_EMPTY = 1  # stdin, clipboard, sysinfo
042f160
-FPASTE_URL = 'http://fpaste.org/'
042f160
+#FPASTE_URL = 'http://fpaste.org/'
7f124a5
+FPASTE_URL = 'http://paste.fedoraproject.org/'
042f160
 
042f160
-import os, sys, urllib, urllib2, subprocess
042f160
+import os, sys, urllib, urllib2, subprocess, json
042f160
 from optparse import OptionParser, OptionGroup, SUPPRESS_HELP
042f160
 
042f160
 def is_text(text, maxCheck = 100, pctPrintable = 0.75):
042f160
@@ -80,7 +81,7 @@ def paste(text, options):
042f160
     if len(author) > 30:
042f160
         author = author[0:30-3] + "..."
042f160
 
042f160
-    params = urllib.urlencode({'title': title, 'author': author, 'lexer': options.lang, 'content': text, 'expire_options': options.expires})
042f160
+    params = urllib.urlencode({'paste_lang': options.lang, 'paste_data': text, 'api_submit': 'true', 'mode': 'json'})
042f160
     pasteSizeKiB = len(params)/1024.0
042f160
 
042f160
     if pasteSizeKiB >= 512:   # 512KiB appears to be the current hard limit (20110404); old limit was 16MiB
042f160
@@ -110,18 +111,27 @@ def paste(text, options):
042f160
                 print f.read()
042f160
         return False
042f160
 
042f160
-    url = f.geturl()
042f160
-    if re.match(FPASTE_URL + '?.+', url):
042f160
-        return url
042f160
-    elif urllib2.urlparse.urlsplit(url).path == '/static/limit/':
042f160
-        # instead of returning a 500 server error, fpaste.org now returns "http://fedoraunity.org/static/limit/" if paste too large
042f160
-        print >> sys.stderr, "Error: paste size (%.1fKiB) exceeded server limit.  %s" % (pasteSizeKiB, url)
042f160
-        return False
042f160
-    else:
042f160
-        print >> sys.stderr, "Invalid URL '%s' returned. This should not happen. Use --debug to see server output" % url
042f160
-        if options.debug:
042f160
-            print f.read()
042f160
-        return False
042f160
+#    response = f.read()
042f160
+    response = json.loads(f.read())
042f160
+    id = [i[1]["id"] for i in response.iteritems()].pop()
042f160
+#        for k,j in i.iteritems():
042f160
+#            print j, k
042f160
+
042f160
+    url = "{0}{1}".format(FPASTE_URL, id)
042f160
+    return url
042f160
+
042f160
+#    url = f.geturl()
042f160
+#    if re.match(FPASTE_URL + '?.+', url):
042f160
+#        return url
042f160
+#    elif urllib2.urlparse.urlsplit(url).path == '/static/limit/':
042f160
+#        # instead of returning a 500 server error, fpaste.org now returns "http://fedoraunity.org/static/limit/" if paste too large
042f160
+#        print >> sys.stderr, "Error: paste size (%.1fKiB) exceeded server limit.  %s" % (pasteSizeKiB, url)
042f160
+#        return False
042f160
+#    else:
042f160
+#        print >> sys.stderr, "Invalid URL '%s' returned. This should not happen. Use --debug to see server output" % url
042f160
+#        if options.debug:
042f160
+#            print f.read()
042f160
+#        return False
042f160
 
042f160
 
042f160
 def sysinfo(show_stderr = False, show_successful_cmds = True, show_failed_cmds = True):
042f160
-- 
042f160
1.7.11.7
042f160