pastebinit: update to 1.5.1
This commit is contained in:
parent
534c905a94
commit
cc9680c1a4
@ -1,10 +1,9 @@
|
|||||||
TERMUX_PKG_HOMEPAGE=https://launchpad.net/pastebinit
|
TERMUX_PKG_HOMEPAGE=https://launchpad.net/pastebinit
|
||||||
TERMUX_PKG_DESCRIPTION="Command-line pastebin client"
|
TERMUX_PKG_DESCRIPTION="Command-line pastebin client"
|
||||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||||
TERMUX_PKG_VERSION=1.5
|
TERMUX_PKG_VERSION=1.5.1
|
||||||
TERMUX_PKG_REVISION=1
|
TERMUX_PKG_SRCURL=https://github.com/felixonmars/pastebinit/archive/$TERMUX_PKG_VERSION.tar.gz
|
||||||
TERMUX_PKG_SRCURL=https://launchpad.net/pastebinit/trunk/${TERMUX_PKG_VERSION}/+download/pastebinit-${TERMUX_PKG_VERSION}.tar.bz2
|
TERMUX_PKG_SHA256=30850b9dc6b3e9105321cee159d491891b3d3c03180440edffa296c7e1ac0c41
|
||||||
TERMUX_PKG_SHA256=42e5a84ce7e46825fb3b6478e11893fad357197327257e474bd0d3549f438457
|
|
||||||
TERMUX_PKG_DEPENDS="python"
|
TERMUX_PKG_DEPENDS="python"
|
||||||
TERMUX_PKG_BUILD_IN_SRC=true
|
TERMUX_PKG_BUILD_IN_SRC=true
|
||||||
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
||||||
|
@ -1,102 +0,0 @@
|
|||||||
Changes:
|
|
||||||
|
|
||||||
= Do not set default pastbin url based on distribution used.
|
|
||||||
|
|
||||||
= Fix warning about deprecated methords in 'pasteURLopener' - applied patch from Debian.
|
|
||||||
|
|
||||||
= Fix paths to configuration directories.
|
|
||||||
|
|
||||||
diff -uNr pastebinit-1.5/pastebinit pastebinit-1.5.mod/pastebinit
|
|
||||||
--- pastebinit-1.5/pastebinit 2016-03-01 07:52:32.000000000 +0200
|
|
||||||
+++ pastebinit-1.5.mod/pastebinit 2019-07-27 14:05:27.571525242 +0300
|
|
||||||
@@ -27,28 +27,15 @@
|
|
||||||
from ConfigParser import NoOptionError
|
|
||||||
from ConfigParser import SafeConfigParser as ConfigParser
|
|
||||||
from urllib import urlencode
|
|
||||||
- from urllib import FancyURLopener
|
|
||||||
+ from urllib import request
|
|
||||||
else:
|
|
||||||
from configparser import ConfigParser, NoOptionError
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
- from urllib.request import FancyURLopener
|
|
||||||
+ from urllib import request
|
|
||||||
|
|
||||||
# Set the default pastebin
|
|
||||||
defaultPB = "pastebin.com"
|
|
||||||
|
|
||||||
-# Now try to override it with a distributor pastebin
|
|
||||||
-try:
|
|
||||||
- import platform
|
|
||||||
- release = platform.linux_distribution()[0].lower()
|
|
||||||
- if release == 'debian':
|
|
||||||
- defaultPB = "paste.debian.net"
|
|
||||||
- elif release == 'fedora':
|
|
||||||
- defaultPB = "fpaste.org"
|
|
||||||
- elif release == 'ubuntu':
|
|
||||||
- defaultPB = "paste.ubuntu.com"
|
|
||||||
-except ImportError:
|
|
||||||
- pass
|
|
||||||
-
|
|
||||||
try:
|
|
||||||
import getopt
|
|
||||||
import gettext
|
|
||||||
@@ -72,12 +59,13 @@
|
|
||||||
version = "1.5"
|
|
||||||
configfile = os.path.expanduser("~/.pastebinit.xml")
|
|
||||||
|
|
||||||
- # Custom urlopener to handle 401's
|
|
||||||
- class pasteURLopener(FancyURLopener):
|
|
||||||
+ class PasteRequest(request.Request):
|
|
||||||
version = "Pastebinit v%s" % version
|
|
||||||
|
|
||||||
- def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
|
|
||||||
- return None
|
|
||||||
+ def __init__(self, *args, **opts):
|
|
||||||
+ super(PasteRequest, self).__init__(*args, **opts)
|
|
||||||
+ if 'User-agent' not in self.headers:
|
|
||||||
+ self.add_header('User-agent', self.version)
|
|
||||||
|
|
||||||
def preloadPastebins():
|
|
||||||
# Check several places for config files:
|
|
||||||
@@ -86,8 +74,8 @@
|
|
||||||
# - user's overrides in ~/.pastebin.d
|
|
||||||
# Files found later override files found earlier.
|
|
||||||
pastebind = {}
|
|
||||||
- for confdir in ['/usr/share/pastebin.d', '/etc/pastebin.d',
|
|
||||||
- '/usr/local/etc/pastebin.d',
|
|
||||||
+ for confdir in ['@TERMUX_PREFIX@/share/pastebin.d', '@TERMUX_PREFIX@/etc/pastebin.d',
|
|
||||||
+ '@TERMUX_PREFIX@/local/etc/pastebin.d',
|
|
||||||
os.path.expanduser('~/.pastebin.d'),
|
|
||||||
os.path.join(
|
|
||||||
os.path.dirname(
|
|
||||||
@@ -410,25 +398,25 @@
|
|
||||||
else:
|
|
||||||
post_format = 'standard'
|
|
||||||
|
|
||||||
- url_opener = pasteURLopener()
|
|
||||||
+ req = PasteRequest(fetch_url)
|
|
||||||
|
|
||||||
if post_format == 'json':
|
|
||||||
if json:
|
|
||||||
- params = json.dumps(params)
|
|
||||||
- url_opener.addheader('Content-type', 'text/json')
|
|
||||||
+ params = bytes(json.dumps(params), encoding='US-ASCII')
|
|
||||||
+ req.add_header('Content-type', 'text/json')
|
|
||||||
else:
|
|
||||||
print(_("Could not find any json library."), file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
# Convert to a format usable with the HTML POST
|
|
||||||
- params = urlencode(params)
|
|
||||||
+ params = bytes(urlencode(params), encoding='US-ASCII')
|
|
||||||
|
|
||||||
# Send the informations and be redirected to the final page
|
|
||||||
if verbose:
|
|
||||||
print("POSTing to: %s\nParams: %s" % (
|
|
||||||
fetch_url, str(params)), file=sys.stderr)
|
|
||||||
try:
|
|
||||||
- page = url_opener.open(fetch_url, params)
|
|
||||||
+ page = request.urlopen(req, params)
|
|
||||||
except Exception as e:
|
|
||||||
print(_("Failed to contact the server: %s") % e, file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
Loading…
Reference in New Issue
Block a user