def main(): args = parse_arguments() addr = args.addr addr_prefix = args.addr_prefix port = args.port firmware = args.firmware template = args.template nodetype = args.type baud = int(args.baud) mac = args.write_mac if addr == 'auto' and ('send' in args.actions or 'send-receive' in args.actions): addr = read_ipv6_addr(port, addr_prefix) if template == 'auto' and firmware: template = parse_template_filename(firmware) print "------------------" print "port:", port, "@", baud print "address:", addr print "template:", template print "firmware:", firmware print "nodetype:", nodetype print "------------------" rdf = None if template and template != 'auto': ns = vars(args) ns.update({'addr': addr}) rdf = parse_rdftemplate(template, ns) for action in args.actions: if action == 'flash': flash_node(port, firmware) elif action == 'write-mac': write_mac(port, mac) elif action == 'send': send(port, rdf, False, nodetype, baud) elif action == 'send-receive': send(port, rdf, True, nodetype, baud) elif action == 'print-rdf': for elem in rdf: print elem elif action == 'receive': receive(port, nodetype, baud) elif action == 'test': test(port, nodetype, baud)