File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -425,7 +425,8 @@ def __init__(
425
425
with open (config_file ) as f :
426
426
config .read_file (f , config_file )
427
427
if api_key is None :
428
- api_key = config .get ("api" , "key" )
428
+ passcmd = config .get ("api" , "passcmd" )
429
+ api_key = self .get_api_key (passcmd )
429
430
if email is None :
430
431
email = config .get ("api" , "email" )
431
432
if site is None and config .has_option ("api" , "site" ):
@@ -512,6 +513,14 @@ def __init__(
512
513
self .feature_level : int = server_settings .get ("zulip_feature_level" , 0 )
513
514
assert self .zulip_version is not None
514
515
516
+ def get_api_key (self , passcmd : str ) -> Optional [str ]:
517
+ # run the passcmd command and get the API key
518
+ result = subprocess .run (passcmd .split (), capture_output = True )
519
+ if result .returncode == 0 :
520
+ return result .stdout .decode ().strip ()
521
+ else :
522
+ raise RuntimeError ("Error: Unable to retrieve API key." )
523
+
515
524
def ensure_session (self ) -> None :
516
525
# Check if the session has been created already, and return
517
526
# immediately if so.
You can’t perform that action at this time.
0 commit comments