Skip to content

Commit 72e5e0d

Browse files
refactor: Move get_api_key functionality to python-zulip-api repo.
1 parent 6b126db commit 72e5e0d

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

zulipterminal/core.py

-22
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
Defines the `Controller`, which sets up the `Model`, `View`, and how they interact
33
"""
44

5-
import configparser
65
import itertools
76
import os
87
import signal
9-
import subprocess
108
import sys
119
import time
1210
import webbrowser
@@ -103,7 +101,6 @@ def __init__(
103101
self.client = zulip.Client(
104102
config_file=config_file,
105103
client=client_identifier,
106-
api_key=self.get_api_key(config_file),
107104
)
108105
self.model = Model(self)
109106
self.view = View(self)
@@ -144,25 +141,6 @@ def raise_exception_in_main_thread(
144141
self._critical_exception = critical
145142
os.write(self._exception_pipe, b"1")
146143

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-
166144
def is_in_editor_mode(self) -> bool:
167145
return self._editor is not None
168146

0 commit comments

Comments
 (0)