From d26998c03cb6d22e921ddf2a2551f99543fe426a Mon Sep 17 00:00:00 2001 From: LexiconCode Date: Mon, 12 Aug 2019 11:51:06 -0500 Subject: [PATCH 1/2] Initial commit --- _caster.py | 8 +++++--- castervoice/lib/ctrl/dependencies.py | 23 ++++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/_caster.py b/_caster.py index 25999d7a6..74040fafc 100644 --- a/_caster.py +++ b/_caster.py @@ -24,7 +24,7 @@ from castervoice.lib import control _NEXUS = control.nexus() _NEXUS.dep.initialize() -from castervoice.lib.ctrl.dependencies import pip_path, update +from castervoice.lib.ctrl.dependencies import find_pip, update from castervoice.lib import navigation navigation.initialize_clipboard(_NEXUS) @@ -68,6 +68,7 @@ def change_monitor(): else: print("This command requires SikuliX to be enabled in the settings file") +pip = find_pip() class MainRule(MergeRule): @staticmethod @@ -84,12 +85,13 @@ def generate_sm_ccr_choices(nexus): choices[ccr_choice] = ccr_choice return Choice("name2", choices) + mapping = { # update management "update caster": - R(DependencyUpdate([pip_path, "install", "--upgrade", "castervoice"])), + R(DependencyUpdate([pip, "install", "--upgrade", "castervoice"])), "update dragonfly": - R(DependencyUpdate([pip_path, "install", "--upgrade", "dragonfly2"])), + R(DependencyUpdate([pip, "install", "--upgrade", "dragonfly2"])), # hardware management "volume []": diff --git a/castervoice/lib/ctrl/dependencies.py b/castervoice/lib/ctrl/dependencies.py index 58013dbd6..697fe059c 100644 --- a/castervoice/lib/ctrl/dependencies.py +++ b/castervoice/lib/ctrl/dependencies.py @@ -4,24 +4,22 @@ @author: synkarius ''' -import os, socket, time, pkg_resources, subprocess +import os, sys, socket, time, pkg_resources, subprocess from pkg_resources import VersionConflict, DistributionNotFound from subprocess import Popen from castervoice.lib import settings -pip_path = None update = None - def find_pip(): - # Find the pip.exe script for Python 2.7. Fallback on pip.exe. - global pip_path - python_scripts = os.path.join("Python27", "Scripts") - for path in os.environ["PATH"].split(";"): - pip = os.path.join(path, "pip.exe") - if path.endswith(python_scripts) and os.path.isfile(pip): - pip_path = pip - break + # Find the pip script for Python. + python_scripts = os.path.join(sys.exec_prefix, "Scripts") + if sys.platform == "win32": + pip = os.path.join(python_scripts, "pip.exe") + return pip + if sys.platform == "linux" or "linux2": + pip = os.path.join(python_scripts, "pip") + return pip def install_type(): @@ -54,7 +52,7 @@ def internet_check(host="1.1.1.1", port=53, timeout=3): def dependency_check(command=None): # Check for updates pip packages castervoice/dragonfly2 - com = [pip_path, "search", command] + com = [find_pip(), "search", command] startupinfo = None global update try: @@ -132,7 +130,6 @@ class DependencyMan: # Initializes functions def initialize(self): install = install_type() - find_pip() if install is "classic": dep_min_version() dep_missing() From f2b2f1fd3996ab5a0b3da086735ee145e0ca63ea Mon Sep 17 00:00:00 2001 From: LexiconCode Date: Mon, 12 Aug 2019 11:52:38 -0500 Subject: [PATCH 2/2] yapf formatting --- castervoice/lib/ctrl/dependencies.py | 1 + 1 file changed, 1 insertion(+) diff --git a/castervoice/lib/ctrl/dependencies.py b/castervoice/lib/ctrl/dependencies.py index 697fe059c..d685c4ab0 100644 --- a/castervoice/lib/ctrl/dependencies.py +++ b/castervoice/lib/ctrl/dependencies.py @@ -11,6 +11,7 @@ update = None + def find_pip(): # Find the pip script for Python. python_scripts = os.path.join(sys.exec_prefix, "Scripts")