Codebase list xapp / 0f28d18 files / usr / bin / pastebin
0f28d18

Tree @0f28d18 (Download .tar.gz)

pastebin @0f28d18raw · history · blame

#!/usr/bin/python3

import sys
import os
import stat
import subprocess

content = ""

mode = os.fstat(0).st_mode
if stat.S_ISFIFO(mode):
    content = sys.stdin.read()
elif stat.S_ISREG(mode):
    content = sys.stdin.read()
else:
    args = sys.argv[1:]
    if len(args) == 1 and os.path.exists(args[0]):
        with open(args[0], 'r') as infile:
            content = infile.read()
    else:
        str_args = ' '.join(args)
        content = str_args

if content != "":
    for paster in ['/usr/bin/gist-paste', '/usr/bin/fpaste']:
        if os.path.exists(paster):
            p = subprocess.Popen([paster], stdin=subprocess.PIPE)
            p.communicate(content.encode("UTF-8"))