mirror of
https://github.com/gryf/mc_adbfs.git
synced 2025-12-18 12:00:19 +01:00
Fix for removing files with space/parentheses.
Also, some further py2 cleanup.
This commit is contained in:
15
Makefile
15
Makefile
@@ -1,22 +1,17 @@
|
||||
# simple makefile for running tests for the adbfs plugin
|
||||
|
||||
all: test_dir py2 py3 flake8
|
||||
all: test_dir py3 flake8
|
||||
|
||||
TEST_DIR='.test'
|
||||
PY2_VENV=$(TEST_DIR)/py2
|
||||
PY3_VENV=$(TEST_DIR)/py3
|
||||
FL8_VENV=$(TEST_DIR)/flake8
|
||||
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)
|
||||
FL8_EXISTS=$(shell [ -e $(FL8_VENV) ] && echo 1 || echo 0)
|
||||
|
||||
py3: test_dir virtualenv3
|
||||
.test/py3/bin/python test_adbfs.py
|
||||
|
||||
py2: test_dir virtualenv2
|
||||
.test/py2/bin/python test_adbfs.py
|
||||
|
||||
flake8: test_dir virtualenv_flake8
|
||||
.test/flake8/bin/flake8 adbfs test_adbfs.py
|
||||
|
||||
@@ -35,14 +30,6 @@ else
|
||||
virtualenv3:
|
||||
endif
|
||||
|
||||
ifeq ($(PY2_EXISTS), 0)
|
||||
virtualenv2:
|
||||
virtualenv -p python2 $(PY2_VENV)
|
||||
$(PY2_VENV)/bin/pip install mock
|
||||
else
|
||||
virtualenv2:
|
||||
endif
|
||||
|
||||
ifeq ($(FL8_EXISTS), 0)
|
||||
virtualenv_flake8:
|
||||
virtualenv -p python2 $(FL8_VENV)
|
||||
|
||||
12
README.rst
12
README.rst
@@ -109,26 +109,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
|
||||
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:
|
||||
It requires GNU ``make`` program, and also ``virtualenv``. Using it is simple
|
||||
as running following command:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ 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:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ make py3
|
||||
|
||||
or Python 2:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
$ make py2
|
||||
|
||||
or flake 8:
|
||||
|
||||
.. code:: shell-session
|
||||
|
||||
6
adbfs
6
adbfs
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/env python
|
||||
#! /usr/bin/env python3
|
||||
"""
|
||||
adbfs Virtual filesystem for Midnight Commander
|
||||
|
||||
@@ -15,7 +15,7 @@ import subprocess
|
||||
import sys
|
||||
import shlex
|
||||
|
||||
__version__ = 0.13
|
||||
__version__ = 0.14
|
||||
|
||||
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
|
||||
|
||||
@@ -572,7 +572,7 @@ class Adb(object):
|
||||
sys.stderr.write(self.error)
|
||||
return 10
|
||||
|
||||
cmd = self._shell_cmd(False, 'rm', dst)
|
||||
cmd = self._shell_cmd(False, 'rm %s' % shlex.quote(dst))
|
||||
try:
|
||||
err = check_output(cmd).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'adbfs')
|
||||
|
||||
try:
|
||||
from importlib.util import spec_from_loader, module_from_spec
|
||||
from importlib.machinery import SourceFileLoader
|
||||
spec = spec_from_loader("adbfs", SourceFileLoader("adbfs", FILE))
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
|
||||
module_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'adbfs')
|
||||
spec = spec_from_loader("adbfs", SourceFileLoader("adbfs", module_path))
|
||||
adbfs = module_from_spec(spec)
|
||||
spec.loader.exec_module(adbfs)
|
||||
except ImportError:
|
||||
# py27
|
||||
import imp
|
||||
adbfs = imp.load_source('adbfs', FILE)
|
||||
|
||||
LISTING = '''\
|
||||
-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
|
||||
returns bytes object, which is equvalend for py2 string… annoying.
|
||||
"""
|
||||
if six.PY3:
|
||||
out.return_value = bytes(LISTING, 'utf-8')
|
||||
else:
|
||||
out.return_value = LISTING
|
||||
result = adbfs.check_output(None)
|
||||
self.assertEqual(result, LISTING)
|
||||
|
||||
@@ -57,9 +45,6 @@ class TestCheckOutput(unittest.TestCase):
|
||||
Special case for py3. We have bytes with some weird character - like
|
||||
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 '
|
||||
b'/storage/emulated/0/\xe2\n') # Latin 1 char â
|
||||
out.return_value = bytes(line)
|
||||
|
||||
Reference in New Issue
Block a user