a guest Oct 15th, 2011 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- 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)
- if (playsound):
- p2 = subprocess.check_call(['afplay', '/System/Library/Sounds/Purr.aiff'])
RAW Paste Data