ligonlibrary 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ligonlibrary
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
Author: Ethan Ligon
|
|
6
|
+
Author-email: ligon@berkeley.edu
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
Miscellaneous useful (?) oddments.
|
|
14
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Miscellaneous useful (?) oddments.
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
def get_password_for_machine(machine_name, login=None, authinfo_file="~/.authinfo.gpg") -> str:
|
|
8
|
+
try:
|
|
9
|
+
# Expand the ~ to the user's home directory
|
|
10
|
+
authinfo_file = os.path.expanduser(authinfo_file)
|
|
11
|
+
|
|
12
|
+
# Decrypt the file using GPG
|
|
13
|
+
decrypted_content = subprocess.check_output(['gpg', '--decrypt', authinfo_file], stderr=subprocess.DEVNULL).decode('utf-8')
|
|
14
|
+
|
|
15
|
+
for line in decrypted_content.splitlines():
|
|
16
|
+
# Match the machine and optional login fields, then capture the password
|
|
17
|
+
if login:
|
|
18
|
+
match = re.search(rf'machine\s+{re.escape(machine_name)}\s+login\s+{re.escape(login)}\s+.*password\s+(\S+)', line)
|
|
19
|
+
else:
|
|
20
|
+
match = re.search(rf'machine\s+{re.escape(machine_name)}\s+.*password\s+(\S+)', line)
|
|
21
|
+
if match:
|
|
22
|
+
return match.group(1)
|
|
23
|
+
except subprocess.CalledProcessError:
|
|
24
|
+
print("Failed to decrypt the file. Ensure GPG is configured correctly.")
|
|
25
|
+
return None
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "ligonlibrary"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = ["Ethan Ligon <ligon@berkeley.edu>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
|
|
8
|
+
[tool.poetry.dependencies]
|
|
9
|
+
python = "^3.11"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["poetry-core"]
|
|
14
|
+
build-backend = "poetry.core.masonry.api"
|