From f7a6b145fdba54bef1a23c16eb2a752952874df6 Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 26 Apr 2020 09:06:28 +0200 Subject: [PATCH] Added new option for trying su command. --- README.rst | 9 ++++++++- adbfs | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index db9ac77..4ff8137 100644 --- a/README.rst +++ b/README.rst @@ -90,12 +90,14 @@ where: * ``root`` root directory to read. Everything outside of that directory will be omitted. That would be the fastest way to access certain location on the device. Note, that ``dirs_to_skip`` still apply inside this directory. -* ``adb_command`` absolute or relative path to ``adb`` command. `~/` or +* ``adb_command`` absolute or relative path to ``adb`` command. ``~/`` or environment variables are allowed. * ``adb_connect`` specifies if connection to specific device needs to be performed before accessing shell. It is useful for *adb over network* feature. Typical value here is a device IP address with optional port, which defaults to 5555. +* ``try_su`` specifies whether or not to try to detect if ``su`` command is + available and usable. Contribution @@ -103,6 +105,9 @@ Contribution There is a ``Makefile`` in the top directory, which is basic helper for running the tests. Please use it, and adapt/add tests for provided fixes/functionality. +The reason why `tox`_ wasn't used is, that there is no ``setup.py`` file, and +it's difficult to install simple script, which isn't a python module (python +interpreter will refuse to import module without ``.py`` extension). It requires GNU ``make`` program, and also ``virtualenv`` besides Python in version 2 and 3. Using it is simple as running following command: @@ -150,3 +155,5 @@ License This software is licensed under 3-clause BSD license. See LICENSE file for details. + +.. _tox: https://tox.readthedocs.io diff --git a/adbfs b/adbfs index 4f34c69..f1ca742 100755 --- a/adbfs +++ b/adbfs @@ -200,7 +200,8 @@ class Conf(object): 'suppress_colors': (cfg.get, 'suppress_colors'), 'root': (cfg.get, 'root'), 'adb_command': (cfg.get, 'adb_command'), - 'adb_connect': (cfg.get, 'adb_connect')} + 'adb_connect': (cfg.get, 'adb_connect'), + 'try_su': (cfg.getboolean, 'try_su')} cfg.read(conf_fname) for key, (function, attr) in cfg_map.items(): @@ -340,7 +341,8 @@ class Adb(object): self._links = {} self._got_root = False - self.__su_check() + if self.conf.try_su: + self.__su_check() def _shell_cmd(self, with_root, *args): cmd = [self.conf.adb_command, 'shell']