Skip to content

Commit 16408d4

Browse files
add hwibridge binary (#271)
1 parent fa24258 commit 16408d4

4 files changed

Lines changed: 96 additions & 4 deletions

File tree

docs/release-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## v0.6.0 August 4, 2020
2-
- Build: Create `specterd` binaries (#258) (@stepansnigirev)
2+
- Build: Create `specterd` and `hwibridge` binaries (#258, #271) (@stepansnigirev)
33
- Devices: [Cobo Valut](https://cobo.com/hardware-wallet/cobo-vault) multisig support (#268) (@stepansnigirev)
44
- Bugfix: Fix issues and improve performance by removing local caching (#242) (@ben-kaufman)
55
- Bugfix: Fix installation issue on ARM machines by removing the BIP32 dependency (#259) (@stepansnigirev)

pyinstaller/hwibridge.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from logging.config import dictConfig
2+
from cryptoadvance.specter.cli import server
3+
import sys
4+
5+
if __name__ == "__main__":
6+
# central and early configuring of logging see
7+
# https://flask.palletsprojects.com/en/1.1.x/logging/#basic-configuration
8+
dictConfig({
9+
'version': 1,
10+
'formatters': {'default': {
11+
'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
12+
}},
13+
'handlers': {'wsgi': {
14+
'class': 'logging.StreamHandler',
15+
'stream': 'ext://flask.logging.wsgi_errors_stream',
16+
'formatter': 'default'
17+
}},
18+
'root': {
19+
'level': 'INFO',
20+
'handlers': ['wsgi']
21+
}
22+
})
23+
if "--daemon" in sys.argv:
24+
print("Daemon mode is not supported in binaries yet")
25+
sys.exit(1)
26+
if "--debug" in sys.argv:
27+
print("Debug mode is useless in binary mode, don't use it")
28+
sys.exit(1)
29+
if "--hwibridge" not in sys.argv:
30+
sys.argv.append("--hwibridge")
31+
server()

pyinstaller/hwibridge.spec

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
import platform
3+
import subprocess
4+
import mnemonic, os
5+
6+
mnemonic_path = os.path.join(mnemonic.__path__[0], "wordlist")
7+
8+
block_cipher = None
9+
10+
binaries = []
11+
if platform.system() == 'Windows':
12+
binaries = [("./windll/libusb-1.0.dll", ".")]
13+
elif platform.system() == 'Linux':
14+
if platform.processor() == 'aarch64': #ARM 64 bit
15+
binaries = [("/lib/aarch64-linux-gnu/libusb-1.0.so.0", ".")]
16+
else:
17+
binaries = [("/lib/x86_64-linux-gnu/libusb-1.0.so.0", ".")]
18+
elif platform.system() == 'Darwin':
19+
find_brew_libusb_proc = subprocess.Popen(['brew', '--prefix', 'libusb'], stdout=subprocess.PIPE)
20+
libusb_path = find_brew_libusb_proc.communicate()[0]
21+
binaries = [(libusb_path.rstrip().decode() + "/lib/libusb-1.0.dylib", ".")]
22+
23+
a = Analysis(['hwibridge.py'],
24+
binaries=binaries,
25+
datas=[('../src/cryptoadvance/specter/templates', 'templates'),
26+
('../src/cryptoadvance/specter/static', 'static'),
27+
(mnemonic_path, 'mnemonic/wordlist'),
28+
],
29+
hiddenimports=[
30+
'pkg_resources.py2_warn',
31+
'cryptoadvance.specter.config'
32+
],
33+
hookspath=['hooks/'],
34+
runtime_hooks=[],
35+
excludes=[],
36+
win_no_prefer_redirects=False,
37+
win_private_assemblies=False,
38+
cipher=block_cipher,
39+
noarchive=False)
40+
41+
if platform.system() == 'Linux':
42+
import hwilib
43+
a.datas += Tree('../udev', prefix='hwilib/udev')
44+
45+
pyz = PYZ(a.pure, a.zipped_data,
46+
cipher=block_cipher)
47+
exe = EXE(pyz,
48+
a.scripts,
49+
a.binaries,
50+
a.zipfiles,
51+
a.datas,
52+
[],
53+
name='hwibridge',
54+
debug=False,
55+
bootloader_ignore_signals=False,
56+
strip=False,
57+
upx=True,
58+
upx_exclude=[],
59+
runtime_tmpdir=None,
60+
console=True )

src/cryptoadvance/specter/cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ def server(daemon, stop, restart, force,
111111
protocol = "https"
112112

113113
if hwibridge:
114-
app.logger.info(
115-
"Running HWI Bridge mode, you can configure access \
116-
to the API at: %s://%s:%d/hwi/settings"
114+
print(
115+
" * Running HWI Bridge mode.\n"
116+
" * You can configure access to the API "
117+
"at: %s://%s:%d/hwi/settings"
117118
% (protocol, host, port)
118119
)
119120

0 commit comments

Comments
 (0)