Merge branch '10-test-script-in-iot-faker' into 'master'

#10 add part of test script

Closes #10

See merge request aic20/g4t2!9
This commit is contained in:
Martin Weick 2021-01-18 20:17:10 +01:00
commit 9c6d7d2c6e

View File

@ -233,14 +233,42 @@ def print_cursor():
print('Cursor on ' + str(index) + " out of " + str(len(metadata)) + " - " + metadata[index]['filename'])
testCommands=[]
testscriptData=[]
def test_script(argv):
try:
opts, args=getopt.getopt(argv,"t")
except getopt.GetoptError:
print("Error by starting test script")
sys.exit(2)
for opt, arg in opts:
if opt == '-t':
testscriptData.append(True)
testCommands.append("deleteall")
#testCommands.append("fetchall")
testCommands.append("trigger")
testCommands.append("trigger")
testCommands.append("fetchall")
testCommands.append("exit")
testscriptData.append(len(testCommands))
else:
testscriptData.append(False)
# main input loop
command = "dummy"
test_script(sys.argv[1:])
i=0
while (command.lower() not in ["exit", "quit", "end"]):
try:
command = input("Please enter command: ")
if testscriptData[0] and i < testscriptData[1]:
command=testCommands[i]
i+=1
else:
command = input("Please enter command: ")
except:
print()
print("Error while reading keyboard input")