public
Last active — forked from bxt/senduit.py

  • Download Gist
senduit.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/python
 
import subprocess, re, sys
 
#get arguments
if len(sys.argv) < 3:
sys.exit("invalid arguments!")
 
upload_file = sys.argv[1]
#expire_time = "30 minutes"
expire_time = sys.argv[2]
 
#upload
cmd = """/usr/bin/curl -F "file=@%s" -F "expire_time=%s" -F "MAX_FILE_SIZE=104857600" http://senduit.com/index.php""" % (upload_file, expire_time)
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.wait()
print cmd
 
#check & display
if process.returncode == 0:
pattern = re.compile(r'.*(http://senduit.com/.*)"')
senduit_link = pattern.search(process.stdout.read()).groups()[0]
cmd = """kdialog --title "senduit.com" --inputbox "Ihre Datei %s ist zu finden unter: " "%s" """ % (upload_file, senduit_link)
#cmd = """/usr/bin/zenity --entry --entry-text %s --text %s uploaded to: --title senduit.com""" % (senduit_link, upload_file)
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
sys.exit("upload failed!")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.