11 changed files with 195 additions and 161 deletions
-
135pyadb/adb.py
-
5pyadb/extras/open_youtube.py
-
24pyadb/extras/sync_clip.py
-
39pyadb/internal/__init__.py
-
35pyadb/internal/android_db.py
-
31pyadb/internal/cli_wrap.py
-
32pyadb/internal/config.py
-
23pyadb/internal/directory.py
-
15pyadb/internal/load_config.py
-
11pyadb/test.py
-
6setup.py
@ -1,26 +1,32 @@ |
|||
import pyperclip |
|||
import time |
|||
import re |
|||
|
|||
import pyperclip |
|||
|
|||
|
|||
def sync_clipboard(dev): |
|||
db_file = '/data/data/com.catchingnow.tinyclipboardmanager/databases/clippingnow.db' |
|||
db_file = "/data/data/com.catchingnow.tinyclipboardmanager/databases/clippingnow.db" |
|||
try: |
|||
pid = dev.shell( |
|||
'pidof', 'com.catchingnow.tinyclipboardmanager', output="out") |
|||
dev.sudo('kill', pid, output='shell') |
|||
pid = dev.shell("pidof", "com.catchingnow.tinyclipboardmanager", output="out") |
|||
dev.sudo("kill", pid, output="shell") |
|||
except: |
|||
pass |
|||
t = time.time() |
|||
text = pyperclip.paste() |
|||
conn = dev.db_connect(db_file) |
|||
out = conn.execute("INSERT INTO cliphistory VALUES (?,?,?);", [ |
|||
int(1000*t), text, False]) |
|||
dev.shell('am', 'start', '-n', |
|||
'com.catchingnow.tinyclipboardmanager/.activity.ActivityMain') |
|||
out = conn.execute( |
|||
"INSERT INTO cliphistory VALUES (?,?,?);", [int(1000 * t), text, False] |
|||
) |
|||
dev.shell( |
|||
"am", |
|||
"start", |
|||
"-n", |
|||
"com.catchingnow.tinyclipboardmanager/.activity.ActivityMain", |
|||
) |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
import adb |
|||
|
|||
d = adb.Device.prim_device() |
|||
sync_clipboard(d) |
|||
@ -0,0 +1,32 @@ |
|||
import configparser |
|||
import re |
|||
import os.path as osp |
|||
|
|||
# https://stackoverflow.com/a/11866695 |
|||
ROOT = osp.dirname(__file__) |
|||
CONFIG_PATH = osp.join(ROOT, "config.ini") |
|||
|
|||
|
|||
class AdbConfig(configparser.ConfigParser): |
|||
def __init__(self): |
|||
super().__init__(interpolation=configparser.ExtendedInterpolation()) |
|||
|
|||
def getlist(self, section, option, fallback=None): |
|||
data = self.get(section, option, fallback=fallback) |
|||
if data == fallback: |
|||
return data |
|||
return list(filter(bool, re.split(" *, *", data))) |
|||
|
|||
def getpath(self, section, option, fallback=None): |
|||
data = self.get(section, option, fallback=fallback) |
|||
if data == fallback: |
|||
return data |
|||
return osp.expandvars(data) |
|||
|
|||
def getpaths(self, section, option, fallback=None): |
|||
data = self.getlist(section, option, fallback) |
|||
return list(map(osp.expandvars, data)) |
|||
|
|||
|
|||
config = AdbConfig() |
|||
config.read(CONFIG_PATH) |
|||
@ -1,15 +0,0 @@ |
|||
import json |
|||
import munch |
|||
import os |
|||
import configparser |
|||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..\\')) |
|||
parser = configparser.ConfigParser( |
|||
interpolation=configparser.ExtendedInterpolation()) |
|||
parser.read(os.path.join(path, 'config.ini')) |
|||
with open(os.path.join(path, 'keycodes.json')) as k: |
|||
|
|||
keycodes = munch.munchify(json.load(k)) |
|||
config = parser.__dict__['_sections'] |
|||
for key, value in config['local'].items(): |
|||
config['local'][key] = os.path.expandvars(value) |
|||
loaded = munch.munchify(dict(config=config, keycodes=keycodes)) |
|||
@ -1,8 +1,13 @@ |
|||
import time |
|||
|
|||
from adb import Device |
|||
|
|||
d = Device.prim_device() |
|||
d.root() |
|||
conn = d.db_connect( |
|||
'/data/data/com.catchingnow.tinyclipboardmanager/databases/clippingnow.db') |
|||
out = conn.execute('INSERT INTO cliphistory (date,history,star) values (?,?,?)', [ |
|||
int(time.time()*1000), "test_test", False]) |
|||
"/data/data/com.catchingnow.tinyclipboardmanager/databases/clippingnow.db" |
|||
) |
|||
out = conn.execute( |
|||
"INSERT INTO cliphistory (date,history,star) values (?,?,?)", |
|||
[int(time.time() * 1000), "test_test", False], |
|||
) |
|||
@ -1,11 +1,11 @@ |
|||
import setuptools |
|||
import setuptools |
|||
|
|||
|
|||
setuptools.setup( |
|||
setuptools.setup( |
|||
name="pyadb", |
|||
version="1.0", |
|||
author="Raphael Roberts", |
|||
author_email="raphael.roberts48@gmail.com", |
|||
author_email="raphael.roberts48@gmail.com", |
|||
description="Python ADB wrapper", |
|||
packages=setuptools.find_packages(), |
|||
) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue