mirror of
https://github.com/kawasaki/pyscrlink.git
synced 2025-07-21 09:31:21 +02:00
bluepy_helper_cap.py, gencert.py: Remove capture_output
The argument capture_output which was introduced in python 3.7 is used in bluepy_helper_cap.py and gencert.py. This cause failure with python 3.6 environment. Avoid the failure by removing the argument. Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
This commit is contained in:
@@ -42,8 +42,8 @@ def helper_path():
|
||||
|
||||
def is_set():
|
||||
path = helper_path()
|
||||
p = subprocess.run(["getcap", path], capture_output=True)
|
||||
if p.returncode !=0:
|
||||
p = subprocess.run(["getcap", path], stdout=subprocess.PIPE)
|
||||
if p.returncode != 0:
|
||||
logger.error(f"Failed to get capability of {path}")
|
||||
return False
|
||||
out = str(p.stdout)
|
||||
@@ -53,8 +53,8 @@ def setcap():
|
||||
path = helper_path()
|
||||
if is_set():
|
||||
return True
|
||||
p = subprocess.run(["sudo", "setcap", "cap_net_raw,cap_net_admin+eip", \
|
||||
path], capture_output=True)
|
||||
p = subprocess.run(["sudo", "setcap", "cap_net_raw,cap_net_admin+eip",
|
||||
path])
|
||||
if p.returncode !=0:
|
||||
logger.error(f"Failed to set capability to {path}")
|
||||
return False
|
||||
|
@@ -83,12 +83,13 @@ def certutil_db_name(dir):
|
||||
def remove_cert(dir, nickname):
|
||||
while True:
|
||||
p = subprocess.run(["certutil", "-L", "-d", certutil_db_name(dir),
|
||||
"-n", nickname], capture_output=True)
|
||||
"-n", nickname], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
if p.returncode != 0:
|
||||
break
|
||||
logger.info(f"Delete certificate {nickname} from {dir}")
|
||||
p = subprocess.run(["certutil", "-D", "-d", certutil_db_name(dir),
|
||||
"-n", nickname])
|
||||
"-n", nickname], stdout=subprocess.PIPE)
|
||||
|
||||
def is_cert_valid(cert_path):
|
||||
"""
|
||||
@@ -105,14 +106,15 @@ def has_cert(dir, cert, nickname):
|
||||
"""
|
||||
# Try to list with given nick name.
|
||||
p = subprocess.run(["certutil", "-L", "-d", certutil_db_name(dir),
|
||||
"-n", nickname], capture_output=True)
|
||||
"-n", nickname], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
if p.returncode != 0:
|
||||
# No certificate with the nick name.
|
||||
return False
|
||||
|
||||
# Get the certificate in the NSSDB.
|
||||
p = subprocess.run(["certutil", "-L", "-d", certutil_db_name(dir),
|
||||
"-n", nickname, "-a"], capture_output=True)
|
||||
"-n", nickname, "-a"], stdout=subprocess.PIPE)
|
||||
assert (p.returncode == 0), "Unexpected certutil result"
|
||||
cert_in_db = p.stdout.replace(b'\r\n', b'\n')
|
||||
|
||||
|
Reference in New Issue
Block a user