
Untitled
By: a guest on Oct 15th, 2011 | syntax:
Python | size: 1.06 KB | hits: 28 | expires: Never
servername = 'unix.torvalds.net'
username = 'stevejobs'
remotedir = 'bla/' # don't forget the trailing slash
remoteurl = 'http://www.foo.com/screenshots/' # don't forget the trailing slash
playsound = true # do you want a sound if upload is done and url in your pastebuffer?
## there should be no reason to edit below this line
import os, sys, random, string, subprocess
for file in sys.stdin:
file = file.strip()
fileroot, fileext = os.path.splitext(file)
if os.path.isfile(file) and fileext.lower()=='.png':
print file, " is a png file"
remotefilename = ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(8)) + '.png'
# returnvalue = subprocess.check_call(['rsync', ....])
returnvalue = subprocess.check_call(['rsync', file, username + '@' + servername + ':' + remotedir + remotefilename ])
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(remoteurl + remotefilename)
p.stdin.close()
p.wait()
if (playsound):
p2 = subprocess.check_call(['afplay', '/System/Library/Sounds/Purr.aiff'])