From 57509eaac060f554bb63a68e805c10127b4fa96f Mon Sep 17 00:00:00 2001 From: gryf Date: Thu, 6 Oct 2016 14:14:28 +0200 Subject: [PATCH 1/2] Added option for suppressing colors for ls command from busybox --- README.rst | 4 ++++ adbfs | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 63d749a..20b9bb5 100644 --- a/README.rst +++ b/README.rst @@ -65,6 +65,7 @@ You can use configure behaviour of this plugin using ``.ini`` file located under debug = false skip_dirs = true dirs_to_skip = ["acct", "charger", "d", "dev", "proc", "sys"] + suppress_colors = false root = where: @@ -74,6 +75,9 @@ where: * ``dirs_to_skip`` list of paths to directories which will be skipped during reading. If leaved empty, or setted to empty list (``[]``) will read everything (slow!) +* ``suppress_colors`` this option will make ``busybox`` not to display colors, + helpful, if ``busybox ls`` is configured to display colors by default. Does + not affect ``toolbox``. * ``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. diff --git a/adbfs b/adbfs index 5cb0450..6523aaa 100755 --- a/adbfs +++ b/adbfs @@ -48,17 +48,17 @@ class Conf(object): r'(?P\d+)?\s' r'(?P\d{4}-\d{2}-\d{2}\s' r'\d{2}:\d{2})\s' - r'(?P.*)'} - } + r'(?P.*)'}} def __init__(self): self.box = None self.debug = False self.dirs_to_skip = ["acct", "charger", "d", "dev", "proc", "sys"] self.root = None + self.suppress_colors = False - self.get_the_box() self.read() + self.get_the_box() def get_the_box(self): """Detect if we dealing with busybox or toolbox""" @@ -67,9 +67,12 @@ class Conf(object): result = subprocess.check_output('adb shell which ' 'busybox'.split(), stderr=fnull) - if 'busybox' in result: self.box = Conf.boxes['busybox'] + if self.suppress_colors: + self.box.update({'ls': 'busybox ls --color=none -anel', + 'rls': 'busybox ls --color=none ' + '-Ranel {}'}) Adb.file_re = re.compile(self.box['file_re']) return except subprocess.CalledProcessError: @@ -106,6 +109,7 @@ class Conf(object): cfg = ConfigParser.SafeConfigParser() cfg_map = {'debug': (cfg.getboolean, 'debug'), 'dirs_to_skip': (cfg.get, 'dirs_to_skip'), + 'suppress_colors': (cfg.get, 'suppress_colors'), 'root': (cfg.get, 'root')} cfg.read(conf_fname) From b2163e0fba0ed5e1c7c90746bc40ef081ab7c31b Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Thu, 6 Oct 2016 18:51:52 +0200 Subject: [PATCH 2/2] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 20b9bb5..1308e37 100644 --- a/README.rst +++ b/README.rst @@ -55,7 +55,7 @@ your device and how fast it is :) Configuration ============= -You can use configure behaviour of this plugin using ``.ini`` file located under +You can configure behaviour of this plugin using ``.ini`` file located under ``$XDG_CONFIG_HOME/mc/adbfs.ini`` (which usually is located under ``~/.config/mc/adbfs.ini``), and have default values, like: