Example #1
0
    def fetch_whatsonchain(self, url: str="https://github.com/AustEcon/woc-explorer.git",
                           branch: str='') -> None:
        assert self.plugin.src is not None  # typing bug
        assert self.plugin.config.REMOTE_REPOS_DIR is not None  # typing bug
        if not self.plugin.src.exists():
            os.makedirs(self.plugin.src, exist_ok=True)
            os.chdir(self.plugin.config.REMOTE_REPOS_DIR)
            subprocess.run(f"git clone {url}", shell=True, check=True)

            os.chdir(self.plugin.src)
            checkout_branch(branch)
Example #2
0
    def packages_reference_server(self, url: str, branch: str) -> None:
        """plyvel wheels are not available on windows so it is swapped out for plyvel-win32 to
        make it work"""

        assert self.plugin.config.PYTHON_LIB_DIR is not None
        assert self.plugin.COMPONENT_NAME is not None

        assert self.plugin.src is not None  # typing bug
        os.chdir(self.plugin.src)

        checkout_branch(branch)
        requirements_path = self.plugin.src.joinpath('requirements.txt')
        component_libs_path = self.plugin.config.PYTHON_LIB_DIR / self.plugin.COMPONENT_NAME

        process = subprocess.Popen(
            f"{sys.executable} -m pip install --target {component_libs_path} "
            f"-r {requirements_path} --upgrade", shell=True)
        process.wait()
Example #3
0
    def packages_electrumsv(self, url: str, branch: str) -> None:
        assert self.plugin.config.PYTHON_LIB_DIR is not None  # typing bug
        assert self.plugin.COMPONENT_NAME is not None  # typing bug
        assert self.plugin.src is not None  # typing bug
        os.chdir(self.plugin.src)
        checkout_branch(branch)

        electrumsv_requirements_path = (self.plugin.src.joinpath(
            "contrib/deterministic-build/requirements.txt"))
        electrumsv_binary_requirements_path = (self.plugin.src.joinpath(
            "contrib/deterministic-build/requirements-binaries.txt"))

        electrumsv_libs_path = self.plugin.config.PYTHON_LIB_DIR / self.plugin.COMPONENT_NAME
        cmd1 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \
               f"-r {electrumsv_requirements_path}"
        cmd2 = f"{sys.executable} -m pip install --target {electrumsv_libs_path} --upgrade " \
               f"-r {electrumsv_binary_requirements_path}"
        process1 = subprocess.Popen(cmd1, shell=True)
        process1.wait()
        process2 = subprocess.Popen(cmd2, shell=True)
        process2.wait()
Example #4
0
 def fetch_reference_server(self, url: str, branch: str) -> None:
     """3 possibilities:
     (dir doesn't exists) -> install
     (dir exists, url matches)
     (dir exists, url does not match - it's a forked repo)
     """
     assert self.plugin.src is not None  # typing bug
     assert self.plugin.config.REMOTE_REPOS_DIR is not None  # typing bug
     cwd = os.getcwd()
     try:
         if not self.plugin.src.exists():
             self.logger.debug("Installing reference_server (url=%s)", url)
             os.chdir(self.plugin.config.REMOTE_REPOS_DIR)
             process = subprocess.Popen(["git", "clone", f"{url}"])
             process.wait()
         elif self.plugin.src.exists():
             os.chdir(str(self.plugin.src))
             process = subprocess.Popen(["git", "pull"])
             process.wait()
             checkout_branch(branch)
     finally:
         os.chdir(cwd)
Example #5
0
    def fetch_electrumsv(self, url: str, branch: str) -> None:
        # Todo - make this generic
        """3 possibilities:
        (dir doesn't exists) -> install
        (dir exists, url matches)
        (dir exists, url does not match - it's a forked repo)
        """
        assert self.plugin.src is not None  # typing bug
        assert self.plugin.config.REMOTE_REPOS_DIR is not None  # typing bug
        if not self.plugin.src.exists():
            logger.debug(f"Installing electrumsv (url={url})")
            os.chdir(self.plugin.config.REMOTE_REPOS_DIR)
            subprocess.run(f"git clone {url}", shell=True, check=True)

        elif self.plugin.src.exists():
            os.chdir(self.plugin.src)
            result = subprocess.run(
                f"git config --get remote.origin.url",
                shell=True,
                check=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                text=True,
            )
            if result.stdout.strip() == url:
                logger.debug(f"ElectrumSV is already installed (url={url})")
                subprocess.run(f"git pull", shell=True, check=True)
                checkout_branch(branch)
            if result.stdout.strip() != url:
                existing_fork = self.plugin.src
                logger.debug(
                    f"Alternate fork of electrumsv is already installed")
                logger.debug(
                    f"Moving existing fork (to '{existing_fork}.bak')")
                logger.debug(f"Installing electrumsv (url={url})")
                os.rename(
                    self.plugin.src,
                    self.plugin.src.with_suffix(".bak"),
                )