Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 52 lines (40 sloc) 1.79 kb
9109fce @EvanDotPro added config file, fixed bug in php url generation, added mac support
authored
1 #!/usr/bin/python
2 # This file is part of GtkGrab.
3 #
4 # GtkGrab is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; version 3 of the License.
7 #
8 # GtkGrab is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GtkGrab. If not, see <http://www.gnu.org/licenses/>.
15 #
16 # @category GtkGrab
17 # @license http://www.gnu.org/licenses/gpl-3.0.txt GPL
18 # @copyright Copyright 2010 Evan Coury (http://www.Evan.pro/)
19 # @copyright Copyright 2010 Pieter Kokx (http://blog.kokx.nl/)
20 # @package Client
21
22 import ConfigParser, sys, urllib2, os, base64, hashlib, time
23
24 config = ConfigParser.ConfigParser()
b1032ce @EvanDotPro fixed path to config file issue
authored
25 config.readfp(open(os.path.dirname(sys.argv[0]) + '/config.cfg'))
9109fce @EvanDotPro added config file, fixed bug in php url generation, added mac support
authored
26
27 user = config.get('GtkGrab','username')
28 token = config.get('GtkGrab','password')
29 postURL = config.get('GtkGrab','posturl')
30
31 path = '/tmp/ss.png'
32 os.system('screencapture -i '+path)
33
34 # encode the screenshot with base64
35 data = base64.b64encode(open(path, 'r').read())
36
37 # hash the data with the user's secret token and send that as header
38 hash = hashlib.sha1()
39
40 hash.update(data)
41 hash.update(token)
42
c48fda1 @EvanDotPro added text/xml header for IIS bug
authored
43 headers = { 'X-Username': user, 'X-Signature': hash.hexdigest(), 'Content-Type': 'text/xml' }
9109fce @EvanDotPro added config file, fixed bug in php url generation, added mac support
authored
44
45 # upload the url and give the screenshot url to the user
46 url = urllib2.urlopen(urllib2.Request(postURL, data, headers)).read();
47 os.remove(path)
48
1c1c6a1 @EvanDotPro removed -n from echo statement on mac version
authored
49 os.system('echo "' + url + '" | pbcopy')
9109fce @EvanDotPro added config file, fixed bug in php url generation, added mac support
authored
50
3c8b6b9 @EvanDotPro added absolute path to growlnotify
authored
51 os.system('/usr/local/bin/growlnotify -m "Copied URL to clipboard: '+url+'" -n "GtkGrab"')
Something went wrong with that request. Please try again.