summaryrefslogtreecommitdiffstats
path: root/fb
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-01-01 22:30:25 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-01-01 22:30:25 +0100
commit805aff30d8021e31dc6330b9ad91d8df6d3c3c9e (patch)
treeb71a08368edcbfdc6515cedd4255c936781328ff /fb
parentf6a914aba369ebd3960ab16b009b0b3fa52c346b (diff)
downloadbin-805aff30d8021e31dc6330b9ad91d8df6d3c3c9e.tar.gz
bin-805aff30d8021e31dc6330b9ad91d8df6d3c3c9e.tar.xz
fb: add --get option and support https/ftp repasting
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-xfb13
1 files changed, 12 insertions, 1 deletions
diff --git a/fb b/fb
index d4f1b24..22a5d78 100755
--- a/fb
+++ b/fb
@@ -16,9 +16,11 @@ or nopaste stdin
from optparse import OptionParser
from subprocess import Popen, PIPE
+from urllib2 import urlopen
import os
import sys
import netrc
+import re
def password():
''' netrc: machine paste.xinu.at password PASSWORD'''
@@ -55,6 +57,9 @@ def delete(id):
['http://paste.xinu.at/file/delete/'+id]]
),).communicate()[0]
+def get(id):
+ print urlopen('http://paste.xinu.at/d/%s' % id).read()
+
def merge(seq):
merged = []
for s in seq:
@@ -85,6 +90,8 @@ def main():
help='delete IDs', default=False)
p.add_option('-e', '--extension', action='store', dest='extension',
help='extension for tempfiles when pipeing (e.g. "diff")', default='')
+ p.add_option('-g', '--get', action='store_true', dest='get',
+ help='Download File IDs and output to stdout (use with care!)', default=False)
options, args = p.parse_args()
tmpfiles = []
@@ -96,7 +103,11 @@ def main():
delete(arg)
continue
- if arg.find('http://') != -1:
+ if options.get:
+ get(arg)
+ continue
+
+ if re.match('[a-z]+://.+', arg):
os.chdir(tmpdir)
tmpfiles.append(tmpdir)
Popen(['wget', '-q', arg]).communicate()[0]