Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX authored Feb 17, 2025
2 parents 88552d3 + d6c3181 commit d7d4a1b
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 37 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Format and Lint
on:
workflow_call:
pull_request:
paths-ignore:
- '**.md'
push:
paths-ignore:
- '**.md'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Format
uses: psf/black@stable

- name: Lint
uses: astral-sh/ruff-action@v3
with:
src: "./ppadb"
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run Unit Tests
on:
workflow_call:
pull_request:
paths-ignore:
- '**.md'
push:
paths-ignore:
- '**.md'

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"


- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
target: google_apis
#emulator-options: -no-boot-anim
script: |
pip install '.[async,dev]'
pip install -r requirements.txt
pip install pytest
python3 -m pytest test -s -v --junitxml=junit/test-results.xml
python3 -m pytest test_async -s -v --junitxml=junit/test-async-results.xml
13 changes: 7 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
The package name has been renamed from 'adb' to 'ppadb'
This package is a fork of ppadb (https://github.com/swind/pure-python-adb)
=========================================================
Pure Python ADB was not being maintained, so it was forked to give new life to it.

From version **v0.2.1-dev**, the package name has been renamed from 'adb' to 'ppadb' to avoid conflit with Google `google/python-adb`_
As such, it has been renamed to ppadb-reborn on PyPi.


Introduction
Expand All @@ -13,11 +14,11 @@ You can use it to communicate with adb server (not the adb daemon on the device/

When you use `adb` command

.. image:: https://raw.githubusercontent.com/Swind/pure-python-adb/master/docs/adb_cli.png
.. image:: https://raw.githubusercontent.com/spm5065/pure-python-adb/master/docs/adb_cli.png

Now you can use `pure-python-adb` to connect to adb server as adb command line

.. image:: https://raw.githubusercontent.com/Swind/pure-python-adb/master/docs/adb_pure_python_adb.png
.. image:: https://raw.githubusercontent.com/spm5065/pure-python-adb/master/docs/adb_pure_python_adb.png

This package supports most of the adb command line tool's functionality.

Expand All @@ -30,14 +31,14 @@ This package supports most of the adb command line tool's functionality.
Requirements
============

Python 3.6+
Python 3.12+

Installation
============

.. code-block:: console
$pip install -U pure-python-adb
$pip install -U ppadb-reborn
Examples
========
Expand Down
4 changes: 2 additions & 2 deletions ppadb/command/transport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def clear(self, package):
raise ClearError(package, result.strip())

def framebuffer(self):
raise NotImplemented()
raise NotImplementedError()

def list_features(self):
result = self.shell("pm list features 2>/dev/null")
Expand Down Expand Up @@ -149,7 +149,7 @@ def log(self, name):
return conn

def logcat(self, clear=False):
raise NotImplemented()
raise NotImplementedError()

def reboot(self):
conn = self.create_connection()
Expand Down
5 changes: 0 additions & 5 deletions ppadb/command/transport_async/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import logging
import re
import time


class TransportAsync:
async def transport(self, connection):
cmd = "host:transport:{}".format(self.serial)
Expand Down
2 changes: 0 additions & 2 deletions ppadb/connection_async.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import asyncio
import struct
import socket

from ppadb.protocol import Protocol
from ppadb.utils.logger import AdbLogging
Expand Down
1 change: 0 additions & 1 deletion ppadb/device.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import os
from pathlib import Path, PurePosixPath

from ppadb.command.transport import Transport
Expand Down
6 changes: 0 additions & 6 deletions ppadb/device_async.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
try:
from asyncio import get_running_loop
except ImportError: # pragma: no cover
from asyncio import get_event_loop as get_running_loop # Python 3.6 compatibility

import os
from pathlib import Path, PurePosixPath
import re

Expand Down
2 changes: 0 additions & 2 deletions ppadb/sync/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import struct
import time
import os

from ppadb.protocol import Protocol
Expand Down Expand Up @@ -61,7 +60,6 @@ def push(self, src, dest, mode, progress=None):
self.connection._check_status()

def pull(self, src, dest):
error = None

# RECV
self._send_str(Protocol.RECV, src)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest
pytest
Exscript
16 changes: 8 additions & 8 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import logging
import os
import pytest
import time
import Exscript.protocols.telnetlib as telnetlib

import pytest

from ppadb.client import Client as AdbClient
from ppadb.device import Device as AdbDevice
import logging

logger = logging.getLogger(__name__)

adb_host = "emulator"
# adb_host = "127.0.0.1"
# adb_host = "emulator"
# adb_host = "172.20.0.2"
adb_port = 5037
device_serial = "emulator-5554"
emulator_port = 5554
adb_host = os.environ.get("ADB_HOST", "127.0.0.1")
adb_port = int(os.environ.get("ADB_PORT", "5037"))
device_serial = os.environ.get("DEVICE_SERIAL", "emulator-5554")
emulator_port = int(os.environ.get("EMULATOR_PORT", "5554"))


class EmulatorConsole:
Expand Down
3 changes: 2 additions & 1 deletion test/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def test_list_features(device):
assert "reqGlEsVersion" in features
assert "android.hardware.sensor.barometer" in features

assert features["reqGlEsVersion"] == "0x20000"
assert features["reqGlEsVersion"] is not None
assert features["reqGlEsVersion"] != ""
assert features["android.hardware.sensor.barometer"] is True


Expand Down
1 change: 1 addition & 0 deletions test/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def test_remote_connect_disconnect(client):
for index in range(0, 10):
device = client.device("emulator-5554")
if device is not None:
time.sleep(1)
break
else:
time.sleep(1)
Expand Down
5 changes: 2 additions & 3 deletions test_async/test_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ def setUp(self):
self.client = ClientAsync()

@awaiter
async def test_create_connection_fail(self):
with self.assertRaises(RuntimeError):
await self.client.create_connection()
async def test_create_connection(self):
await self.client.create_connection()

@awaiter
async def test_device_returns_none(self):
Expand Down

0 comments on commit d7d4a1b

Please sign in to comment.