Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowsError: [Error 2] when passing --show on Windows #5

Open
hilasha2 opened this issue Dec 6, 2020 · 1 comment
Open

WindowsError: [Error 2] when passing --show on Windows #5

hilasha2 opened this issue Dec 6, 2020 · 1 comment

Comments

@hilasha2
Copy link

hilasha2 commented Dec 6, 2020

So I am trying to run your code on Windows, python 2.7:

adbrecord.py --show

But I get this error:

File "C:[path-to-code]\adb-event-record-master\adbrecord.py", line 73, in listAllEvent
stderr=PIPE)
File "C:\Python27\lib\subprocess.py", line 394, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

So I tried to delve into subprocess.py and specifically look for the arguments passed in the constructor Popen as your code fails when calling subprocess.Popen(...) (adbrecord.py line 72)

adb = subprocess.Popen(self.adb_shell_command + [b'getevent', '-i'], stdin=PIPE, stdout=PIPE,
stderr=PIPE)

I tried to solve the issue by for example adding shell = True to subprocess.Popen:

adb = subprocess.Popen(self.adb_shell_command + [b'getevent', '-i'], stdin=PIPE, stdout=PIPE,
stderr=PIPE, shell = True)

Because I read somewhere that it's needed.
It apparently solved(?) the issue, but then I got the following error:

File "C:[path-to-code]\adb-event-record-master\adbrecord.py", line 67, in checkPermission
if subprocess.call(self.adb_command + [b'root']) != 0:
File "C:\Python27\lib\subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 394, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

So I guess I basically need to add shell=True wherever subprocess is called.

Now I get:

line 68, in checkPermission
raise OSError('Insufficient permissions')
OSError: Insufficient permissions

Which I guess is related to permissions from my phone, so I'll try to solve the issue later.

PS.
This is how to constructor looks like in subprocess.py:
image

@cy-shriram
Copy link
Contributor

PR raised with the fix for windows: #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants