mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
d3dshot install logic implemented
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -9,7 +8,6 @@ from numpy import ndarray
|
|||||||
|
|
||||||
from fishy import constants
|
from fishy import constants
|
||||||
from fishy.helper.config import config
|
from fishy.helper.config import config
|
||||||
from fishy.helper.depless import singleton_proxy, install_and_import
|
|
||||||
from fishy.osservices.os_services import os_services
|
from fishy.osservices.os_services import os_services
|
||||||
|
|
||||||
|
|
||||||
@ -66,13 +64,17 @@ class PyAutoGUI(IScreenShot):
|
|||||||
class D3DShot(IScreenShot):
|
class D3DShot(IScreenShot):
|
||||||
# noinspection PyPackageRequirements
|
# noinspection PyPackageRequirements
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
for i in range(2):
|
try:
|
||||||
install_and_import("d3dshot", constants.d3dshot_git)
|
import d3dshot
|
||||||
# noinspection PyUnresolvedReferences
|
except ImportError:
|
||||||
self.d3 = d3dshot.create(capture_output="numpy")
|
logging.info("Installing d3dshot please wait...")
|
||||||
|
subprocess.call(["python", "-m", "pip", "install", constants.d3dshot_git])
|
||||||
|
import d3dshot
|
||||||
|
|
||||||
|
self.d3 = d3dshot.create(capture_output="numpy")
|
||||||
|
|
||||||
def setup(self) -> bool:
|
def setup(self) -> bool:
|
||||||
monitor_id = get_monitor_id(self.d3.display, lambda m: (m.top, m.left))
|
monitor_id = get_monitor_id(self.d3.displays, lambda m: (m.position["top"], m.position["left"]))
|
||||||
if monitor_id is None:
|
if monitor_id is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
no imports from fishy itself here, or anything which depends on fishy
|
no imports from fishy itself here, or anything which depends on fishy
|
||||||
"""
|
"""
|
||||||
import importlib
|
|
||||||
|
|
||||||
|
|
||||||
def singleton_proxy(instance_name):
|
def singleton_proxy(instance_name):
|
||||||
def decorator(root_cls):
|
def decorator(root_cls):
|
||||||
if not hasattr(root_cls, instance_name):
|
if not hasattr(root_cls, instance_name):
|
||||||
@ -19,15 +16,3 @@ def singleton_proxy(instance_name):
|
|||||||
return NewClass
|
return NewClass
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def install_and_import(package, package_url=None):
|
|
||||||
try:
|
|
||||||
importlib.import_module(package)
|
|
||||||
except ImportError:
|
|
||||||
import pip
|
|
||||||
if package_url is None:
|
|
||||||
package_url = package
|
|
||||||
pip.main(['install', package_url])
|
|
||||||
finally:
|
|
||||||
globals()[package] = importlib.import_module(package)
|
|
Reference in New Issue
Block a user