Skip to content

Commit 39b1fc9

Browse files
committed
BugsFix
1.修复安装脚本逻辑错误 2.main.py功能测试完毕
1 parent 9f8e7e8 commit 39b1fc9

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

Cli-Tools/main.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
# -*- coding: utf-8 -*-
21
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
34
import json
45
import os
56
import random
67
import requests
78
import subprocess
89

910
def get_cid():
10-
cid = "localfile"
1111
cid = input("请输入CID(直接回车导入本地文件):")
12-
if cid == "localfile":
12+
if cid == "":
1313
file_path = input("请输入文件绝对路径:")
1414
while os.path.exists(file_path) == False:
1515
print("该路径文件不存在,请重新输入")
1616
else:
1717
if os.path.isfile(file_path):
18-
ipfs_add_cmd = """ipfs add %s"""
18+
ipfs_add_cmd = """ipfs add %s""" % file_path
1919
ipfs_cli_output = str(subprocess.check_output(ipfs_add_cmd.split()), "utf-8")
2020
cid = ipfs_cli_output.split()[-2]
21-
elif os.path.isfile(file_path):
22-
ipfs_add_cmd = """ipfs add -r %s"""
21+
elif os.path.isdir(file_path):
22+
ipfs_add_cmd = """ipfs add -r %s""" % file_path
2323
ipfs_cli_output = str(subprocess.check_output(ipfs_add_cmd.split()), "utf-8")
2424
cid = ipfs_cli_output.split()[-2]
2525
else:
2626
pass
2727
else:
2828
pass
29+
print("已获取到CID:%s" % cid)
2930
return cid
3031

3132
def get_vshare_nodeid():
@@ -48,7 +49,8 @@ def ipfs_gc(cid):
4849
cid = get_cid()
4950
if mode == "1":
5051
minerid = get_vshare_nodeid()
51-
subprocess.run("expect /opt/vsharecloud-tools/scripts/single_deal.sh %s %s %s" % (cid, deal_duration, minerid), shell=True)
52+
cmd = "expect /opt/vsharecloud-tools/scripts/single_deal.sh %s %s %s" % (cid, deal_duration, minerid)
53+
subprocess.run(cmd, shell=True)
5254
print("交易已发起,请通过命令 lotus client list-deals 查询交易状态")
5355
if_gc = input("是否清理刚刚导入的文件缓存?(y/n)")
5456
if if_gc == "y":
@@ -58,7 +60,8 @@ def ipfs_gc(cid):
5860
exit()
5961
elif mode == "2":
6062
minerid = input("请输入FileCoin节点ID(格式:f0xxxxx):")
61-
subprocess.run("expect /opt/vsharecloud-tools/scripts/single_deal.sh %s %s %s" % (cid, deal_duration, minerid), shell=True)
63+
cmd = "expect /opt/vsharecloud-tools/scripts/single_deal.sh %s %s %s" % (cid, deal_duration, minerid)
64+
subprocess.run(cmd, shell=True)
6265
print("交易已发起,请通过命令 lotus client list-deals 查询交易状态")
6366
if_gc = input("是否清理刚刚导入的文件缓存?(y/n)")
6467
if if_gc == "y":
@@ -69,7 +72,8 @@ def ipfs_gc(cid):
6972
elif mode == "3":
7073
deal_times = input("请输入本次发起的交易次数(纯数字):")
7174
max_budget = input("请输入最大的价格预算(纯数字)")
72-
subprocess.run("expect /opt/vsharecloud-tools/scripts/global_deal.sh %s %s %s %s" % (cid, deal_duration, max_budget, deal_times), shell=True)
75+
cmd = "expect /opt/vsharecloud-tools/scripts/global_deal.sh %s %s %s %s" % (cid, deal_duration, max_budget, deal_times)
76+
subprocess.run(cmd, shell=True)
7377
print("交易已发起,请通过命令 lotus client list-deals 查询交易状态")
7478
if_gc = input("是否清理刚刚导入的文件缓存?(y/n)")
7579
if if_gc == "y":

Shell-Script/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if [[ ${release} == "centos" ]]; then
7070
sudo yum install wget gcc python3 python3-pip mariadb-devel python3-devel expect -y
7171
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm; sudo yum install -y git gcc bzr jq pkgconfig clang llvm mesa-libGL-devel opencl-headers ocl-icd ocl-icd-devel hwloc-devel
7272
else
73-
sudo apt install mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev libhwloc5 wget python3 python3-pip expect -y
73+
sudo apt install mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev wget python3 python3-pip expect -y
7474
sudo apt upgrade -y
7575
fi
7676

@@ -152,9 +152,9 @@ if [ -e /usr/local/bin/lotus ]; then
152152
rm -rf /opt/vsharecloud-tools/
153153
fi
154154
mkdir /opt/vsharecloud-tools
155-
ipfs get /ipns/vsharecloud-tools.ipns.network/ -o /opt/vsharecloud-tools/
155+
ipfs get /ipns/vsharecloud-tools.ipns.network/ -o c
156156
chmod +x /opt/vsharecloud-tools/main.py
157-
sudo ln -s /usr/lib/vsharecloud-cli /opt/vsharecloud-tools/main.py
157+
sudo ln -s /opt/vsharecloud-tools/main.py /usr/bin/vsharecloud-cli
158158
OUT_INFO "[信息] 安装已完成!"
159159

160160
exit 0

0 commit comments

Comments
 (0)