Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that the file exists before proceeding #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions screenshot
Original file line number Diff line number Diff line change
Expand Up @@ -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))