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