Skip to content

Commit fdac4af

Browse files
authored
Fix admin: can't read config and empty line error (#10574)
### What problem does this PR solve? As title. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Signed-off-by: Jin Hai <haijin.chn@gmail.com>
1 parent 769d701 commit fdac4af

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

admin/client/admin_client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
%ignore WS
101101
"""
102102

103+
103104
class AdminTransformer(Transformer):
104105

105106
def start(self, items):
@@ -182,17 +183,20 @@ def meta_command_name(self, items):
182183
def meta_args(self, items):
183184
return items
184185

186+
185187
def encrypt(input_string):
186188
pub = '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArq9XTUSeYr2+N1h3Afl/z8Dse/2yD0ZGrKwx+EEEcdsBLca9Ynmx3nIB5obmLlSfmskLpBo0UACBmB5rEjBp2Q2f3AG3Hjd4B+gNCG6BDaawuDlgANIhGnaTLrIqWrrcm4EMzJOnAOI1fgzJRsOOUEfaS318Eq9OVO3apEyCCt0lOQK6PuksduOjVxtltDav+guVAA068NrPYmRNabVKRNLJpL8w4D44sfth5RvZ3q9t+6RTArpEtc5sh5ChzvqPOzKGMXW83C95TxmXqpbK6olN4RevSfVjEAgCydH6HN6OhtOQEcnrU97r9H0iZOWwbw3pVrZiUkuRD1R56Wzs2wIDAQAB\n-----END PUBLIC KEY-----'
187189
pub_key = RSA.importKey(pub)
188190
cipher = Cipher_pkcs1_v1_5.new(pub_key)
189191
cipher_text = cipher.encrypt(base64.b64encode(input_string.encode('utf-8')))
190192
return base64.b64encode(cipher_text).decode("utf-8")
191193

194+
192195
def encode_to_base64(input_string):
193196
base64_encoded = base64.b64encode(input_string.encode('utf-8'))
194197
return base64_encoded.decode('utf-8')
195198

199+
196200
class AdminCLI(Cmd):
197201
def __init__(self):
198202
super().__init__()
@@ -209,8 +213,16 @@ def __init__(self):
209213

210214
def onecmd(self, command: str) -> bool:
211215
try:
212-
print(f"command: {command}")
216+
# print(f"command: {command}")
213217
result = self.parse_command(command)
218+
219+
# if 'type' in result and result.get('type') == 'empty':
220+
# return False
221+
222+
if isinstance(result, dict):
223+
if 'type' in result and result.get('type') == 'empty':
224+
return False
225+
214226
self.execute_command(result)
215227

216228
if isinstance(result, Tree):

admin/server/admin_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from api.utils.log_utils import init_root_logger
2727
from api.constants import SERVICE_CONF
2828
from api import settings
29-
from config import load_configurations, SERVICE_CONFIGS
29+
from admin.server.config import load_configurations, SERVICE_CONFIGS
3030

3131
stop_event = threading.Event()
3232

0 commit comments

Comments
 (0)