Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print ''
print '#################################disable-network#################################'
try:
devMgr.DisableNetwork(lastNetworkId)
except WeaveDeviceMgr.DeviceManagerException, ex:
print str(ex)
print "Disable network complete"
print ''
print '#################################enable-network#################################'
try:
devMgr.EnableNetwork(lastNetworkId)
except WeaveDeviceMgr.DeviceManagerException, ex:
print ex
exit()
print "Enable network complete"
print ''
print '#################################test-network#################################'
try:
devMgr.TestNetworkConnectivity(lastNetworkId)
except WeaveDeviceMgr.DeviceManagerException, ex:
print ex
exit()
print "Network test complete"
Specifies that only the device with the given Weave node id should respond.
A value of 0xFFFFFFFFFFFFFFFF (the default) specifies that all devices should
respond.
"""
args = shlex.split(line)
optParser = OptionParser(usage=optparse.SUPPRESS_USAGE, option_class=ExtendedOption)
optParser.add_option("-p", "--pairing-code", action="store", dest="pairingCode", type="string")
optParser.add_option("-a", "--access-token", action="store", dest="accessToken", type="base64")
optParser.add_option("-d", "--use-dummy-access-token", action="store_true", dest="useDummyAccessToken")
optParser.add_option("", "--target-fabric", action="store", dest="targetFabricId", type="hexint", default=WeaveDeviceMgr.TargetFabricId_AnyFabric)
optParser.add_option("", "--target-modes", action="store", dest="targetModes", type="hexint", default=WeaveDeviceMgr.TargetDeviceMode_Any)
optParser.add_option("", "--target-vendor", action="store", dest="targetVendorId", type="hexint", default=WeaveDeviceMgr.TargetVendorId_Any)
optParser.add_option("", "--target-product", action="store", dest="targetProductId", type="hexint", default=WeaveDeviceMgr.TargetProductId_Any)
optParser.add_option("", "--target-device", action="store", dest="targetDeviceId", type="hexint", default=WeaveDeviceMgr.TargetDeviceId_Any)
try:
(options, remainingArgs) = optParser.parse_args(args)
except SystemExit:
return
if (len(remainingArgs) > 1):
print "Unexpected argument: " + remainingArgs[1]
return
if (len(remainingArgs) == 1):
options.pairingCode = remainingArgs[0]
if (options.useDummyAccessToken and not options.accessToken):
options.accessToken = base64.standard_b64decode(dummyAccessToken)
if (options.pairingCode and options.accessToken):
print "Cannot specify both pairing code and access token"
if (securityType != WeaveDeviceMgr.WiFiSecurityType_None):
if (len(args) < 3):
print "Must supply WiFi key"
return
if (len(args) > 3):
print "Unexpected argument: " + args[3]
return
networkInfo.WiFiKey = args[2]
elif (len(args) > 2):
print "Unexpected argument: " + args[2]
return
try:
addResult = self.devMgr.AddNetwork(networkInfo)
except WeaveDeviceMgr.DeviceManagerException, ex:
print str(ex)
return
self.lastNetworkId = addResult
print "Add wifi network complete (network id = " + str(addResult) + ")"