Updated release script to use pyserial to automatically create subdirs for
uploader.
Showing
1 changed file
with
39 additions
and
15 deletions
1 | import serial | ||
2 | import io | ||
1 | import os | 3 | import os |
2 | import sys | 4 | import sys |
3 | 5 | ||
6 | PORT = 'COM17' | ||
7 | BAUDRATE = 115200 | ||
8 | IPADDRESS = ' 192.168.1.122' | ||
9 | |||
10 | folders = ['help', 'rooms', 'inventory', 'commands', 'mobs'] | ||
11 | |||
4 | files = [ | 12 | files = [ |
5 | "commandhandler.py", | 13 | "commandhandler.py", |
6 | "inventoryhandler.py", | 14 | "inventoryhandler.py", |
... | @@ -14,24 +22,40 @@ files = [ | ... | @@ -14,24 +22,40 @@ files = [ |
14 | "wifiweb.py" | 22 | "wifiweb.py" |
15 | ] | 23 | ] |
16 | 24 | ||
17 | for f in os.listdir('help'): | 25 | def run_command(sio, command, expected='>>>'): |
18 | files.append('help/' + f) | 26 | sio.write("{}\n".format(command)) |
19 | 27 | sio.flush() # it is buffering. required to get the data out *now* | |
20 | for f in os.listdir('rooms'): | 28 | res = '' |
21 | files.append('rooms/' + f) | 29 | while expected not in res: |
22 | 30 | res = sio.readline() | |
23 | for f in os.listdir('inventory'): | 31 | # print(res) |
24 | files.append('inventory/' + f) | 32 | return res |
25 | 33 | ||
26 | for f in os.listdir('commands'): | 34 | with serial.Serial(PORT, BAUDRATE, timeout=1) as ser: |
27 | files.append('commands/' + f) | 35 | sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) |
28 | 36 | run_command(sio, 'import os') | |
29 | for f in os.listdir('mobs'): | 37 | root = eval(run_command(sio, 'os.listdir()', expected=']')) |
30 | files.append('mobs/' + f) | 38 | |
39 | if not set(folders).issubset(root): | ||
40 | |||
41 | print('Creating folders.') | ||
42 | # we are missing folders so they need to be created. | ||
43 | for folder in folders: | ||
44 | if folder in root: | ||
45 | continue | ||
46 | print('Creating folder: {}'.format(folder)) | ||
47 | run_command(sio, 'os.mkdir("{}")'.format(folder)) | ||
48 | else: | ||
49 | print('Folders already created.') | ||
50 | |||
51 | |||
52 | for folder in folders: | ||
53 | for f in os.listdir(folder): | ||
54 | files.append('{}/{}'.format(folder, f)) | ||
31 | 55 | ||
32 | with open('releasepw.conf', 'r', encoding='utf-8') as f: | 56 | with open('releasepw.conf', 'r', encoding='utf-8') as f: |
33 | password = f.read() | 57 | password = f.read() |
34 | 58 | ||
35 | for file in files: | 59 | for file in files: |
36 | os.system("python webrepl\webrepl_cli.py -p {} {} 192.168.1.138:/{}".format(password, file, file)) | 60 | os.system("python webrepl\webrepl_cli.py -p {} {} {}:/{}".format(password, file, IPADDRESS, file)) |
37 | 61 | ... | ... |
-
Please register or sign in to post a comment