سؤال

I'm currently trying to run the systrace python script that is included in the platform-tools folder and I'm getting the following error:

File "systrace.py", line 274, in <module>
 main()
File "systrace.py", line 60, in main
 device_sdk_version = get_device_sdk_version()
File "systrace.py", line 44, in get_device_sdk_version
 stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
 errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
 raise child_exception
OSError: [Errno 2] No such file or directory

I'M running on Ubuntu 12.04 LTS. Here is the command I'm using to run systrace:

sudo python systrace.py -o output.html

NOTE: The sudo is in order to avoid the following error:

File "systrace.py", line 274, in <module>
 main()
File "systrace.py", line 63, in main
 os.execv(legacy_script, sys.argv)
OSError: [Errno 13] Permission denied

After doing some searching around the web I found that one solution was to add the adb to my PATH variable. I added the platform-tools directory to my PATH and I'm still getting the same error. I went ahead to check the code that is causing the problem and apparently its this snippet:

adb = subprocess.Popen(getprop_args, stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE)

where getprop_args is defined as follows:

getprop_args = ['adb', 'shell', 'getprop', 'ro.build.version.sdk']

From what I understand the code is trying to run the following command:

adb shell getprop ro.build.version.sdk

I ran the command in console and it work with no problem. I also copied both lines of code and ran them in python interpreter and it ran without a problem. I really don't know how to solve this issue. Does anyone know of a possible solution?

هل كانت مفيدة؟

المحلول

Ok so I found out what the problem was. The problem was the sudo that I was putting right before python systrace.py -o output.html I didn't know but I guess the PATH variable is different when using sudo, than when not using it. So the PATH in sudo didn't have the platform-tools directory. So I removed the sudo and I was getting the following error:

File "systrace.py", line 274, in <module>
 main()
File "systrace.py", line 63, in main
 os.execv(legacy_script, sys.argv)
OSError: [Errno 13] Permission denied

To solve this problem I ran the following command on the legacy_script:

$chmod +x ./systrace-legacy.py

And now I was able to run the systrace script without a problem :P

نصائح أخرى

this problem is causing by PATH. adb path should put the end of the other path.

for example:

$ sudo gedit /etc/environment;

PATH="...:~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/platform-tools:~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/tools"

not:

PATH="~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/platform-tools:~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/tools:..."

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top