在本地网络上使用Google的Python-ADB

时间:2018-12-17 09:03:12

标签: android python adb

正如标题所言,很容易解释,是否有一种方法可以使用Google的Python-ADB库连接到网络上启用了[ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: value] System.Web.UI.WebControls.Unit..ctor(Int32 value) +3066885 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_VB_HB_PictureEdit_cshtml.<Execute>b__1_0(BinaryImageEditSettings settings) in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_VB_HB_PictureEdit.cshtml:15 DevExpress.Web.Mvc.UI.ExtensionsFactory.CreateExtension(Action`1 method) +67 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_VB_HB_PictureEdit_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_VB_HB_PictureEdit.cshtml:11 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_0_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_0.cshtml:23 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS_VB_TVC_VB_HB_VB2_VS.cshtml:11 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_VB_TVC_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS_VB_TVC.cshtml:106 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_1_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS_1.cshtml:14 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_TilesViewArtikelen_VB_VS_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\TilesViewArtikelen_VB_VS.cshtml:11 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_RootControl_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\RootControl.cshtml:58 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_ZoekArtikelFrm_Index_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\ZoekArtikelFrm\Index.cshtml:12 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_MainWindow_Index_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\MainWindow\Index.cshtml:147 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277 System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model) +58 ASP._Views_MainWindow_TotalRefresh_cshtml.Execute() in C:\Users\Jelle\Documents\Trunk\Psh\Psh.Asp.Net.Webshop\obj\CodeGen\Views\MainWindow\TotalRefresh.cshtml:0 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78 RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) +273 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52 System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__3() +198 System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult) +100 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45 System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9873789 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159 的设备?

我看到adb_commands.py文件中提到的与TCP连接有关的内容,这里是注释:

ADB over TCP

但是没有这样做的例子。

我有设备的IP地址和端口,以及正确的ADB密钥,我想知道是否有人可以提供示例代码段。

感谢堆:)

P.S。我正在使用If serial specifies a TCP address:port, then a TCP connection is used instead of a USB connection. ,这是python3.7的输出:

uname -a

1 个答案:

答案 0 :(得分:2)

是的,只需将ip:port传递给serial位置参数:

import os.path as op

from adb import adb_commands
from adb import sign_m2crypto

# KitKat+ devices require authentication
signer = sign_m2crypto.M2CryptoSigner(
    op.expanduser('~/.android/adbkey'))
# Connect to the device
device = adb_commands.AdbCommands()
device.ConnectDevice(port_path=None, serial="192.168.0.140:5555",
    rsa_keys=[signer])

# Now we can use Shell, Pull, Push, etc!
# for i in range(10):
#     print device.Shell('echo %d' % i)

print device.Shell('uname -a').rstrip()
print "%s, %s" % (device.Shell('getprop ro.product.brand').rstrip(),
                  device.Shell('getprop ro.product.model').rstrip())
print device.Shell('getprop ro.build.version.release').rstrip()
print device.List('/system')

我的设备上的输出:

Linux localhost 4.4.78-perf-g27c78a6 #1 SMP PREEMPT Thu Sep 6 03:28:28 CST 2018 aarch64
Xiaomi, MI 6
8.0.0
[DeviceFile(filename=bytearray(b'.'), mode=16877,
...

使用Python 2.7.15测试;该库尚未完全支持py3。 请注意,您仍然必须先通过tcpip或其他端口使设备以adb tcpip 5555模式侦听。