Skip to content

Commit 2f75435

Browse files
committed
lglpy: Generate error message if adb not available
1 parent a571f39 commit 2f75435

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lglpy/android/adb.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from collections.abc import Iterable
3030
import os
3131
import shlex
32+
import shutil
3233
import subprocess as sp
3334
from typing import Optional
3435

@@ -64,10 +65,17 @@ def __init__(self, device: Optional[str] = None,
6465
None for non-specific use.
6566
package: The package name, as returned by `adb shell pm list
6667
packages` or None for non-specific use.
68+
69+
Raise:
70+
FileNotFoundError will be raised if adb is not available on the
71+
environment PATH.
6772
'''
6873
self.device = device
6974
self.package = package
7075

76+
if not shutil.which('adb'):
77+
raise FileNotFoundError('Android adb not found on the PATH')
78+
7179
def set_device(self, device: Optional[str]) -> None:
7280
'''
7381
Set the device for this connection.

0 commit comments

Comments
 (0)