1
0
mirror of https://github.com/gryf/mc_adbfs.git synced 2025-12-19 12:28:15 +01:00

Drop Python2 support.

This commit is contained in:
2020-04-26 09:16:59 +02:00
parent f7a6b145fd
commit 390f1b1112
2 changed files with 13 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ This is Midnight Commander extfs plugin for browsing Android device through
Rquirements Rquirements
=========== ===========
* Python 2.7 or 3.x (tested on 3.5.4) * Python 3.x (tested on 3.5.4, 3.6 and 3.7)
* ``adb`` installed and in ``$PATH`` or provided via the config file * ``adb`` installed and in ``$PATH`` or provided via the config file
* An Android device or emulator preferably rooted * An Android device or emulator preferably rooted
* ``busybox`` (``toolbox``, ``toybox``) installed and available in the path on * ``busybox`` (``toolbox``, ``toybox``) installed and available in the path on

23
adbfs
View File

@@ -5,9 +5,6 @@ adbfs Virtual filesystem for Midnight Commander
* Copyright (c) 2016, Roman Dobosz, * Copyright (c) 2016, Roman Dobosz,
* Published under 3-clause BSD-style license (see LICENSE file) * Published under 3-clause BSD-style license (see LICENSE file)
""" """
try:
import ConfigParser as configparser
except ImportError:
import configparser import configparser
import argparse import argparse
from datetime import datetime from datetime import datetime
@@ -17,12 +14,8 @@ import re
import subprocess import subprocess
import sys import sys
import shlex import shlex
try:
from shlex import quote
except ImportError:
from pipes import quote
__version__ = 0.12 __version__ = 0.13
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config')) XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
@@ -348,8 +341,8 @@ class Adb(object):
cmd = [self.conf.adb_command, 'shell'] cmd = [self.conf.adb_command, 'shell']
if with_root and self._got_root: if with_root and self._got_root:
_args = [quote(x) for x in args] _args = [shlex.quote(x) for x in args]
cmd += ['su', '-c', quote(' '.join(_args))] cmd += ['su', '-c', shlex.quote(' '.join(_args))]
else: else:
cmd += args cmd += args
@@ -407,7 +400,7 @@ class Adb(object):
def _retrieve_single_dir_list(self, dir_): def _retrieve_single_dir_list(self, dir_):
"""Retrieve file list using adb""" """Retrieve file list using adb"""
lscmd = self.conf.box['rls'].format(quote(dir_)) lscmd = self.conf.box['rls'].format(shlex.quote(dir_))
command = self._shell_cmd(True, *shlex.split(lscmd)) command = self._shell_cmd(True, *shlex.split(lscmd))
try: try:
@@ -597,7 +590,7 @@ class Adb(object):
sys.stderr.write(self.error) sys.stderr.write(self.error)
return 13 return 13
cmd = self._shell_cmd(False, 'rm -r %s' % quote(dst)) cmd = self._shell_cmd(False, 'rm -r %s' % shlex.quote(dst))
try: try:
err = check_output(cmd).strip() err = check_output(cmd).strip()
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@@ -618,7 +611,7 @@ class Adb(object):
if not dst.startswith('/'): if not dst.startswith('/'):
dst = '/' + dst dst = '/' + dst
cmd = self._shell_cmd(False, 'mkdir %s' % quote(dst)) cmd = self._shell_cmd(False, 'mkdir %s' % shlex.quote(dst))
try: try:
err = check_output(cmd).strip() err = check_output(cmd).strip()
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@@ -686,7 +679,11 @@ def main():
args = parser.parse_args() args = parser.parse_args()
try:
return args.func(args) return args.func(args)
except AttributeError:
parser.print_help()
parser.exit()
if __name__ == '__main__': if __name__ == '__main__':