mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
test suite: espcli can now do stuff for all configured nodes
This commit is contained in:
+10
-8
@@ -1,4 +1,5 @@
|
||||
nodes=[
|
||||
# node 0
|
||||
{
|
||||
'type' : 'wemos d1 mini v2.2.0',
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.1:1.0-port0',
|
||||
@@ -7,6 +8,7 @@ nodes=[
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096'
|
||||
},
|
||||
|
||||
# node 1
|
||||
{
|
||||
'type' : 'nodemcu geekcreit ESP12E devkit v2',
|
||||
'port' : '/dev/serial/by-path/pci-0000:00:14.0-usb-0:3.2:1.0-port0',
|
||||
@@ -15,14 +17,14 @@ nodes=[
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096'
|
||||
},
|
||||
|
||||
{
|
||||
'node' : 3,
|
||||
'type' : 'wemos d1 mini v2.2.0',
|
||||
'port' : '/dev/ttyUSB0',
|
||||
'ip' : '192.168.13.91',
|
||||
'flash_cmd' : 'esptool.py --port {port} -b 1500000 write_flash 0x0 .pioenvs/dev_ESP8266_4096/firmware.bin --flash_size=32m -p',
|
||||
'build_cmd' : 'platformio run --environment dev_ESP8266_4096'
|
||||
},
|
||||
# {
|
||||
# 'node' : 3,
|
||||
# 'type' : 'wemos d1 mini v2.2.0',
|
||||
# 'port' : '/dev/ttyUSB0',
|
||||
# 'ip' : '192.168.13.91',
|
||||
# 'flash_cmd' : 'esptool.py --port {port} -b 1500000 write_flash 0x0 .pioenvs/dev_ESP8266_4096/firmware.bin --flash_size=32m -p',
|
||||
# 'build_cmd' : 'platformio run --environment dev_ESP8266_4096'
|
||||
# },
|
||||
|
||||
]
|
||||
|
||||
|
||||
+35
-25
@@ -20,6 +20,9 @@ Examples:
|
||||
Build, flash and connect to serial for node 1:
|
||||
./espcli node 1 bfs
|
||||
|
||||
Build and flash all configured nodes:
|
||||
./espcli node all bf
|
||||
|
||||
Configure wifi settings for node:
|
||||
./espcli node 0 wificonfig
|
||||
|
||||
@@ -43,43 +46,50 @@ parser = argparse.ArgumentParser(description='ESPEasy testing framework', epilog
|
||||
parser.add_argument('--debug', action='store_true', help='enable http debugging output')
|
||||
|
||||
parser.add_argument('module', nargs=1, help='Module to use (node or espeasy)')
|
||||
parser.add_argument('node', type=int,nargs=1, help='Node number (from config)')
|
||||
|
||||
node_choices=['all']
|
||||
for node_choice in range(0,len(config.nodes)):
|
||||
node_choices.append(str(node_choice))
|
||||
parser.add_argument('node', choices=node_choices,nargs=1, help='Node number (from config)')
|
||||
|
||||
parser.add_argument('command', nargs=1, help='Function from the module (help below)')
|
||||
parser.add_argument('params', default=[], nargs='*', help='command parameters. in foo=bar form ')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
if args.node[0]<0:
|
||||
raise(Exception("node number should be 0 or higher"))
|
||||
|
||||
if args.debug:
|
||||
util.enable_http_debug()
|
||||
|
||||
|
||||
node_index=args.node[0]
|
||||
|
||||
|
||||
#we always need a node instance
|
||||
node_instance=node.Node(config.nodes[node_index], "node"+str(node_index))
|
||||
|
||||
|
||||
#determine rpc parameters
|
||||
params={}
|
||||
for param in args.params:
|
||||
(key,value)=param.split("=")
|
||||
params[key]=value
|
||||
|
||||
if args.module[0]=='node':
|
||||
command = getattr(node_instance, args.command[0])
|
||||
command(**params)
|
||||
|
||||
elif args.module[0]=='espeasy':
|
||||
espeasy_instance=espeasy.EspEasy(node_instance)
|
||||
command = getattr(espeasy_instance, args.command[0])
|
||||
command(**params)
|
||||
#which node to process? all or a specific one?
|
||||
if args.node[0]=='all':
|
||||
node_indexes=range(0,len(config.nodes))
|
||||
else:
|
||||
raise(Exception("Unknown module:"+args.module[0]))
|
||||
node_indexes=[int(args.node[0])]
|
||||
|
||||
#traverse selected nodes
|
||||
for node_index in node_indexes:
|
||||
node_instance=node.Node(config.nodes[node_index], "node"+str(node_index))
|
||||
|
||||
|
||||
#determine rpc parameters
|
||||
params={}
|
||||
for param in args.params:
|
||||
(key,value)=param.split("=")
|
||||
params[key]=value
|
||||
|
||||
if args.module[0]=='node':
|
||||
command = getattr(node_instance, args.command[0])
|
||||
command(**params)
|
||||
|
||||
elif args.module[0]=='espeasy':
|
||||
espeasy_instance=espeasy.EspEasy(node_instance)
|
||||
command = getattr(espeasy_instance, args.command[0])
|
||||
command(**params)
|
||||
else:
|
||||
raise(Exception("Unknown module:"+args.module[0]))
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@@ -182,6 +182,10 @@ class Node():
|
||||
self.flashserial()
|
||||
self.serial()
|
||||
|
||||
def bf(self):
|
||||
"""build + flashserial"""
|
||||
self.build()
|
||||
self.flashserial()
|
||||
|
||||
|
||||
def http_post(self, page, params=None, data=None, twice=False):
|
||||
|
||||
Reference in New Issue
Block a user