python - Airflow - BashOperator - 运行 2 个 CLI 命令时出错
问题描述
我正在使用 Ubuntu 20.04 和 Airflow 2.0.1。
我在 DAG 中有 BashOperator 任务,如下所示:
proxy_update_getProxies = BashOperator(
task_id='proxy_update_getProxies',
bash_command="scripts/proxies-update-get.sh",
dag=dag)
scripts
文件夹在dag
文件夹中,因此根据文档,应该可以像这样运行它。
proxies-update-get.sh
脚本包含 2 行:
proxy-lists updateGeoIpData --license-key Y00qKC2A9ZoWVXJW
proxy-lists getProxies --protocols="https" --output-format="txt" --output-file="httpsproxies.txt"
proxy-lists
是nmp
可以使用 CLI 中的这两个命令运行以更新和获取代理列表的包。脚本在任何文件夹中都可以正常工作,因此$PATH
应该没有问题,但我收到此错误:
can't open file 'proxy-lists': [Errno 2] No such file or directory
我究竟做错了什么?
解决方案
谢谢@00和@PeterRing。
我刚刚在我的 bash 脚本中使用了节点 CLI 脚本的完整路径,它运行良好:
/home/username/.nvm/versions/node/v14.16.0/lib/node_modules/proxy-lists/cli.js updateGeoIpData --license-key hshshhshshshsh
/home/username/.nvm/versions/node/v14.16.0/lib/node_modules/proxy-lists/cli.js getProxies --protocols="https" --output-format="txt" --output-file="/home/username/airflow/dags/scripts/httpsproxies.txt"
推荐阅读
- python - 是否可以使用 numpy 乘法将字符串乘以整数?
- opengl - 关于使用 glVertexAttribPointer 绑定不存在属性的索引的困惑
- c - 如何修改我用 C 编写的树遍历程序,使其不依赖递归?
- javascript - 承诺中来自 Console.log() 的奇怪行为
- flask - 如何使用 Flask SocketIO 进行多个事件?
- swift - 如何返回一个数组?
- android - Handler 何时与 Looper 关联?
- python - 如何在 python-bash 环境中管理进程?
- sql - 从 SQL 中的列中删除重复值
- javascript - 如何使用 javascript 将 css-grid 元素放入网格容器中