diff --git a/screenshot b/screenshot index 9c50ee3..f69c9a9 100755 --- a/screenshot +++ b/screenshot @@ -35,21 +35,24 @@ path = config.get('GtkGrab','capPath') os.system(command.replace("%s", 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) - -pyperclip.copy(url) - -os.system(notifyCommand.replace('%s', url)) +# validate the command was successful and a file was saved +if os.path.isfile(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) + + pyperclip.copy(url) + + os.system(notifyCommand.replace('%s', url))