Codebase list xapp / upstream/1.2.1 files / usr / bin / pastebin
upstream/1.2.1

Tree @upstream/1.2.1 (Download .tar.gz)

pastebin @upstream/1.2.1raw · 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"))