Akimio521 / FastCDN

全自动优选特定地区IP并自动解析到域名
GNU Affero General Public License v3.0
21 stars 3 forks source link

debian12无法运行 #3

Open Kagami47 opened 8 months ago

Kagami47 commented 8 months ago

执行 python main.py 报错: Traceback (most recent call last): File "/opt/FastCDN/main.py", line 95, in main() File "/opt/FastCDN/main.py", line 63, in main cloudflarespeedtest(command) File "/opt/FastCDN/FastCDN.py", line 72, in cloudflarespeedtest subprocess.run(command) File "/usr/lib/python3.11/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/subprocess.py", line 1024, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/opt/FastCDN/CloudflareST -f ./tmp/ipv4.txt -o ./tmp/result.csv -p 0 -httping -cfcolo HKG -n 200 -t 4 -dn 20 -dt 10 -tp 443 -url https://cf.xiu2.xyz/url -tl 300 -tll 20 -tlr 0.3 -sl 3'

找chatgpt告诉我: 根据输出结果显示,命令执行失败,因为系统无法找到名为 ./CloudflareST -f ./tmp/ipv4.txt -o ./tmp/result.csv -p 0 -httping -cfcolo HKG -n 200 -t 4 -dn 20 -dt 10 -tp 443 -url https://cf.xiu2.xyz/url -tl 300 -tll 20 -tlr 0.3 -sl 3 的文件或目录。这个问题可能是由于命令中包含了参数,导致系统将整个命令作为一个文件名来解释。

要解决这个问题,你应该将命令字符串分割成可执行的文件和参数,然后传递给 subprocess.run()。在你的代码中,应该这样修改 cloudflarespeedtest() 函数的调用部分:

python Copy code import shlex

将命令字符串分割成可执行文件和参数列表

command_parts = shlex.split(command) subprocess.run(command_parts) 这样做可以确保正确解释命令字符串,使其可以被 subprocess.run() 正确执行。

Akimio521 commented 8 months ago

你找到那个函数,在fastcdn.py里面 改成subprocess.run(command,shell=True) 再试试

Kagami47 commented 7 months ago

你找到那个函数,在fastcdn.py里面 改成 再试试subprocess.run(command,shell=True)

抱歉这么晚回复,因为发完之后我想换成ubuntu试试,但紧接着电脑又坏了。 今天我换成ubuntu,也按照你的回复改完了,但也没成功,报错/bin/sh: 1: Syntax error: "(" unexpected, 我又改成subprocess.run(command,shell=True,executable="/bin/bash")也一样, 报错: /bin/bash: -c: line 1: syntax error near unexpected token `('

/bin/bash: -c: line 1: `./CloudflareST -f ./tmp/ipv4.txt -o ./tmp/result.csv -p 0 -httping -cfcolo HKG -n 200  # 延迟测速线程;越多延迟测速越快,但可能会被识别成网络扫描,最多 1000 -t 4    # 延迟测速次数;单个 IP 延迟测速的次数;(默认 4 次) -dn 20  # 下载测速数量;延迟测速并排序后,从最低延迟起下载测速的数量;(默认 10 个) -dt 10  # 下载测速时间;单个 IP 下载测速最长时间,不能太短;(默认 10 秒) -tp 443 -url https://cf.xiu2.xyz/url  # 指定测速地址;延迟测速(HTTPing)/下载测速时使用的地址,默认地址不保证可用性,建议自建 -tl 300 -tll 20 -tlr 0.3  # 丢包几率上限;只输出低于/等于指定丢包率的 IP,范围 0.00~1.00,0 过滤掉任何丢包的 IP;(默认 1.00) -sl 3  '

我认为是config.yaml里注释造成的,将CFST的注释删掉后稀里糊涂的继续运行了。

还有不管是你博客里的还是git clone的,示例的yaml都过不了语法验证,因为缩进有问题,将缩进全部换成空格的才能通过。

Akimio521 commented 7 months ago

