|
12 | 12 |
|
13 | 13 |
|
14 | 14 | def find_existing_config(): |
15 | | - possible_locations = [ |
16 | | - '../../shared/etc/coaia.json', |
17 | | - '../shared/etc/coaia.json', |
18 | | - '../../etc/coaia.json', |
19 | | - '../etc/coaia.json', |
20 | | - '../coaia.json', |
21 | | - '../config/coaia.json', |
22 | | - './coaia.json', |
23 | | - './etc/coaia.json' |
24 | | - ] |
25 | | - |
26 | | - for location in possible_locations: |
27 | | - if os.path.exists(location): |
28 | | - return location |
29 | | - |
30 | | - if config is None: |
31 | | - #try load from $HOME |
32 | | - _home=os.getenv('HOME') |
33 | | - if _home is not None: |
34 | | - _cnf=os.path.join(_home,'.config','jgwill','coaia.json') |
35 | | - if os.path.exists(_cnf): |
36 | | - return _cnf |
37 | | - #ifnstill not found, try in $HOME/coaia.json |
38 | | - _cnf=os.path.join(_home,'coaia.json') |
39 | | - if os.path.exists(_cnf): |
40 | | - return _cnf |
41 | | - #if still not found, try in current directory, try in $HOME/Documents/coaia.json (for iOS Shell Mini) |
42 | | - _cnf=os.path.join(_home,'Documents','coaia.json') |
43 | | - if os.path.exists(_cnf): |
44 | | - return _cnf |
45 | | - if not os.path.exists(_cnf): |
| 15 | + """Locate an existing coaia.json configuration file. |
| 16 | +
|
| 17 | + The search checks common project locations followed by a few paths under the |
| 18 | + user's HOME directory. If no configuration file is found, the program exits |
| 19 | + with an error message. |
| 20 | + """ |
| 21 | + possible_locations = [ |
| 22 | + "../../shared/etc/coaia.json", |
| 23 | + "../shared/etc/coaia.json", |
| 24 | + "../../etc/coaia.json", |
| 25 | + "../etc/coaia.json", |
| 26 | + "../coaia.json", |
| 27 | + "../config/coaia.json", |
| 28 | + "./coaia.json", |
| 29 | + "./etc/coaia.json", |
| 30 | + ] |
| 31 | + |
| 32 | + for location in possible_locations: |
| 33 | + if os.path.exists(location): |
| 34 | + return location |
| 35 | + |
| 36 | + home = os.getenv("HOME") |
| 37 | + if home: |
| 38 | + home_locations = [ |
| 39 | + os.path.join(home, ".config", "jgwill", "coaia.json"), |
| 40 | + os.path.join(home, "coaia.json"), |
| 41 | + os.path.join(home, "Documents", "coaia.json"), |
| 42 | + ] |
| 43 | + for loc in home_locations: |
| 44 | + if os.path.exists(loc): |
| 45 | + return loc |
| 46 | + |
46 | 47 | print("Config file not found. Please run \"coaia init\" to create config.") |
47 | 48 | sys.exit(1) |
48 | | - return None |
49 | 49 |
|
50 | 50 | def read_config(): |
51 | 51 | global config |
@@ -91,7 +91,7 @@ def remove_placeholder_lines(text): |
91 | 91 | # Split the text into lines |
92 | 92 | lines = text.split('\n') |
93 | 93 | # Iterate over the lines and remove lines starting with "Placeholder" |
94 | | - cleaned_lines = [line for line for line in lines if not line.startswith("Placeholder")] |
| 94 | + cleaned_lines = [line for line in lines if not line.startswith("Placeholder")] |
95 | 95 |
|
96 | 96 | # Join the cleaned lines back into a string |
97 | 97 | cleaned_text = '\n'.join(cleaned_lines) |
@@ -560,13 +560,12 @@ def send_openai_request_v3(input_message, temperature=0.7, preprompt_instruction |
560 | 560 | def _newjtaler(jtalecnf): |
561 | 561 | try: |
562 | 562 | _r = redis.Redis( |
563 | | - host=jtalecnf['host'], |
564 | | - port=int(jtalecnf['port']), |
565 | | - password=jtalecnf['password'], |
566 | | - ssl=jtalecnf['ssl']) |
567 | | - print('newjtaler servide created') |
| 563 | + host=jtalecnf['host'], |
| 564 | + port=int(jtalecnf['port']), |
| 565 | + password=jtalecnf['password'], |
| 566 | + ssl=jtalecnf['ssl']) |
568 | 567 | return _r |
569 | | - except Exception as e : |
| 568 | + except Exception as e: |
570 | 569 | print(e) |
571 | 570 | print('error creating newjtaler') |
572 | 571 | return None |
|
0 commit comments