From d383ae96a0300f43f5a22040e2f2420677307eef Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 9 Jun 2015 14:46:09 +0000 Subject: essential-files: Install brpaste by default This script helps developers to share logs via paste.baserock.org Change-Id: I22b255c90e0b42a4b65dea41ec196ae92577a7f8 --- install-files/essential-files/manifest | 2 ++ install-files/essential-files/usr/bin/brpaste | 29 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 install-files/essential-files/usr/bin/brpaste (limited to 'install-files') diff --git a/install-files/essential-files/manifest b/install-files/essential-files/manifest index 2b77c237..4ef270d2 100644 --- a/install-files/essential-files/manifest +++ b/install-files/essential-files/manifest @@ -3,6 +3,8 @@ overwrite 0100644 0 0 /etc/os-release overwrite 0100644 0 0 /etc/profile overwrite 0100644 0 0 /etc/inputrc 0040755 0 0 /usr +0040755 0 0 /usr/bin +0100755 0 0 /usr/bin/brpaste 0040755 0 0 /usr/lib 0040755 0 0 /usr/lib/tmpfiles.d 0100644 0 0 /usr/lib/tmpfiles.d/shutdownramfs.conf diff --git a/install-files/essential-files/usr/bin/brpaste b/install-files/essential-files/usr/bin/brpaste new file mode 100644 index 00000000..15f976b9 --- /dev/null +++ b/install-files/essential-files/usr/bin/brpaste @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import urllib2 +import os +import json + +URL = 'http://paste.baserock.org/documents' + +def run(*args): + if args: + content = [open(x).read() for x in args] + extensions = [os.path.splitext(x)[1] for x in args] + else: + content = [sys.stdin.read()] + extensions = [None] + + for i, each in enumerate(content): + req = urllib2.Request(URL, each) + response = urllib2.urlopen(req) + the_page = response.read() + key = json.loads(the_page)['key'] + url = "http://paste.baserock.org/%s" % key + if extensions[i]: + url += extensions[i] + print url + +if __name__ == '__main__': + import sys + sys.exit(run(*sys.argv[1:])) -- cgit v1.2.1