你找到那个函数,在fastcdn.py里面 改成 再试试subprocess.run(command,shell=True)

抱歉这么晚回复,因为发完之后我想换成ubuntu试试,但紧接着电脑又坏了。 今天我换成ubuntu,也按照你的回复改完了,但也没成功,报错/bin/sh: 1: Syntax error: "(" unexpected, 我又改成subprocess.run(command,shell=True,executable="/bin/bash")也一样, 报错: /bin/bash: -c: line 1: syntax error near unexpected token `('

/bin/bash: -c: line 1: `./CloudflareST -f ./tmp/ipv4.txt -o ./tmp/result.csv -p 0 -httping -cfcolo HKG -n 200  # 延迟测速线程;越多延迟测速越快,但可能会被识别成网络扫描,最多 1000 -t 4    # 延迟测速次数;单个 IP 延迟测速的次数;(默认 4 次) -dn 20  # 下载测速数量;延迟测速并排序后,从最低延迟起下载测速的数量;(默认 10 个) -dt 10  # 下载测速时间;单个 IP 下载测速最长时间,不能太短;(默认 10 秒) -tp 443 -url https://cf.xiu2.xyz/url  # 指定测速地址;延迟测速(HTTPing)/下载测速时使用的地址,默认地址不保证可用性,建议自建 -tl 300 -tll 20 -tlr 0.3  # 丢包几率上限;只输出低于/等于指定丢包率的 IP,范围 0.00~1.00,0 过滤掉任何丢包的 IP;(默认 1.00) -sl 3  '

我认为是config.yaml里注释造成的,将CFST的注释删掉后稀里糊涂的继续运行了。

还有不管是你博客里的还是git clone的,示例的yaml都过不了语法验证,因为缩进有问题,将缩进全部换成空格的才能通过。

可能是你的配置文件有问题,一般来说是不会读到后面注释的部分的,在shell运行把注释当成参数了,肯定有问题

Kagami47 commented 7 months ago

你找到那个函数,在fastcdn.py里面 改成 再试试subprocess.run(command,shell=True)

抱歉这么晚回复,因为发完之后我想换成ubuntu试试,但紧接着电脑又坏了。 今天我换成ubuntu,也按照你的回复改完了,但也没成功,报错/bin/sh: 1: Syntax error: "(" unexpected, 我又改成subprocess.run(command,shell=True,executable="/bin/bash")也一样, 报错: /bin/bash: -c: line 1: syntax error near unexpected token (' /bin/bash: -c: line 1:./CloudflareST -f ./tmp/ipv4.txt -o ./tmp/result.csv -p 0 -httping -cfcolo HKG -n 200  # 延迟测速线程;越多延迟测速越快,但可能会被识别成网络扫描,最多 1000 -t 4    # 延迟测速次数;单个 IP 延迟测速的次数;(默认 4 次) -dn 20  # 下载测速数量;延迟测速并排序后,从最低延迟起下载测速的数量;(默认 10 个) -dt 10  # 下载测速时间;单个 IP 下载测速最长时间,不能太短;(默认 10 秒) -tp 443 -url https://cf.xiu2.xyz/url  # 指定测速地址;延迟测速(HTTPing)/下载测速时使用的地址,默认地址不保证可用性,建议自建 -tl 300 -tll 20 -tlr 0.3  # 丢包几率上限;只输出低于/等于指定丢包率的 IP,范围 0.00~1.00,0 过滤掉任何丢包的 IP;(默认 1.00) -sl 3  ' 我认为是config.yaml里注释造成的,将CFST的注释删掉后稀里糊涂的继续运行了。 还有不管是你博客里的还是git clone的,示例的yaml都过不了语法验证,因为缩进有问题,将缩进全部换成空格的才能通过。

可能是你的配置文件有问题,一般来说是不会读到后面注释的部分的,在shell运行把注释当成参数了,肯定有问题

应该是吧,但我也不想折腾了,感谢你的开源项目,目前用着很方便,感谢