Created
February 27, 2011 12:32
-
-
Save bxt/846144 to your computer and use it in GitHub Desktop.
Upload to senduit via python/curl/kde script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment