Ethereum 无法在Windows10上编译来自solc的compile_源
这是我试图运行的代码片段 def投票(请求,问题编号): bashCommand=“复制唯一标识”空唯一标识”+str(问题标识) process=subprocess.Popen(bashCommand.split(),shell=True,stdout=subprocess.PIPE) 输出,错误=process.communicate() 打印(问题编号) 问题=获取对象或404(问题,主键=问题id) _提交\结束=question.pub\日期 #打印(类型(日期)) #打印(int(_commit_end))Ethereum 无法在Windows10上编译来自solc的compile_源,ethereum,Ethereum,这是我试图运行的代码片段 def投票(请求,问题编号): bashCommand=“复制唯一标识”空唯一标识”+str(问题标识) process=subprocess.Popen(bashCommand.split(),shell=True,stdout=subprocess.PIPE) 输出,错误=process.communicate() 打印(问题编号) 问题=获取对象或404(问题,主键=问题id) _提交\结束=question.pub\日期 #打印(类型(日期)) #打印(int(
commit_end = int((_commit_end.replace(tzinfo=None) - datetime.datetime(1970,1,1).replace(tzinfo=None)).total_seconds())
# print(commit_end)
# start of contract work
r=requests.get("http://127.0.0.1:8000/polls/"+str(question_id))
print(r.content)
resp=str(r.content).split('\\n')
print("before strip")
print(resp)
resp=[x.strip() for x in resp]
print("before after")
print(resp)
choices=[]
for i in resp:
if('label' in i):
temp=""
fl=0
for j in range(1,len(i)):
if(i[j]=='>'):
fl=1
continue
if(i[j]=='<'):
fl=0
if(fl==1):
temp+=i[j]
choices.append(temp)
http_provider = HTTPProvider('http://localhost:8545')
eth_provider = Web3(http_provider).eth
default_account = eth_provider.accounts[0]
transaction_details = {
'from': default_account,
}
def get_contract_source(file_name):
with open(file_name) as f:
return f.read()
contract_source_code = get_contract_source("polls/poll.sol")
compiled_code = compile_source(contract_source_code)
# store contract_name so we keep our code DRY
contract_name = 'pollBooth'
contract_bytecode = compiled_code[f'<stdin>:{contract_name}']['bin']
contract_abi = compiled_code[f'<stdin>:{contract_name}']['abi']
contract_factory = eth_provider.contract(
abi=contract_abi,
bytecode=contract_bytecode,
)
facultylist = pickle.load(open('conf/faculty.pub', 'rb'))
contract_constructor = contract_factory.constructor(len(choices), len(facultylist),40,70)
transaction_hash = contract_constructor.transact(transaction_details)
transaction_receipt = eth_provider.getTransactionReceipt(transaction_hash)
contract_address = transaction_receipt['contractAddress']
contract_instance = eth_provider.contract(
abi=contract_abi,
address=contract_address,
ContractFactoryClass=ConciseContract,
)
with open ("conf/"+ str(question_id) + "contract_abi", 'wb') as handle:
pickle.dump(contract_abi, handle, protocol=3)
with open ("conf/"+ str(question_id) + "contract_address", 'wb') as handle:
pickle.dump(contract_address, handle, protocol=3)
with open ("conf/"+ str(question_id) + "ConciseContract", 'wb') as handle:
pickle.dump(ConciseContract, handle, protocol=3)
try:
selected_choice = question.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the question voting form.
return render(request, 'polls/detail.html', {
'question': question,
'error_message': "Contract created.",
})
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))
def get_contract_source(file_name):
with open(file_name) as f:
return f.read()
contract_source_code = get_contract_source("polls/poll.sol")
compiled_code = compile_source(contract_source_code)