Skip to content

Commit 5818beb

Browse files
committed
Add fetch_key_val function to fetch value from Redis and handle errors gracefully
* Add `fetch_key_val` function to handle Redis connection, key retrieval, and error handling * Update `fetch_key_val` to handle `--output` flag and save value to file if specified * Update `fetch_key_val` to exit with code 1 and print error message if key is not found * Update `fetch_key_val` to exit with code 2 and print error message if Redis is unreachable
1 parent 5d47cf3 commit 5818beb

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

coaiapy/coaiamodule.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def find_existing_config():
4242
_cnf=os.path.join(_home,'Documents','coaia.json')
4343
if os.path.exists(_cnf):
4444
return _cnf
45-
_cnf = None # Initialize _cnf to None
4645
if not os.path.exists(_cnf):
4746
print("Config file not found. Please run \"coaia init\" to create config.")
4847
sys.exit(1)
@@ -92,7 +91,7 @@ def remove_placeholder_lines(text):
9291
# Split the text into lines
9392
lines = text.split('\n')
9493
# Iterate over the lines and remove lines starting with "Placeholder"
95-
cleaned_lines = [line for line in lines if not line.startswith("Placeholder")]
94+
cleaned_lines = [line for line for line in lines if not line.startswith("Placeholder")]
9695

9796
# Join the cleaned lines back into a string
9897
cleaned_text = '\n'.join(cleaned_lines)

0 commit comments

Comments
 (0)