mirror of
https://github.com/gryf/mc_adbfs.git
synced 2026-03-26 21:43:30 +01:00
Compare commits
11 Commits
0.13
...
cbef13ccea
| Author | SHA1 | Date | |
|---|---|---|---|
| cbef13ccea | |||
|
|
9cfa834604 | ||
| b1a6219d21 | |||
| d16f0f06b8 | |||
| c2f07f5516 | |||
| e9b196eaf8 | |||
| 039c078a35 | |||
| 2776668913 | |||
|
|
b088c45d3f | ||
|
|
c5559f7d41 | ||
|
|
9ffa1a13af |
15
Makefile
15
Makefile
@@ -1,22 +1,17 @@
|
|||||||
# simple makefile for running tests for the adbfs plugin
|
# simple makefile for running tests for the adbfs plugin
|
||||||
|
|
||||||
all: test_dir py2 py3 flake8
|
all: test_dir py3 flake8
|
||||||
|
|
||||||
TEST_DIR='.test'
|
TEST_DIR='.test'
|
||||||
PY2_VENV=$(TEST_DIR)/py2
|
|
||||||
PY3_VENV=$(TEST_DIR)/py3
|
PY3_VENV=$(TEST_DIR)/py3
|
||||||
FL8_VENV=$(TEST_DIR)/flake8
|
FL8_VENV=$(TEST_DIR)/flake8
|
||||||
TST_EXISTS=$(shell [ -e $(TEST_DIR) ] && echo 1 || echo 0)
|
TST_EXISTS=$(shell [ -e $(TEST_DIR) ] && echo 1 || echo 0)
|
||||||
PY2_EXISTS=$(shell [ -e $(PY2_VENV) ] && echo 1 || echo 0)
|
|
||||||
PY3_EXISTS=$(shell [ -e $(PY3_VENV) ] && echo 1 || echo 0)
|
PY3_EXISTS=$(shell [ -e $(PY3_VENV) ] && echo 1 || echo 0)
|
||||||
FL8_EXISTS=$(shell [ -e $(FL8_VENV) ] && echo 1 || echo 0)
|
FL8_EXISTS=$(shell [ -e $(FL8_VENV) ] && echo 1 || echo 0)
|
||||||
|
|
||||||
py3: test_dir virtualenv3
|
py3: test_dir virtualenv3
|
||||||
.test/py3/bin/python test_adbfs.py
|
.test/py3/bin/python test_adbfs.py
|
||||||
|
|
||||||
py2: test_dir virtualenv2
|
|
||||||
.test/py2/bin/python test_adbfs.py
|
|
||||||
|
|
||||||
flake8: test_dir virtualenv_flake8
|
flake8: test_dir virtualenv_flake8
|
||||||
.test/flake8/bin/flake8 adbfs test_adbfs.py
|
.test/flake8/bin/flake8 adbfs test_adbfs.py
|
||||||
|
|
||||||
@@ -35,14 +30,6 @@ else
|
|||||||
virtualenv3:
|
virtualenv3:
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PY2_EXISTS), 0)
|
|
||||||
virtualenv2:
|
|
||||||
virtualenv -p python2 $(PY2_VENV)
|
|
||||||
$(PY2_VENV)/bin/pip install mock
|
|
||||||
else
|
|
||||||
virtualenv2:
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(FL8_EXISTS), 0)
|
ifeq ($(FL8_EXISTS), 0)
|
||||||
virtualenv_flake8:
|
virtualenv_flake8:
|
||||||
virtualenv -p python2 $(FL8_VENV)
|
virtualenv -p python2 $(FL8_VENV)
|
||||||
|
|||||||
13
README.rst
13
README.rst
@@ -76,6 +76,7 @@ You can configure behaviour of this plugin using ``.ini`` file located under
|
|||||||
root =
|
root =
|
||||||
adb_command = adb
|
adb_command = adb
|
||||||
adb_connect =
|
adb_connect =
|
||||||
|
try_su = false
|
||||||
|
|
||||||
where:
|
where:
|
||||||
|
|
||||||
@@ -109,26 +110,20 @@ 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
|
it's difficult to install simple script, which isn't a python module (python
|
||||||
interpreter will refuse to import module without ``.py`` extension).
|
interpreter will refuse to import module without ``.py`` extension).
|
||||||
|
|
||||||
It requires GNU ``make`` program, and also ``virtualenv`` besides Python in
|
It requires GNU ``make`` program, and also ``virtualenv``. Using it is simple
|
||||||
version 2 and 3. Using it is simple as running following command:
|
as running following command:
|
||||||
|
|
||||||
.. code:: shell-session
|
.. code:: shell-session
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
it will run `py2`, `py3` and `flake8` jobs to check it against the code. For
|
it will run `py3` and `flake8` jobs to check it against the code. For
|
||||||
running tests against Python 3:
|
running tests against Python 3:
|
||||||
|
|
||||||
.. code:: shell-session
|
.. code:: shell-session
|
||||||
|
|
||||||
$ make py3
|
$ make py3
|
||||||
|
|
||||||
or Python 2:
|
|
||||||
|
|
||||||
.. code:: shell-session
|
|
||||||
|
|
||||||
$ make py2
|
|
||||||
|
|
||||||
or flake 8:
|
or flake 8:
|
||||||
|
|
||||||
.. code:: shell-session
|
.. code:: shell-session
|
||||||
|
|||||||
13
adbfs
13
adbfs
@@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
adbfs Virtual filesystem for Midnight Commander
|
adbfs Virtual filesystem for Midnight Commander
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
__version__ = 0.13
|
__version__ = 0.14
|
||||||
|
|
||||||
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
|
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
|
||||||
|
|
||||||
@@ -80,6 +80,7 @@ class Conf(object):
|
|||||||
self.suppress_colors = False
|
self.suppress_colors = False
|
||||||
self.adb_command = 'adb'
|
self.adb_command = 'adb'
|
||||||
self.adb_connect = ''
|
self.adb_connect = ''
|
||||||
|
self.try_su = False
|
||||||
|
|
||||||
self.read()
|
self.read()
|
||||||
self.connect()
|
self.connect()
|
||||||
@@ -187,7 +188,7 @@ class Conf(object):
|
|||||||
if not os.path.exists(conf_fname):
|
if not os.path.exists(conf_fname):
|
||||||
return
|
return
|
||||||
|
|
||||||
cfg = configparser.SafeConfigParser()
|
cfg = configparser.ConfigParser()
|
||||||
cfg_map = {'debug': (cfg.getboolean, 'debug'),
|
cfg_map = {'debug': (cfg.getboolean, 'debug'),
|
||||||
'dirs_to_skip': (cfg.get, 'dirs_to_skip'),
|
'dirs_to_skip': (cfg.get, 'dirs_to_skip'),
|
||||||
'suppress_colors': (cfg.get, 'suppress_colors'),
|
'suppress_colors': (cfg.get, 'suppress_colors'),
|
||||||
@@ -204,7 +205,7 @@ class Conf(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if self.dirs_to_skip and isinstance(self.dirs_to_skip, str):
|
if self.dirs_to_skip and isinstance(self.dirs_to_skip, str):
|
||||||
self.dirs_to_skip = json.loads(self.dirs_to_skip, encoding='ascii')
|
self.dirs_to_skip = json.loads(self.dirs_to_skip)
|
||||||
self.dirs_to_skip = [x.encode('utf-8') for x in self.dirs_to_skip]
|
self.dirs_to_skip = [x.encode('utf-8') for x in self.dirs_to_skip]
|
||||||
else:
|
else:
|
||||||
self.dirs_to_skip = []
|
self.dirs_to_skip = []
|
||||||
@@ -458,7 +459,7 @@ class Adb(object):
|
|||||||
if not root:
|
if not root:
|
||||||
lscmd = self.conf.box['ls']
|
lscmd = self.conf.box['ls']
|
||||||
else:
|
else:
|
||||||
lscmd = self.conf.box['rls'].format(shlex.quite(root.filepath))
|
lscmd = self.conf.box['rls'].format(shlex.quote(root.filepath))
|
||||||
|
|
||||||
command = self._shell_cmd(True, *shlex.split(lscmd))
|
command = self._shell_cmd(True, *shlex.split(lscmd))
|
||||||
|
|
||||||
@@ -572,7 +573,7 @@ class Adb(object):
|
|||||||
sys.stderr.write(self.error)
|
sys.stderr.write(self.error)
|
||||||
return 10
|
return 10
|
||||||
|
|
||||||
cmd = self._shell_cmd(False, 'rm', dst)
|
cmd = self._shell_cmd(False, 'rm %s' % shlex.quote(dst))
|
||||||
try:
|
try:
|
||||||
err = check_output(cmd).strip()
|
err = check_output(cmd).strip()
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
|||||||
@@ -1,24 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import six
|
from importlib.util import spec_from_loader, module_from_spec
|
||||||
|
from importlib.machinery import SourceFileLoader
|
||||||
import unittest
|
import unittest
|
||||||
try:
|
from unittest import mock
|
||||||
from unittest import mock
|
|
||||||
except ImportError:
|
|
||||||
import mock
|
|
||||||
|
|
||||||
FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'adbfs')
|
|
||||||
|
|
||||||
try:
|
module_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'adbfs')
|
||||||
from importlib.util import spec_from_loader, module_from_spec
|
spec = spec_from_loader("adbfs", SourceFileLoader("adbfs", module_path))
|
||||||
from importlib.machinery import SourceFileLoader
|
adbfs = module_from_spec(spec)
|
||||||
spec = spec_from_loader("adbfs", SourceFileLoader("adbfs", FILE))
|
spec.loader.exec_module(adbfs)
|
||||||
adbfs = module_from_spec(spec)
|
|
||||||
spec.loader.exec_module(adbfs)
|
|
||||||
except ImportError:
|
|
||||||
# py27
|
|
||||||
import imp
|
|
||||||
adbfs = imp.load_source('adbfs', FILE)
|
|
||||||
|
|
||||||
LISTING = '''\
|
LISTING = '''\
|
||||||
-rw-rw---- 1 0 1015 0 01/01/2010 22:11:01 /storage/emulated/0/Grüß Gott
|
-rw-rw---- 1 0 1015 0 01/01/2010 22:11:01 /storage/emulated/0/Grüß Gott
|
||||||
@@ -44,10 +35,7 @@ class TestCheckOutput(unittest.TestCase):
|
|||||||
Python3 treats string as unicode objects, but subprocess.check_output
|
Python3 treats string as unicode objects, but subprocess.check_output
|
||||||
returns bytes object, which is equvalend for py2 string… annoying.
|
returns bytes object, which is equvalend for py2 string… annoying.
|
||||||
"""
|
"""
|
||||||
if six.PY3:
|
|
||||||
out.return_value = bytes(LISTING, 'utf-8')
|
out.return_value = bytes(LISTING, 'utf-8')
|
||||||
else:
|
|
||||||
out.return_value = LISTING
|
|
||||||
result = adbfs.check_output(None)
|
result = adbfs.check_output(None)
|
||||||
self.assertEqual(result, LISTING)
|
self.assertEqual(result, LISTING)
|
||||||
|
|
||||||
@@ -57,9 +45,6 @@ class TestCheckOutput(unittest.TestCase):
|
|||||||
Special case for py3. We have bytes with some weird character - like
|
Special case for py3. We have bytes with some weird character - like
|
||||||
some system write something with codepage, instead of utf8.
|
some system write something with codepage, instead of utf8.
|
||||||
"""
|
"""
|
||||||
if six.PY2:
|
|
||||||
# doesn't affect Python 2
|
|
||||||
return
|
|
||||||
line = (b'-rw-rw---- 1 0 1015 0 01/01/2010 22:11:01 '
|
line = (b'-rw-rw---- 1 0 1015 0 01/01/2010 22:11:01 '
|
||||||
b'/storage/emulated/0/\xe2\n') # Latin 1 char â
|
b'/storage/emulated/0/\xe2\n') # Latin 1 char â
|
||||||
out.return_value = bytes(line)
|
out.return_value = bytes(line)
|
||||||
|
|||||||
Reference in New Issue
Block a user