Skip to content

Commit f28935f

Browse files
author
Lee Miller
committed
Avoid recursion when trying to build bitmsghash lib
in environments where prebuilt one is unusable and make doesn't work.
1 parent 06ed879 commit f28935f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/proofofwork.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import ctypes
77
import os
8+
import subprocess # nosec B404
89
import sys
910
import tempfile
1011
import time
1112
from struct import pack, unpack
12-
from subprocess import call # nosec B404
1313

1414
import highlevelcrypto
1515
import openclpow
@@ -278,18 +278,26 @@ def buildCPoW():
278278
try:
279279
if "bsd" in sys.platform:
280280
# BSD make
281-
call(["make", "-C", os.path.join(paths.codePath(), "bitmsghash"),
282-
'-f', 'Makefile.bsd']) # nosec B607, B603
281+
subprocess.check_call([ # nosec B607, B603
282+
"make", "-C", os.path.join(paths.codePath(), "bitmsghash"),
283+
'-f', 'Makefile.bsd'])
283284
else:
284285
# GNU make
285-
call([ # nosec B607, B603
286+
subprocess.check_call([ # nosec B607, B603
286287
"make", "-C", os.path.join(paths.codePath(), "bitmsghash")])
287-
if os.path.exists(os.path.join(paths.codePath(), "bitmsghash", "bitmsghash.so")):
288+
if os.path.exists(
289+
os.path.join(paths.codePath(), "bitmsghash", "bitmsghash.so")
290+
):
288291
init()
289292
notifyBuild(True)
290293
else:
291294
notifyBuild(True)
295+
except (OSError, subprocess.CalledProcessError):
296+
notifyBuild(True)
292297
except: # noqa:E722
298+
logger.warning(
299+
'Unexpected exception rised when tried to build bitmsghash lib',
300+
exc_info=True)
293301
notifyBuild(True)
294302

295303

0 commit comments

Comments
 (0)