diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-01-01 22:32:32 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-01-01 22:32:32 +0100 |
commit | 4ac4b115aed79fefc16989164bdab7d84e4b9193 (patch) | |
tree | 2fffb6e708463002eabe44f70c5df0db20ea3936 /fb | |
parent | 805aff30d8021e31dc6330b9ad91d8df6d3c3c9e (diff) | |
download | bin-4ac4b115aed79fefc16989164bdab7d84e4b9193.tar.gz bin-4ac4b115aed79fefc16989164bdab7d84e4b9193.tar.xz |
fb: add --extension option
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-x | fb | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -32,13 +32,17 @@ def password(): return None return auth[2] -def do_upload(file): +def do_upload(file, extension=None): pw = password() curl_args = [] if pw: curl_args.append('-F') - curl_args.append('password='+pw) - url = Popen(merge([['curl', '-#', '-L', '-F', 'userfile=@'+file, + curl_args.append('password=%s' % pw) + if extension: + curl_args.append('-F') + curl_args.append('extension=%s' % extension) + + url = Popen(merge([['curl', '-#', '-L', '-F', 'userfile=@%s' % file, ], curl_args, ['http://paste.xinu.at/file/do_upload']]), stdout=PIPE).communicate()[0] print url @@ -52,9 +56,10 @@ def delete(id): sys.exit(1) else: curl_args.append('-F') - curl_args.append('password='+pw) + curl_args.append('password=%s' % pw) + Popen(merge([['curl', '-#', '-L'], curl_args, - ['http://paste.xinu.at/file/delete/'+id]] + ['http://paste.xinu.at/file/delete/%s' % id]] ),).communicate()[0] def get(id): @@ -89,7 +94,7 @@ def main(): p.add_option('-d', '--delete', action='store_true', dest='delete', help='delete IDs', default=False) p.add_option('-e', '--extension', action='store', dest='extension', - help='extension for tempfiles when pipeing (e.g. "diff")', default='') + help='extension for default highlighting (e.g. "diff")', default=None) 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() @@ -112,13 +117,13 @@ def main(): tmpfiles.append(tmpdir) Popen(['wget', '-q', arg]).communicate()[0] for file in os.listdir(tmpdir): - do_upload(file) + do_upload(file, extension=options.extension) else: - do_upload(arg) + do_upload(arg, extension=options.extension) else: - tmpfile = read_stdin(tmpdir+"/stdin."+options.extension) + tmpfile = read_stdin(tmpdir+"/stdin") tmpfiles.append(tmpfile) - do_upload(tmpfile) + do_upload(tmpfile, extension=options.extension) os.chdir('/tmp') for path in tmpfiles: |