def wancommonifc(fritzbox, port, debug): location = 'http://'+fritzbox+':'+port+'/igdupnp/control/WANCommonIFC1' namespace = 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1' action = 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#' client = SoapClient(location, action, namespace, trace=debug) gclp = client.GetCommonLinkProperties() newlayer1upstreammaxbitrate = int(gclp.GetCommonLinkPropertiesResponse.NewLayer1UpstreamMaxBitRate) newlayer1downstreammaxbitrate = int(gclp.GetCommonLinkPropertiesResponse.NewLayer1DownstreamMaxBitRate) newwanaccesstype = str(gclp.GetCommonLinkPropertiesResponse.NewWANAccessType) newphysicallinkstatus = str(gclp.GetCommonLinkPropertiesResponse.NewPhysicalLinkStatus) gai = client.GetAddonInfos() newbytesendrate = int(gai.GetAddonInfosResponse.NewByteSendRate) newbytereceiverate = int(gai.GetAddonInfosResponse.NewByteReceiveRate) newpacketsendrate = int(gai.GetAddonInfosResponse.NewPacketSendRate) newpacketreceiverate = int(gai.GetAddonInfosResponse.NewPacketReceiveRate) newtotalbytessent = int(gai.GetAddonInfosResponse.NewTotalBytesSent) newtotalbytesreceived = int(gai.GetAddonInfosResponse.NewTotalBytesReceived) newautodisconnecttime = str(gai.GetAddonInfosResponse.NewAutoDisconnectTime) newidledisconnecttime = str(gai.GetAddonInfosResponse.NewIdleDisconnectTime) newdnsserver1 = str(gai.GetAddonInfosResponse.NewDNSServer1) newdnsserver2 = str(gai.GetAddonInfosResponse.NewDNSServer2) newvoipdnsserver1 = str(gai.GetAddonInfosResponse.NewVoipDNSServer1) newvoipdnsserver2 = str(gai.GetAddonInfosResponse.NewVoipDNSServer2) newupnpcontrolenabled = int(gai.GetAddonInfosResponse.NewUpnpControlEnabled) newroutedbridgedmodeboth = int(gai.GetAddonInfosResponse.NewRoutedBridgedModeBoth) msg = "newlayer1upstreammaxbitrate="+str(newlayer1upstreammaxbitrate)+" newlayer1downstreammaxbitrate="+str(newlayer1downstreammaxbitrate)+" newwanaccesstype="+str(newwanaccesstype)+" newphysicallinkstatus="+str(newphysicallinkstatus)+" newbytesendrate="+str(newbytesendrate)+" newbytereceiverate="+str(newbytereceiverate)+" newpacketsendrate="+str(newpacketsendrate)+" newpacketreceiverate="+str(newpacketreceiverate)+" newtotalbytessent="+str(newtotalbytessent)+" newtotalbytesreceived="+str(newtotalbytesreceived)+" newautodisconnecttime="+str(newautodisconnecttime)+" newidledisconnecttime="+str(newidledisconnecttime)+" newdnsserver1="+str(newdnsserver1)+" newdnsserver2="+str(newdnsserver2)+" newvoipdnsserver1="+str(newvoipdnsserver1)+" newvoipdnsserver2="+str(newvoipdnsserver2)+" newupnpcontrolenabled="+str(newupnpcontrolenabled)+" newroutedbridgedmodeboth="+str(newroutedbridgedmodeboth) return msg
#!/usr/bin/python3 from pysimplesoap.client import SoapClient location = 'http://fritz.box:49000/igdupnp/control/WANCommonIFC1' namespace = 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1' action = 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#' debug = False # display http/soap requests and responses client = SoapClient(location, action, namespace, trace=debug) response = client.GetCommonLinkProperties() upspeed = int( response.GetCommonLinkPropertiesResponse.NewLayer1UpstreamMaxBitRate) downspeed = int( response.GetCommonLinkPropertiesResponse.NewLayer1DownstreamMaxBitRate) response2 = client.GetAddonInfos() newbytesendrate = int(response2.GetAddonInfosResponse.NewByteSendRate) newbytereceiverate = int(response2.GetAddonInfosResponse.NewByteReceiveRate) print(upspeed, downspeed, newbytesendrate, newbytereceiverate)
def getReceiverate(): client = SoapClient(location, action, namespace, trace=False) response = client.GetCommonLinkProperties() response2 = client.GetAddonInfos() return int(response2.GetAddonInfosResponse.NewByteReceiveRate)