Skip to content

Commit

Permalink
fix: fix black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Schille committed Apr 5, 2022
1 parent b723865 commit edc6b06
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions getdeck/sources/tooler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
logger = logging.getLogger("deck")


def run(config: ClientConfiguration, cmd: Union[str, List], volume_mounts: List[str] = None) -> str:
def run(
config: ClientConfiguration, cmd: Union[str, List], volume_mounts: List[str] = None
) -> str:
import docker

# check if this image is already present on this machine
Expand All @@ -21,7 +23,12 @@ def run(config: ClientConfiguration, cmd: Union[str, List], volume_mounts: List[
cmd = " ".join(cmd)

if gnupg_socket := gnupg_agent_socket_path():
volume_mounts.extend([f"{gnupg_socket}:{gnupg_socket}", f"{gnupg_home_path()}:/home/tooler/.gnupg"])
volume_mounts.extend(
[
f"{gnupg_socket}:{gnupg_socket}",
f"{gnupg_home_path()}:/home/tooler/.gnupg",
]
)

exec_cmd = f'bash -c "{cmd}"'
logger.debug("Tooler running with: " + str(exec_cmd))
Expand All @@ -38,8 +45,8 @@ def run(config: ClientConfiguration, cmd: Union[str, List], volume_mounts: List[

def gnupg_home_path() -> str:
result = subprocess.run("echo $GNUPGHOME", shell=True, stdout=subprocess.PIPE)
if result.stdout.decode('utf-8').strip():
return result.stdout.decode('utf-8').strip()
if result.stdout.decode("utf-8").strip():
return result.stdout.decode("utf-8").strip()
else:
return os.path.expanduser("~/.gnupg")

Expand All @@ -49,8 +56,10 @@ def gnupg_agent_socket_path() -> str:
:return: the agent socket to mount
"""
try:
result = subprocess.run(["gpgconf", "--list-dir", "agent-extra-socket"], stdout=subprocess.PIPE)
return result.stdout.decode('utf-8').strip()
result = subprocess.run(
["gpgconf", "--list-dir", "agent-extra-socket"], stdout=subprocess.PIPE
)
return result.stdout.decode("utf-8").strip()
except FileNotFoundError:
# gnupg is not installed
return ""
Expand Down

0 comments on commit edc6b06

Please sign in to comment.