From 732711b25502a4c9bb1f8f4a9b44ada2c368725c Mon Sep 17 00:00:00 2001 From: avatar-lavventura Date: Mon, 9 Apr 2018 10:35:15 +0300 Subject: [PATCH] more update. --- Driver.py | 3 +-- clean.sh | 10 ++++++---- endCode.py | 29 ++++++++++++++++++----------- initialize.sh | 2 +- run.sh | 1 + runSlurm.sh | 10 ++++------ startCode.py | 23 ++++++++++------------- 7 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Driver.py b/Driver.py index 6ae2a7cb..0fb8911e 100755 --- a/Driver.py +++ b/Driver.py @@ -113,8 +113,7 @@ def isSlurmOn(): if not blockReadFromLocal.isdigit(): #{ logTest("Error: constants.BLOCK_READ_FROM_FILE is empty or contains and invalid value", "") - logTest("> Would you like to read from contract's deployed block number? y/n", "") - + logTest("> Would you like to read from contract's deployed block number? y/n", "") while True: #{ choice = input().lower() if choice in yes: diff --git a/clean.sh b/clean.sh index 8de6be13..7633679d 100755 --- a/clean.sh +++ b/clean.sh @@ -4,15 +4,17 @@ rm -f *.pyc rm -f checkSinfoOut.txt rm -f .node-xmlhttprequest* rm -f *.*~ -rm -rf docs/_build rm -f docs/*.*~ rm -f docs/nohup.out -rm -rf docs/_build_html -rm -rf docs/__pycache__ -rm -rf contract/tests/__pycache__ rm -f nohup.out rm -f ./docs/solidity_lexer.pyc rm -f contractCalls/*.*~ +rm -f ipfs.out +rm -rf docs/_build_html +rm -rf docs/__pycache__ +rm -rf contract/tests/__pycache__ +rm -rf __pycache__/ +rm -rf docs/_build pyclean docs/ diff --git a/endCode.py b/endCode.py index 9d15c431..c76d9f9b 100755 --- a/endCode.py +++ b/endCode.py @@ -6,13 +6,14 @@ jobKeyGlobal = ""; indexGlobal = ""; -def logTest(strIn): +def logTest(strIn): #{ print(strIn); txFile = open(constants.LOG_PATH + '/endCodeAnalyse/' + jobKeyGlobal + "_" + indexGlobal + '.txt', 'a'); txFile.write(strIn + "\n"); txFile.close(); - -def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): +#} + +def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): #{ endTimeStamp = os.popen('date +%s').read(); global jobKeyGlobal; jobKeyGlobal = jobKey @@ -79,8 +80,13 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): logTest("0: " + jobInfo[0]) logTest("1: " + jobInfo[2]) - + + countTry = 0; while True: #{ + if countTry > 10: + sys.exit() + countTry = countTry + 1 + logTest(jobInfo[0]); logTest(jobInfo[2]); @@ -112,7 +118,7 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): os.environ['jobId'] = jobId; logTest("JOBID ------------> " + str(jobId)); - # Here we know that job is already completed + # Here we know that job is already completed ---------------- if str(storageType) == '0' or str(storageType) == '3': #{ countTry = 0; while(True): @@ -137,7 +143,7 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): break #} - if str(storageType) == '2': + if str(storageType) == '2': #{ encrypyFolderPath = programPath + "/" + jobKey + "_" + index; os.environ['encrypyFolderPath'] = encrypyFolderPath logTest("encrypyFolderPath: " + encrypyFolderPath) @@ -152,9 +158,9 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): countTry = 0; while(True): - if (countTry > 10): + if countTry > 10: sys.exit() - countTry = countTry + 1 + countTry = countTry + 1; newHash = os.popen('ipfs add $encrypyFolderPath/result.tar.gz.minilock').read(); logTest("newHash: " + newHash) @@ -168,7 +174,8 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): os.environ['newHash'] = newHash; logTest("newHash: " + newHash); break; - + #} + logTest("jobId: " + jobId); elapsedTime = os.popen('sacct -j $jobId --format="Elapsed" | tail -n1 | head -n1').read(); logTest("ElapsedTime: " + elapsedTime); @@ -205,7 +212,7 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): transactionHash = os.popen('node $eblocPath/eBlocBrokerNodeCall.js receiptCheck $jobKey $index $elapsedRawTime $newHash $storageType $endTimeStamp').read().rstrip('\n').replace(" ", ""); time.sleep(5) elif storageType == '1': #{ - nullByte="0x00"; os.environ['nullByte'] = nullByte; + os.environ['nullByte'] = "0x00"; transactionHash = os.popen('node $eblocPath/eBlocBrokerNodeCall.js receiptCheck $jobKey $index $elapsedRawTime $nullByte $storageType $endTimeStamp').read().rstrip('\n').replace(" ", ""); while(True): if (not(transactionHash == "notconnected" or transactionHash == "")): @@ -233,9 +240,9 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName): txFile = open(constants.LOG_PATH + '/transactions/' + clusterID + '.txt', 'a'); txFile.write(transactionHash + " end_receiptCheck\n"); txFile.close(); +#} if __name__ == '__main__': #{ - #jobKey, index, storageType, shareToken, miniLockId, folderName jobKey = sys.argv[1]; index = sys.argv[2]; storageType = sys.argv[3]; diff --git a/initialize.sh b/initialize.sh index 0aba4e3f..4de74cc6 100644 --- a/initialize.sh +++ b/initialize.sh @@ -2,7 +2,7 @@ # pre-installation:----------------------------------------- -## Python 3.5.2 +## Python 3.5.2 # not-nessesary. # cd /usr/src # sudo curl -O https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz # sudo tar xzf Python-3.5.2.tgz diff --git a/run.sh b/run.sh index cc713dda..9b28472a 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,4 @@ #!/bin/bash +source ~/.venv-py3/bin/activate python Driver.py diff --git a/runSlurm.sh b/runSlurm.sh index d87a26a6..f887fcee 100644 --- a/runSlurm.sh +++ b/runSlurm.sh @@ -1,15 +1,13 @@ #!/bin/bash -# To Run: sudo bash runSlurm.sh +# To Run: sudo bash runSlurm.sh #------------------------------ sudo killall slurmctld slurmdbd slurmd -sudo slurmd sudo munged -f sudo /etc/init.d/munge start +sudo slurmd slurmdbd & -mkdir -p /tmp/slurmstate - -slurmctld -c -#slurmctld -cDvvvvvv +sudo -u $(logname) mkdir -p /tmp/slurmstate +slurmctld -c #-cDvvvvvv sinfo diff --git a/startCode.py b/startCode.py index 88764e7b..ff0143c6 100755 --- a/startCode.py +++ b/startCode.py @@ -2,35 +2,32 @@ import sys, os, constants, time -def startCall( jobKey, index ): - clusterID = constants.CLUSTER_ID; - eblocPath = constants.EBLOCPATH; - logPath = constants.LOG_PATH; - - os.environ['eblocPath'] = eblocPath; +def startCall( jobKey, index ): #{ + os.environ['eblocPath'] = constants.EBLOCPATH; os.environ['index'] = str(index); os.environ['jobKey'] = jobKey; statusId = str(constants.job_state_code['RUNNING']); os.environ['statusId'] = statusId; - unixTime = os.popen('date +%s').read(); - unixTime = str(int(unixTime) + 1); + unixTime = str(int(os.popen('date +%s').read()) + 1); os.environ['unixTime'] = unixTime; txHash = os.popen('node $eblocPath/eBlocBrokerNodeCall.js setJobStatus $jobKey $index $statusId $unixTime').read().rstrip('\n').replace(" ", ""); while(True): - if (not(txHash == "notconnected" or txHash == "")): + if not(txHash == "notconnected" or txHash == ""): break; else: os.environ['unixTime'] = unixTime; - txHash = os.popen('node $eblocPath/eBlocBrokerNodeCall.js setJobStatus $jobKey $index $statusId $unixTime').read().rstrip('\n').replace(" ", ""); + txHash = os.popen('node $eblocPath/eBlocBrokerNodeCall.js setJobStatus $jobKey $index $statusId $unixTime').read().rstrip('\n').replace(" ", ""); time.sleep(5); - txFile = open(logPath + '/transactions/' + clusterID + '.txt', 'a'); + txFile = open(constants.LOG_PATH + '/transactions/' + constants.CLUSTER_ID + '.txt', 'a'); txFile.write(txHash + " setJobStatus_started" + " " + unixTime + "\n"); txFile.close(); - -if __name__ == '__main__': +#} + +if __name__ == '__main__': #{ jobKey = sys.argv[1]; index = sys.argv[2]; startCall(jobKey, index); +#}