From 18ee89361ab13b0d3c08b446df17cb6d3fe84480 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sun, 28 Jul 2019 14:45:26 +0200 Subject: [PATCH] Prepare windows releases. --- .travis.yml | 2 +- basicswap/basicswap.py | 6 +++--- bin/basicswap_prepare.py | 28 ++++++++++++++++++++-------- doc/install.md | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e17b50..2215ba2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ jobs: env: cache: false language: python - python: '3.6' + python: '3.7' install: - travis_retry pip install flake8==3.5.0 - travis_retry pip install codespell==1.15.0 diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 603268b..9d9b3ef 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -415,8 +415,8 @@ class BasicSwap(): if not os.path.exists(authcookiepath): time.sleep(0.5) try: - with open(authcookiepath) as fp: - rpcauth = fp.read() + with open(authcookiepath, 'rb') as fp: + rpcauth = fp.read().decode('utf-8') except Exception: self.log.warning('Unable to read authcookie for %s, %s', str(coin), authcookiepath) @@ -2333,7 +2333,7 @@ class BasicSwap(): def callcoincli(self, coin_type, params, wallet=None): bindir = self.coin_clients[coin_type]['bindir'] datadir = self.coin_clients[coin_type]['datadir'] - command_cli = os.path.join(bindir, chainparams[coin_type]['name'] + '-cli') + command_cli = os.path.join(bindir, chainparams[coin_type]['name'] + '-cli' + ('.exe' if os.name == 'nt' else '')) chainname = '' if self.chain == 'mainnet' else (' -' + self.chain) args = command_cli + chainname + ' ' + '-datadir=' + datadir + ' ' + params p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index 6a08ab7..5481e26 100644 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -18,6 +18,7 @@ import json import hashlib import mmap import tarfile +import zipfile import stat import time from urllib.request import urlretrieve @@ -33,6 +34,8 @@ from bin.basicswap_run import startDaemon if platform.system() == 'Darwin': BIN_ARCH = 'osx64.tar.gz' +elif platform.system() == 'Windows': + BIN_ARCH = 'win64.zip' else: BIN_ARCH = 'x86_64-linux-gnu.tar.gz' @@ -167,14 +170,23 @@ def prepareCore(coin, version, settings, data_dir): raise ValueError('Signature verification failed.') bins = [coin + 'd', coin + '-cli', coin + '-tx'] - with tarfile.open(release_path) as ft: - for b in bins: - out_path = os.path.join(bin_dir, b) - fi = ft.extractfile('{}-{}/bin/{}'.format(coin, version, b)) - with open(out_path, 'wb') as fout: - fout.write(fi.read()) - fi.close() - os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH) + if os_name == 'win': + with zipfile.ZipFile(release_path) as fz: + for b in bins: + b += '.exe' + out_path = os.path.join(bin_dir, b) + with open(out_path, 'wb') as fout: + fout.write(fz.read('{}-{}/bin/{}'.format(coin, version, b))) + os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH) + else: + with tarfile.open(release_path) as ft: + for b in bins: + out_path = os.path.join(bin_dir, b) + fi = ft.extractfile('{}-{}/bin/{}'.format(coin, version, b)) + with open(out_path, 'wb') as fout: + fout.write(fi.read()) + fi.close() + os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH) def prepareDataDir(coin, settings, data_dir, chain, particl_mnemonic): diff --git a/doc/install.md b/doc/install.md index 6b81e41..df7f42f 100644 --- a/doc/install.md +++ b/doc/install.md @@ -70,3 +70,20 @@ To run in a different directory and on testnet: $ pip3 install . $ basicswap-prepare $ basicswap-run + + +# Windows + +Install git and python3 +Right click in the directory you want to install into and select 'Git Bash Here': + + $ git clone https://github.com/tecnovert/basicswap.git + $ cd basicswap + $ pip3 install . + $ basicswap-prepare + $ basicswap-run + +Open url in browser: +http://localhost:12700 + +Shutdown by pressibg ctrl + c in the Git Bash console window.