Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 8798d05705
Fetching contributors…

Cannot retrieve contributors at this time

executable file 52 lines (40 sloc) 1.792 kB
#!/usr/bin/python
# This file is part of GtkGrab.
#
# GtkGrab is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# GtkGrab is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GtkGrab. If not, see <http://www.gnu.org/licenses/>.
#
# @category GtkGrab
# @license http://www.gnu.org/licenses/gpl-3.0.txt GPL
# @copyright Copyright 2010 Evan Coury (http://www.Evan.pro/)
# @copyright Copyright 2010 Pieter Kokx (http://blog.kokx.nl/)
# @package Client
import ConfigParser, sys, urllib2, os, base64, hashlib, time
config = ConfigParser.ConfigParser()
config.readfp(open(os.path.dirname(sys.argv[0]) + '/config.cfg'))
user = config.get('GtkGrab','username')
token = config.get('GtkGrab','password')
postURL = config.get('GtkGrab','posturl')
path = '/tmp/ss.png'
os.system('screencapture -i '+path)
# encode the screenshot with base64
data = base64.b64encode(open(path, 'r').read())
# hash the data with the user's secret token and send that as header
hash = hashlib.sha1()
hash.update(data)
hash.update(token)
headers = { 'X-Username': user, 'X-Signature': hash.hexdigest(), 'Content-Type': 'text/xml' }
# upload the url and give the screenshot url to the user
url = urllib2.urlopen(urllib2.Request(postURL, data, headers)).read();
os.remove(path)
os.system('echo "' + url + '\c" | pbcopy')
os.system('/usr/local/bin/growlnotify -m "Copied URL to clipboard: '+url+'" -n "GtkGrab"')
Jump to Line
Something went wrong with that request. Please try again.