|
2 | 2 | Defines the `Controller`, which sets up the `Model`, `View`, and how they interact
|
3 | 3 | """
|
4 | 4 |
|
5 |
| -import configparser |
6 | 5 | import itertools
|
7 | 6 | import os
|
8 | 7 | import signal
|
9 |
| -import subprocess |
10 | 8 | import sys
|
11 | 9 | import time
|
12 | 10 | import webbrowser
|
@@ -103,7 +101,6 @@ def __init__(
|
103 | 101 | self.client = zulip.Client(
|
104 | 102 | config_file=config_file,
|
105 | 103 | client=client_identifier,
|
106 |
| - api_key=self.get_api_key(config_file), |
107 | 104 | )
|
108 | 105 | self.model = Model(self)
|
109 | 106 | self.view = View(self)
|
@@ -144,25 +141,6 @@ def raise_exception_in_main_thread(
|
144 | 141 | self._critical_exception = critical
|
145 | 142 | os.write(self._exception_pipe, b"1")
|
146 | 143 |
|
147 |
| - def get_api_key(self, config_file: str) -> Optional[str]: |
148 |
| - config_file = os.path.expanduser(config_file) |
149 |
| - if os.path.exists(config_file): |
150 |
| - config = configparser.ConfigParser() |
151 |
| - with open(config_file) as f: |
152 |
| - config.read_file(f, config_file) |
153 |
| - if config.has_section("api") and config.has_option("api", "passcmd"): |
154 |
| - result = subprocess.run( |
155 |
| - config["api"]["passcmd"].split(), capture_output=True |
156 |
| - ) |
157 |
| - if result.returncode == 0: |
158 |
| - return result.stdout.decode().strip() |
159 |
| - else: |
160 |
| - raise RuntimeError("Error: Unable to retrieve API key.") |
161 |
| - else: |
162 |
| - raise ValueError("Error: Invalid config file format.") |
163 |
| - else: |
164 |
| - raise FileNotFoundError(f"Error: Config file '{config_file}' not found.") |
165 |
| - |
166 | 144 | def is_in_editor_mode(self) -> bool:
|
167 | 145 | return self._editor is not None
|
168 | 146 |
|
|
0 commit comments