File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -425,7 +425,8 @@ def __init__(
425425 with open (config_file ) as f :
426426 config .read_file (f , config_file )
427427 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 )
429430 if email is None :
430431 email = config .get ("api" , "email" )
431432 if site is None and config .has_option ("api" , "site" ):
@@ -512,6 +513,14 @@ def __init__(
512513 self .feature_level : int = server_settings .get ("zulip_feature_level" , 0 )
513514 assert self .zulip_version is not None
514515
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+
515524 def ensure_session (self ) -> None :
516525 # Check if the session has been created already, and return
517526 # immediately if so.
You can’t perform that action at this time.
0 commit comments