This commit is contained in:
Kimberly 2019-10-30 13:51:59 -06:00
Родитель 9f2463c5f3 cbfdfce276
Коммит 3bf33c5a71
4 изменённых файлов: 39 добавлений и 25 удалений

Просмотреть файл

@ -15,9 +15,8 @@ more-itertools = "==7.2.0"
mozdownload = "==1.26"
mozinfo = "==1.1.0"
mozinstall = "==2.0.0"
mozlog = "==4.2.0"
mozrunner = "==7.5.1"
mozversion = "==2.1.0"
mozrunner = "==7.7"
mozversion = "==2.2.0"
mss = "==4.0.3"
numpy = "==1.17.2"
opencv-python = "==4.1.1.26"
@ -31,7 +30,6 @@ pyperclip = "==1.7.0"
pytesseract = "==0.3.0"
pytest = "==5.1.2"
python-dateutil = "==2.8.0"
# Platform dependencies
xlib = {platform_system = "== 'Linux'",version = "==0.21"}

Просмотреть файл

@ -103,11 +103,11 @@ if command -v python3 &>/dev/null; then
echo -e "\n${GREEN} ---> Verified for specific python3.7. Skipped install. Already installed. ${NC}\n"
else
echo -e "${GREEN} ---> Update to Python 3.7 . ${NC}\n"
powershell -Command "scoop update python" | grep 'bucket already exists.' &> /dev/null
powershell -Command "scoop update python37" | grep 'bucket already exists.' &> /dev/null
fi
else
echo -e "\n${GREEN} ---> Installing Python 3.7 #####${NC}\n"
powershell -Command "scoop install python" | grep 'bucket already exists.' &> /dev/null
powershell -Command "scoop install python37" | grep 'bucket already exists.' &> /dev/null
if [ $? != 0 ]; then
echo -e "\n${RED} ---> Python 3.7 now installed. You need to restart the terminal one more time and run the bootstrap.sh again to complete the install.${NC}\n"
echo -e "\n${RED} ---> Last restart needed in order to use 'python3' and install python3 dependent packages ${NC}\n"
@ -118,8 +118,8 @@ fi
echo -e "\n${GREEN} ---> installing/upgrading pipenv ${NC}\n"
if command -v pipenv &>/dev/null; then
powershell -Command "pip3.7 install --upgrade pip"
powershell -Command "pip3.7 install --upgrade pipenv"
powershell -Command "pip install --upgrade pip"
powershell -Command "pip install --upgrade pipenv"
else
powershell -Command "pip3.7 install pipenv"
powershell -Command "pip install pipenv"
fi

Просмотреть файл

@ -101,16 +101,24 @@ class ScreenshotImage:
def _region_to_image(region) -> Image or ScreenshotError:
if not OSHelper.is_linux():
grabbed_area = _mss_screenshot(region)
else:
try:
grabbed_area = np.array(
screenshot(region=(region.x, region.y, region.width, region.height))
)
except (IOError, OSError):
logger.debug("Call to pyautogui.screnshot failed, using mss instead.")
grabbed_area = _mss_screenshot(region)
# On Linux, try to use pyautogui to take screenshots, and revert to mss if it fails.
# On Windows/Mac, do the reverse.
try:
if OSHelper.is_linux():
try:
grabbed_area = _pyautogui_screenshot(region)
except ScreenshotError as e:
logger.debug(e)
grabbed_area = _mss_screenshot(region)
else:
try:
grabbed_area = _mss_screenshot(region)
except ScreenshotError as e:
logger.debug(e)
grabbed_area = _pyautogui_screenshot(region)
except ScreenshotError as e:
logger.error("Screenshot failed: %s" % e)
raise ScreenshotError("Cannot create screenshot: %s" % e)
return grabbed_area
@ -130,5 +138,14 @@ def _convert_image_to_color(image):
def _mss_screenshot(region):
try:
return np.array(_mss.grab(region))
except Exception:
raise ScreenshotError("Unable to take screenshot.")
except Exception as e:
raise ScreenshotError("Call to _mss.grab failed: %s" % e)
def _pyautogui_screenshot(region):
try:
return np.array(
screenshot(region=(region.x, region.y, region.width, region.height))
)
except (IOError, OSError):
raise ScreenshotError("Call to pyautogui.screenshot failed.")

Просмотреть файл

@ -6,7 +6,7 @@ import platform
from setuptools import setup, find_packages
PACKAGE_NAME = "moziris"
PACKAGE_VERSION = "0.7"
PACKAGE_VERSION = "0.8.1"
INSTALL_REQUIRES = [
"bugzilla==1.0.0",
@ -19,9 +19,8 @@ INSTALL_REQUIRES = [
"mozdownload==1.26",
"mozinfo==1.1.0",
"mozinstall==2.0.0",
"mozlog==4.2.0",
"mozrunner==7.5.1",
"mozversion==2.1.0",
"mozrunner==7.7",
"mozversion==2.2.0",
"mss==4.0.3",
"numpy==1.17.2",
"opencv-python==4.1.1.26",