This commit is contained in:
yumoqing 2023-12-18 18:54:15 +08:00
parent 3382ffb1ba
commit ab9e41bb69
4 changed files with 18 additions and 18 deletions

View File

@ -64,7 +64,7 @@ class AuthAPI(AppLogger):
self.conf = getConfig() self.conf = getConfig()
async def checkUserPermission(self, user, path): async def checkUserPermission(self, user, path):
print('************* checkUserPermission() use default one ****************') # print('************* checkUserPermission() use default one ****************')
return True return True
def getPrivateKey(self): def getPrivateKey(self):
@ -105,7 +105,7 @@ class AuthAPI(AppLogger):
client_uuid = request.headers.get('client_uuid') client_uuid = request.headers.get('client_uuid')
ip = self._get_ip(request) ip = self._get_ip(request)
valid_until = int(time.time()) + self._max_age valid_until = int(time.time()) + self._max_age
print(f'hack: my _new_ticket() called ...remote {ip=}, {client_uuid=}') # print(f'hack: my _new_ticket() called ...remote {ip=}, {client_uuid=}')
return self._ticket.new(user_id, return self._ticket.new(user_id,
valid_until=valid_until, valid_until=valid_until,
client_ip=ip, client_ip=ip,

View File

@ -12,7 +12,7 @@ def load_plugins(p_dir):
ef = ExecFile() ef = ExecFile()
pdir = os.path.join(p_dir, 'plugins') pdir = os.path.join(p_dir, 'plugins')
if not os.path.isdir(pdir): if not os.path.isdir(pdir):
print('load_plugins:%s not exists' % pdir) # print('load_plugins:%s not exists' % pdir)
return return
sys.path.append(pdir) sys.path.append(pdir)
ef.set('sys',sys) ef.set('sys',sys)
@ -22,8 +22,8 @@ def load_plugins(p_dir):
continue continue
if not m.endswith('.py'): if not m.endswith('.py'):
continue continue
print(f'{m=}') # print(f'{m=}')
module = os.path.basename(m[:-3]) module = os.path.basename(m[:-3])
print('module=', module) # print('module=', module)
__import__(module, locals(), globals()) __import__(module, locals(), globals())

View File

@ -51,11 +51,11 @@ class Url2File:
return real_path return real_path
if not os.path.isdir(os.path.dirname(real_path)): if not os.path.isdir(os.path.dirname(real_path)):
print(f'url2file() return None, {real_path=}, {url=},{ourl=}, {self.path=}') # print(f'url2file() return None, {real_path=}, {url=},{ourl=}, {self.path=}')
return None return None
if not self.inherit: if not self.inherit:
print(f'url2file() return None, self.inherit is false, {url:}, {self.path=}') # print(f'url2file() return None, self.inherit is false, {url:}, {self.path=}')
return None return None
items = url.split('/') items = url.split('/')
@ -65,7 +65,7 @@ class Url2File:
url = '/'.join(items) url = '/'.join(items)
# print(f'{oldurl=}, {url=}') # print(f'{oldurl=}, {url=}')
return self.url2file(url) return self.url2file(url)
print(f'url2file() return None finally, {items:}, {url=}, {ourl=}, {self.path=}') # print(f'url2file() return None finally, {items:}, {url=}, {ourl=}, {self.path=}')
return None return None
def relatedurl(self,url: str, name: str) -> str: def relatedurl(self,url: str, name: str) -> str:

View File

@ -18,7 +18,7 @@ class XtermProcessor(BaseProcessor):
if msg.type == aiohttp.WSMsgType.TEXT: if msg.type == aiohttp.WSMsgType.TEXT:
self.p_obj.stdin.write(msg.data) self.p_obj.stdin.write(msg.data)
elif msg.type == aiohttp.WSMsgType.ERROR: elif msg.type == aiohttp.WSMsgType.ERROR:
print('ws connection closed with exception %s' % ws.exception()) # print('ws connection closed with exception %s' % ws.exception())
return return
async def process_2_ws(self, ws): async def process_2_ws(self, ws):
@ -48,7 +48,7 @@ class XtermProcessor(BaseProcessor):
async with aiofiles.open(self.real_path, 'r', encoding='utf-8') as f: async with aiofiles.open(self.real_path, 'r', encoding='utf-8') as f:
txt = await f.read() txt = await f.read()
self.login_info = json.loads(txt) self.login_info = json.loads(txt)
print(f'{self.login_info=}') # print(f'{self.login_info=}')
async def create_process(self): async def create_process(self):
# id = lenv['params_kw'].get('termid') # id = lenv['params_kw'].get('termid')
@ -91,32 +91,32 @@ class WebsocketProcessor(PythonScriptProcessor):
await ws.send_str(json.dumps(data)) await ws.send_str(json.dumps(data))
async def path_call(self, request,params={}): async def path_call(self, request,params={}):
print('1----------------------------------') # print('1----------------------------------')
await self.set_run_env(request) await self.set_run_env(request)
lenv = self.run_ns.copy() lenv = self.run_ns.copy()
lenv.update(params) lenv.update(params)
del lenv['request'] del lenv['request']
print('2----------------------------------') # print('2----------------------------------')
txt = self.loadScript(self.real_path) txt = self.loadScript(self.real_path)
exec(txt,lenv,lenv) exec(txt,lenv,lenv)
func = lenv['myfunc'] func = lenv['myfunc']
print('3----------------------------------') # print('3----------------------------------')
ws = web.WebSocketResponse() ws = web.WebSocketResponse()
await ws.prepare(request) await ws.prepare(request)
print('4----------------------------------', aiohttp.WSMsgType.TEXT) # print('4----------------------------------', aiohttp.WSMsgType.TEXT)
await self.ws_sendstr(ws, 'Welcome to websock') await self.ws_sendstr(ws, 'Welcome to websock')
async for msg in ws: async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT: if msg.type == aiohttp.WSMsgType.TEXT:
print('msg=:', msg) # print('msg=:', msg)
lenv['ws_data'] = msg.data lenv['ws_data'] = msg.data
# resp = await func(request,**lenv) # resp = await func(request,**lenv)
await self.ws_sendstr(ws, msg.data) await self.ws_sendstr(ws, msg.data)
print('msg.data=', msg.data) # print('msg.data=', msg.data)
elif msg.type == aiohttp.WSMsgType.ERROR: elif msg.type == aiohttp.WSMsgType.ERROR:
print('ws connection closed with exception %s' % ws.exception()) # print('ws connection closed with exception %s' % ws.exception())
else: else:
print('datatype error', msg.type) print('datatype error', msg.type)
print('5----------------------------------') # print('5----------------------------------')
self.retResponse = ws self.retResponse = ws
await ws.close() await ws.close()
return ws return ws