Exemplo n.º 1
0
def writeOutput(arguments):
	'Write output.'
	if '-h' in arguments or '-help' in arguments:
		print(__doc__)
		return
	suffixNumberString = almoner.getParameter(arguments, '24', 'round')
	suffixNumber = int(suffixNumberString)
	outputAccountTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'account.csv', 'account'), suffixNumberString)
	accountLines = getAccountLines(arguments, suffixNumberString)
	peerLines = getPeerLines(arguments)
	peerText = '_beginpeers\n%s_endpeers\n' % almoner.getTextByLines(peerLines)
	accountText = getPluribusunumText(peerText, accountLines)
	if almoner.sendOutputTo(outputAccountTo, accountText):
		print('The account file has been written to:\n%s\n' % outputAccountTo)
	outputReceiverTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'receiver.csv', 'receiver'), suffixNumberString)
	outputSummaryTo = almoner.getParameter(arguments, 'receiver_summary.txt', 'summary')
	denominatorSequences = getDenominatorSequencesByAccountLines(accountLines)
	originalReceiverLines = getReceiverLinesByDenominatorSequences(denominatorSequences)
	receiverLines = getPackedReceiverLines(denominatorSequences, originalReceiverLines, suffixNumber)
	receiverText = getPluribusunumText(peerText, receiverLines)
	if almoner.sendOutputTo(outputReceiverTo, receiverText):
		print('The receiver file has been written to:\n%s\n' % outputReceiverTo)
		shaOutputPrefix = almoner.getParameter(arguments, '', 'sha')
		if len(shaOutputPrefix) != 0:
			sha256FileName = almoner.getSuffixedFileName(outputReceiverTo, shaOutputPrefix)
			almoner.writeFileText(sha256FileName, hashlib.sha256(receiverText).hexdigest())
			print('The sha256 receiver file has been written to:\n%s\n' % sha256FileName)
	if almoner.sendOutputTo(outputSummaryTo, getSummaryText(accountLines, originalReceiverLines, peerLines, suffixNumber)):
		print('The summary file has been written to:\n%s\n' % outputSummaryTo)
Exemplo n.º 2
0
def writeOutput(arguments):
	'Write output.'
	if '-h' in arguments or '-help' in arguments:
		print(__doc__)
		return
	suffixNumberString = almoner.getParameter(arguments, '24', 'round')
	suffixNumber = int(suffixNumberString)
	outputAccountTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'account.csv', 'account'), suffixNumberString)
	accountLines = getAccountLines(arguments, suffixNumberString)
	peerLines = getPeerLines(arguments)
	peerText = '_beginpeers\n%s_endpeers\n' % almoner.getTextByLines(peerLines)
	accountText = getPluribusunumText(peerText, accountLines)
	if almoner.sendOutputTo(outputAccountTo, accountText):
		print('The account file has been written to:\n%s\n' % outputAccountTo)
	outputReceiverTo = almoner.getSuffixedFileName(almoner.getParameter(arguments, 'receiver.csv', 'receiver'), suffixNumberString)
	outputSummaryTo = almoner.getParameter(arguments, 'receiver_summary.txt', 'summary')
	denominatorSequences = getDenominatorSequencesByAccountLines(accountLines)
	originalReceiverLines = getReceiverLinesByDenominatorSequences(denominatorSequences)
	receiverLines = getPackedReceiverLines(denominatorSequences, originalReceiverLines, suffixNumber)
	receiverText = getPluribusunumText(peerText, receiverLines)
	if almoner.sendOutputTo(outputReceiverTo, receiverText):
		print('The receiver file has been written to:\n%s\n' % outputReceiverTo)
		shaOutputPrefix = almoner.getParameter(arguments, '', 'sha')
		if len(shaOutputPrefix) != 0:
			sha256FileName = almoner.getSuffixedFileName(outputReceiverTo, shaOutputPrefix)
			almoner.writeFileText(sha256FileName, hashlib.sha256(receiverText).hexdigest())
			print('The sha256 receiver file has been written to:\n%s\n' % sha256FileName)
	if almoner.sendOutputTo(outputSummaryTo, getSummaryText(accountLines, originalReceiverLines, peerLines, suffixNumber)):
		print('The summary file has been written to:\n%s\n' % outputSummaryTo)
Exemplo n.º 3
0
def main():
    'Replace peers.'
    beginPeerString = '_beginpeers\n'
    endPeerString = '_endpeers\n'
    receiverIndex = 0
    receiverFileName = getReceiverFileName(receiverIndex)
    receiverText = almoner.getFileText(receiverFileName)
    peerLines = almoner.getTextLines(almoner.getFileText('peer.csv'))
    replacementString = beginPeerString + almoner.getTextByLines(
        peerLines) + endPeerString
    while receiverText != '':
        beginPeerIndex = receiverText.find(beginPeerString)
        endPeerEndIndex = receiverText.find(endPeerString) + len(endPeerString)
        betweenString = receiverText[beginPeerIndex:endPeerEndIndex]
        almoner.writeFileText('backup_receiver_%s.csv' % receiverIndex,
                              receiverText)
        replacedText = receiverText.replace(betweenString, replacementString)
        almoner.writeFileText(receiverFileName, replacedText)
        print('Replaced peers in file: ' + receiverFileName)
        receiverIndex += 1
        receiverFileName = getReceiverFileName(receiverIndex)
        receiverText = almoner.getFileText(receiverFileName, False)
Exemplo n.º 4
0
def getPluribusunumText(peerText, receiverLines):
	'Get the pluribusunum text according to the arguments.'
	return 'Format,pluribusunum\n%s_begincoins\n%s_endcoins\n' % (peerText, almoner.getTextByLines(receiverLines))
Exemplo n.º 5
0
def getPluribusunumText(peerText, receiverLines):
	'Get the pluribusunum text according to the arguments.'
	return 'Format,pluribusunum\n%s_begincoins\n%s_endcoins\n' % (peerText, almoner.getTextByLines(receiverLines))