summaryrefslogtreecommitdiffstats
path: root/fb
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-04-18 21:59:28 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-04-18 21:59:28 +0200
commit40e84c5d06b3a23b42c6bd9733362674510615cb (patch)
tree791d7fa04550a27a16a00653c858a3e37e7742c6 /fb
parente53a573b9b927cb1a93defb4a2bf28f56642d26a (diff)
downloadbin-40e84c5d06b3a23b42c6bd9733362674510615cb.tar.gz
bin-40e84c5d06b3a23b42c6bd9733362674510615cb.tar.xz
fb: use curl's netrc option
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-xfb37
1 files changed, 5 insertions, 32 deletions
diff --git a/fb b/fb
index 92b72b5..bced69f 100755
--- a/fb
+++ b/fb
@@ -12,9 +12,10 @@
#----------------------------------------------------
'''[cat |] %prog [options] [file1 file2 ...]'''
-__version__ = '0.5.2'
+__version__ = '0.5.3'
__desc__ = '''
Upload/nopaste file/stdin to paste.xinu.at and copy URL to clipboard.
+~/.netrc: machine paste.xinu.at password PASSWORD
'''
from optparse import OptionParser
@@ -25,46 +26,18 @@ import sys
import netrc
import re
-def password():
- ''' netrc: machine paste.xinu.at password PASSWORD'''
- try:
- auth = netrc.netrc().authenticators('paste.xinu.at')
- except:
- return None
- if not auth:
- return None
- return auth[2]
-
def do_upload(file, extension=None):
- pw = password()
curl_args = []
- if pw:
- curl_args.append('-F')
- curl_args.append('password=%s' % pw)
if extension:
curl_args.append('-F')
curl_args.append('extension=%s' % extension)
- url = Popen(merge([['curl', '-#', '-L', '-F', 'file=@%s' % file,
+ url = Popen(merge([['curl', '-#', '-n', '-L', '-F', 'file=@%s' % file,
], curl_args, ['http://paste.xinu.at/file/do_upload']]),
stdout=PIPE).communicate()[0]
print url
Popen('echo -n "%s" | nohup >/dev/null xclip 2>&1' % url, shell=True)
-def delete(id):
- pw = password()
- curl_args = []
- if not pw:
- print 'Please set up ~/.netrc correctly'
- sys.exit(1)
- else:
- curl_args.append('-F')
- curl_args.append('password=%s' % pw)
-
- Popen(merge([['curl', '-#', '-L'], curl_args,
- ['http://paste.xinu.at/file/delete/%s' % id]]
- ),).communicate()[0]
-
def get(id):
print urlopen('http://paste.xinu.at/%s' % id).read()
@@ -93,7 +66,7 @@ def read_stdin(tmpfile):
def main():
p = OptionParser(version=__version__,
usage=__doc__,
- description=__desc__+password.__doc__)
+ description=__desc__)
p.add_option('-d', '--delete', action='store_true', dest='delete',
help='delete IDs', default=False)
p.add_option('-e', '--extension', action='store', dest='extension',
@@ -108,7 +81,7 @@ def main():
if args:
for arg in args:
if options.delete:
- delete(arg)
+ Popen(['curl', '-#', '-n', '-L', 'http://paste.xinu.at/file/delete/%s' % arg]).communicate()[0]
continue
if options.get: