问题:如何使用python对接cas统一认证系统,实现用户登录?

解决:使用模块python-cas

方法:

from cas import CASClient

cas_client = CASClient(
    version=3,
    service_url='http://xx.com/login?next=%2Fprofile',
    server_url='http://sso.xx.xx.cn/cas/'
)


@router.get("/", name="测试cas")
async def index():
    return RedirectResponse('/login')

阅读全文

问题:python使用threading实现线程时,如何调用异步函数?

解决:使用asyncio.run

方法:

async def import_users(db, temp_name):
    # 我的处理方法
    pass
lock = threading.Lock()
def thread_target():
    with lock:
        asyncio.run(import_users(db, name))

threads = [threading.Thread(target=thread_target, args=(db, temp.name)) for _ in range(10)]
for thread in threads:
    thread.start()
for thread in threads:
    thread.join()

阅读全文

问题shell脚本如何遍历文件夹下所有文件?

方法:

dir="./sql_to_hdfs_init"
for file in `ls $dir/*`
do  
  echo $file   # 输出 ./sql_to_hdfs_init/a.sh
  if test -f $file;then  # 相当于 if [ -f $file ];then
     echo "执行:$file"
  fi  
done

阅读全文

问题:hadoop集群datanode没有启动

解决:因为多次格式化namenode,出错了

方法:

删除各节点的data和logs目录,然后重新在主节点上进行namenode格式化

阅读全文