bb26558b by Barry

Updated release script to use pyserial to automatically create subdirs for

uploader.
1 parent ade0b68b
Showing 1 changed file with 39 additions and 15 deletions
import serial
import io
import os
import sys
PORT = 'COM17'
BAUDRATE = 115200
IPADDRESS = ' 192.168.1.122'
folders = ['help', 'rooms', 'inventory', 'commands', 'mobs']
files = [
"commandhandler.py",
"inventoryhandler.py",
......@@ -14,24 +22,40 @@ files = [
"wifiweb.py"
]
for f in os.listdir('help'):
files.append('help/' + f)
for f in os.listdir('rooms'):
files.append('rooms/' + f)
for f in os.listdir('inventory'):
files.append('inventory/' + f)
for f in os.listdir('commands'):
files.append('commands/' + f)
for f in os.listdir('mobs'):
files.append('mobs/' + f)
def run_command(sio, command, expected='>>>'):
sio.write("{}\n".format(command))
sio.flush() # it is buffering. required to get the data out *now*
res = ''
while expected not in res:
res = sio.readline()
# print(res)
return res
with serial.Serial(PORT, BAUDRATE, timeout=1) as ser:
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
run_command(sio, 'import os')
root = eval(run_command(sio, 'os.listdir()', expected=']'))
if not set(folders).issubset(root):
print('Creating folders.')
# we are missing folders so they need to be created.
for folder in folders:
if folder in root:
continue
print('Creating folder: {}'.format(folder))
run_command(sio, 'os.mkdir("{}")'.format(folder))
else:
print('Folders already created.')
for folder in folders:
for f in os.listdir(folder):
files.append('{}/{}'.format(folder, f))
with open('releasepw.conf', 'r', encoding='utf-8') as f:
password = f.read()
for file in files:
os.system("python webrepl\webrepl_cli.py -p {} {} 192.168.1.138:/{}".format(password, file, file))
os.system("python webrepl\webrepl_cli.py -p {} {} {}:/{}".format(password, file, IPADDRESS, file))
......