70 lines
1.3 KiB
Python
70 lines
1.3 KiB
Python
import os
|
|
import sys
|
|
from traceback import format_exc
|
|
import asyncio
|
|
from appPublic.uniqueID import getID
|
|
from appPublic.timeUtils import days_between, strdate_add
|
|
from appPublic.jsonConfig import getConfig
|
|
from random import randint, random
|
|
from appPublic.folderUtils import listFile
|
|
|
|
from sqlor.dbpools import DBPools
|
|
databases = {
|
|
"sage":{
|
|
"driver":"aiomysql",
|
|
"async_mode":True,
|
|
"coding":"utf8",
|
|
"maxconn":100,
|
|
"dbname":"sage",
|
|
"kwargs":{
|
|
"user":"test",
|
|
"db":"sage",
|
|
"password":"QUZVcXg5V1p1STMybG5Ia6mX9D0v7+g=",
|
|
"host":"localhost"
|
|
}
|
|
}
|
|
}
|
|
|
|
async def insert_perm(path):
|
|
db = DBPools()
|
|
async with db.sqlorContext('sage') as sor:
|
|
ns = {
|
|
'id':getID(),
|
|
'path':path
|
|
}
|
|
await sor.C('permission', ns)
|
|
|
|
av_folders = [
|
|
'/index.ui',
|
|
'/user.ui',
|
|
'/top.ui',
|
|
'/center',
|
|
'/bottom.ui',
|
|
'/app_panel.ui',
|
|
'/bricks',
|
|
'/imgs',
|
|
'/login.ui',
|
|
'/up_login.dspy',
|
|
'/public',
|
|
'/tmp'
|
|
]
|
|
|
|
async def main():
|
|
root = os.path.abspath('../wwwroot')
|
|
for f in listFile(root, rescursive=True):
|
|
cnt = len(root)
|
|
pth = f[cnt:]
|
|
print(f'{f=},{root=},{pth=}, {cnt=}')
|
|
act = True
|
|
for f in av_folders:
|
|
if pth.startswith(f):
|
|
act = False
|
|
break
|
|
if act:
|
|
await insert_perm(pth)
|
|
|
|
if __name__ == '__main__':
|
|
DBPools(databases)
|
|
asyncio.get_event_loop().run_until_complete(main())
|
|
|