Skip to content

Instantly share code, notes, and snippets.

@bxt
Created February 27, 2011 12:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bxt/846144 to your computer and use it in GitHub Desktop.
Save bxt/846144 to your computer and use it in GitHub Desktop.
Upload to senduit via python/curl/kde script
#!/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