Skip to content

Commit

Permalink
Showing exception message if it fails to take screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
kashishm committed Dec 22, 2017
1 parent 8cb4c95 commit 9f6579d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions getgauge/registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import re
import tempfile
from subprocess import call
Expand Down Expand Up @@ -141,15 +142,14 @@ def _take_screenshot():
temp_file = os.path.join(tempfile.gettempdir(), 'screenshot.png')
try:
call(['gauge_screenshot', temp_file])
_file = open(temp_file, 'r+b')
data = _file.read()
_file.close()
return data
except Exception as err:
print(Fore.RED + "\nFailed to take screenshot using gauge_screenshot.\n{0}".format(err))
except:
pass
if not os.path.exists(temp_file):
print(Fore.RED + "Failed to take screenshot using gauge_screenshot.")
return str.encode("")
_file = open(temp_file, 'r+b')
data = _file.read()
_file.close()
return data

print(Fore.RED + "\nFailed to take screenshot using gauge_screenshot.\n{0}".format(sys.exc_info()[0]))
return str.encode("")

registry = Registry()

0 comments on commit 9f6579d

Please sign in to comment.