summaryrefslogtreecommitdiffstats
path: root/src/vfs/extfs/helpers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:11:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:11:49 +0000
commit1b88cd5ee8510e90e69f885bfd730ce57621781c (patch)
treeb6b33bd695258f68c68824029c279d660ee4b85e /src/vfs/extfs/helpers
parentAdding upstream version 3:4.8.30. (diff)
downloadmc-1b88cd5ee8510e90e69f885bfd730ce57621781c.tar.xz
mc-1b88cd5ee8510e90e69f885bfd730ce57621781c.zip
Adding upstream version 3:4.8.31.upstream/3%4.8.31upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/vfs/extfs/helpers')
-rw-r--r--src/vfs/extfs/helpers/Makefile.in2
-rw-r--r--src/vfs/extfs/helpers/iso9660.in1
-rw-r--r--src/vfs/extfs/helpers/lslR.in1
-rw-r--r--src/vfs/extfs/helpers/mailfs.in3
-rw-r--r--src/vfs/extfs/helpers/patchfs.in5
-rw-r--r--src/vfs/extfs/helpers/s3+.in18
-rw-r--r--[-rwxr-xr-x]src/vfs/extfs/helpers/uc1541152
7 files changed, 56 insertions, 126 deletions
diff --git a/src/vfs/extfs/helpers/Makefile.in b/src/vfs/extfs/helpers/Makefile.in
index 0a240fb..95e5375 100644
--- a/src/vfs/extfs/helpers/Makefile.in
+++ b/src/vfs/extfs/helpers/Makefile.in
@@ -135,7 +135,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-sfs.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-ftp.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-sftp.m4 \
- $(top_srcdir)/m4.include/vfs/mc-vfs-fish.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-shell.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-undelfs.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-tarfs.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-cpiofs.m4 \
diff --git a/src/vfs/extfs/helpers/iso9660.in b/src/vfs/extfs/helpers/iso9660.in
index 5a6f1d5..f78db61 100644
--- a/src/vfs/extfs/helpers/iso9660.in
+++ b/src/vfs/extfs/helpers/iso9660.in
@@ -132,6 +132,7 @@ mcisofs_list () {
*.lz) MYCAT="lzip -dc";;
*.lz4) MYCAT="lz4 -dc";;
*.lzma) MYCAT="lzma -dc";;
+ *.lzo) MYCAT="lzop -dc";;
*.xz) MYCAT="xz -dc";;
*.zst) MYCAT="zstd -dc";;
*.bz2) MYCAT="bzip2 -dc";;
diff --git a/src/vfs/extfs/helpers/lslR.in b/src/vfs/extfs/helpers/lslR.in
index 69b663b..f568c02 100644
--- a/src/vfs/extfs/helpers/lslR.in
+++ b/src/vfs/extfs/helpers/lslR.in
@@ -15,6 +15,7 @@ case "$1" in
*.lz) MYCAT="lzip -dc";;
*.lz4) MYCAT="lz4 -dc";;
*.lzma) MYCAT="lzma -dc";;
+ *.lzo) MYCAT="lzop -dc";;
*.xz) MYCAT="xz -dc";;
*.zst) MYCAT="zstd -dc";;
*.bz2) MYCAT="bzip2 -dc";;
diff --git a/src/vfs/extfs/helpers/mailfs.in b/src/vfs/extfs/helpers/mailfs.in
index 5bb373b..20cfae3 100644
--- a/src/vfs/extfs/helpers/mailfs.in
+++ b/src/vfs/extfs/helpers/mailfs.in
@@ -11,6 +11,7 @@ $bzcat="bzip2 -dc"; # bunzip2 to stdout
$lzipcat="lzip -dc"; # unlzip to stdout
$lz4cat="lz4 -dc"; # unlz4 to stdout
$lzcat="lzma -dc"; # unlzma to stdout
+$lzocat="lzop -dc"; # unlzo to stdout
$xzcat="xz -dc"; # unxz to stdout
$zstdcat="zstd -dc"; # unzstd to stdout
$file="file"; # "file" command
@@ -194,6 +195,8 @@ if (/gzip/) {
exit 1 unless (open IN, "$lz4cat $mbox_qname|");
} elsif (/lzma/) {
exit 1 unless (open IN, "$lzcat $mbox_qname|");
+} elsif (/lzo/) {
+ exit 1 unless (open IN, "$lzocat $mbox_qname|");
} elsif (/xz/) {
exit 1 unless (open IN, "$xzcat $mbox_qname|");
} elsif (/zst/) {
diff --git a/src/vfs/extfs/helpers/patchfs.in b/src/vfs/extfs/helpers/patchfs.in
index ee1e651..59fdde1 100644
--- a/src/vfs/extfs/helpers/patchfs.in
+++ b/src/vfs/extfs/helpers/patchfs.in
@@ -17,6 +17,7 @@ use File::Temp 'tempfile';
my $lzip = 'lzip';
my $lz4 = 'lz4';
my $lzma = 'lzma';
+my $lzo = 'lzop';
my $xz = 'xz';
my $zstd = 'zstd';
my $bzip = 'bzip2';
@@ -88,6 +89,8 @@ sub myin
return "$lzip -dc $qfname";
} elsif (/^'*lzma/) {
return "$lzma -dc $qfname";
+ } elsif (/^'*lzo/) {
+ return "$lzo -dc $qfname";
} elsif (/^'*xz/) {
return "$xz -dc $qfname";
} elsif (/^'*zst/) {
@@ -114,6 +117,8 @@ sub myout
return "$lzip -c $sep $qfname";
} elsif (/^'*lzma/) {
return "$lzma -c $sep $qfname";
+ } elsif (/^'*lzo/) {
+ return "$lzo -c $sep $qfname";
} elsif (/^'*xz/) {
return "$xz -c $sep $qfname";
} elsif (/^'*zst/) {
diff --git a/src/vfs/extfs/helpers/s3+.in b/src/vfs/extfs/helpers/s3+.in
index f5e4b90..6436ba7 100644
--- a/src/vfs/extfs/helpers/s3+.in
+++ b/src/vfs/extfs/helpers/s3+.in
@@ -153,16 +153,16 @@ def threadmap(fun, iterable, maxthreads=16):
Propagates exception safely.
"""
from threading import Thread
- import Queue
+ import queue
items = list(iterable)
nitems = len(items)
if nitems < 2:
- return map(fun, items)
+ return list(map(fun, items))
# Create and fill input queue
- input = Queue.Queue()
- output = Queue.Queue()
+ input = queue.Queue()
+ output = queue.Queue()
for i,item in enumerate(items):
input.put( (i,item) )
@@ -181,7 +181,7 @@ def threadmap(fun, iterable, maxthreads=16):
output.put( (i,result) )
except:
output.put( (None,sys.exc_info()) )
- except Queue.Empty:
+ except queue.Empty:
return
# Start threads
@@ -196,8 +196,8 @@ def threadmap(fun, iterable, maxthreads=16):
try:
i,res = output.get()
if i == None:
- raise res[0],res[1],res[2]
- except Queue.Empty:
+ raise res[0](res[1]).with_traceback(res[2])
+ except queue.Empty:
break
ret.append(res)
@@ -241,7 +241,7 @@ def get_bucket(name):
b = s3.get_bucket(name, validate=False)
b.get_location() # just to raise an exception on error
return b
- except boto.exception.S3ResponseError, e:
+ except boto.exception.S3ResponseError as e:
# Seems this is the only proper way to switch to the bucket's region.
# Requesting of the default region for "?location" does not work unfortunately.
m = re.search(r'<Region>(.*?)</Region>', e.body)
@@ -340,7 +340,7 @@ if cmd == 'list':
expr = re.compile(r'^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d{3}Z$')
def convDate(awsdatetime):
m = expr.match(awsdatetime)
- ye,mo,da,ho,mi,se = map(int,m.groups())
+ ye,mo,da,ho,mi,se = list(map(int,m.groups()))
dt = datetime.datetime(ye,mo,da,ho,mi,se, tzinfo=pytz.utc)
return dt.astimezone(tz).strftime('%m-%d-%Y %H:%M')
diff --git a/src/vfs/extfs/helpers/uc1541 b/src/vfs/extfs/helpers/uc1541
index dc15b42..abb86ea 100755..100644
--- a/src/vfs/extfs/helpers/uc1541
+++ b/src/vfs/extfs/helpers/uc1541
@@ -1,24 +1,25 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
UC1541 Virtual filesystem
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
-Date: 2019-09-20
-Version: 3.3
+Date: 2023-10-04
+Version: 3.6
Licence: BSD
source: https://bitbucket.org/gryf/uc1541
mirror: https://github.com/gryf/uc1541
"""
-
-import sys
-import re
-import os
+import argparse
import gzip
-from subprocess import Popen, PIPE
+import logging
+import os
+import re
+import subprocess
+import sys
+
+LOG = logging.getLogger('UC1541')
if os.getenv('UC1541_DEBUG'):
- import logging
- LOG = logging.getLogger('UC1541')
LOG.setLevel(logging.DEBUG)
FILE_HANDLER = logging.FileHandler("/tmp/uc1541.log")
FILE_FORMATTER = logging.Formatter("%(asctime)s %(levelname)-8s "
@@ -26,47 +27,11 @@ if os.getenv('UC1541_DEBUG'):
FILE_HANDLER.setFormatter(FILE_FORMATTER)
FILE_HANDLER.setLevel(logging.DEBUG)
LOG.addHandler(FILE_HANDLER)
-else:
- class LOG(object):
- """
- Dummy logger object. Does nothing.
- """
- @classmethod
- def debug(*args, **kwargs):
- pass
-
- @classmethod
- def info(*args, **kwargs):
- pass
-
- @classmethod
- def warning(*args, **kwargs):
- pass
-
- @classmethod
- def error(*args, **kwargs):
- pass
-
- @classmethod
- def critical(*args, **kwargs):
- pass
SECLEN = 256
-def _ord(string_or_int):
- """
- Return an int value for the (possible) string passed in argument. This
- function is for compatibility between python2 and python3, where single
- element in byte string array is a string or an int respectively.
- """
- try:
- return ord(string_or_int)
- except TypeError:
- return string_or_int
-
-
def _get_raw(dimage):
"""
Try to get contents of the D64 image either it's gzip compressed or not.
@@ -160,10 +125,10 @@ class Disk(object):
filename = list()
for chr_ in string:
- if _ord(chr_) == 160: # shift+space character; $a0
+ if chr_ == 160: # shift+space character; $a0
break
- character = D64.CHAR_MAP.get(_ord(chr_), '?')
+ character = D64.CHAR_MAP.get(chr_, '?')
filename.append(character)
# special cases
@@ -204,8 +169,8 @@ class Disk(object):
if not self.current_sector_data:
return False
- self.next_track = _ord(self.current_sector_data[0])
- self.next_sector = _ord(self.current_sector_data[1])
+ self.next_track = self.current_sector_data[0]
+ self.next_sector = self.current_sector_data[1]
if (self.next_track, self.next_sector) in self._already_done:
# Just a failsafe. Endless loop is not what is expected.
@@ -239,7 +204,7 @@ class Disk(object):
sector = self.current_sector_data
for dummy in range(8):
entry = sector[:32]
- ftype = _ord(entry[2])
+ ftype = entry[2]
if ftype == 0: # deleted
sector = sector[32:]
@@ -247,12 +212,12 @@ class Disk(object):
type_verbose = self._get_ftype(ftype)
- protect = _ord(entry[2]) & 64 and "<" or " "
+ protect = entry[2] & 64 and "<" or " "
fname = entry[5:21]
if ftype == 'rel':
- size = _ord(entry[23])
+ size = entry[23]
else:
- size = _ord(entry[30]) + _ord(entry[31]) * 226
+ size = entry[30] + entry[31] * 226
self._dir_contents.append({'fname': self._map_filename(fname),
'ftype': type_verbose,
@@ -392,7 +357,7 @@ class Uc1541(object):
"""
Class for interact with c1541 program and MC
"""
- PRG = re.compile(r'(\d+)\s+"([^"]*)".+?\s(del|prg|rel|seq|usr)([\s<])')
+ PRG = re.compile(r'(\d+)\s+"([^"]*)".+?(del|prg|rel|seq|usr)([\s<])')
def __init__(self, archname):
self.arch = archname
@@ -430,11 +395,7 @@ class Uc1541(object):
"""
LOG.info("Removing file %s", dst)
dst = self._get_masked_fname(dst)
-
- if not self._call_command('delete', dst=dst):
- return self._show_error()
-
- return 0
+ return self._call_command('delete', dst=dst)
def copyin(self, dst, src):
"""
@@ -442,11 +403,7 @@ class Uc1541(object):
"""
LOG.info("Copy into D64 %s as %s", src, dst)
dst = self._correct_fname(dst)
-
- if not self._call_command('write', src=src, dst=dst):
- return self._show_error()
-
- return 0
+ return self._call_command('write', src=src, dst=dst)
def copyout(self, src, dst):
"""
@@ -459,10 +416,7 @@ class Uc1541(object):
src = self._get_masked_fname(src)
- if not self._call_command('read', src=src, dst=dst):
- return self._show_error()
-
- return 0
+ return self._call_command('read', src=src, dst=dst)
def mkdir(self, dirname):
"""Not supported"""
@@ -523,8 +477,9 @@ class Uc1541(object):
uid = os.getuid()
gid = os.getgid()
- if not self._call_command('list'):
- return self._show_error()
+ res = self._call_command('list')
+ if res != 0:
+ return res
idx = 0
for line in self.out.split("\n"):
@@ -540,7 +495,7 @@ class Uc1541(object):
if '/' in display_name:
display_name = display_name.replace('/', '|')
- # workaround for space and dash at the beginning of the
+ # workaround for space and dash at the beggining of the
# filename
char_map = {' ': '~',
'-': '_'}
@@ -593,13 +548,16 @@ class Uc1541(object):
universal_newlines = True
if cmd in ['delete', 'write']:
universal_newlines = False
- self.out, self.err = Popen(command,
- universal_newlines=universal_newlines,
- stdout=PIPE, stderr=PIPE).communicate()
+ (self.out,
+ self.err) = subprocess.Popen(command,
+ universal_newlines=universal_newlines,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).communicate()
if self.err:
LOG.debug('an err: %s', self.err)
- return not self.err
+ return self._show_error()
+ return 0
CALL_MAP = {'list': lambda a: Uc1541(a.arch).list(),
@@ -612,7 +570,7 @@ CALL_MAP = {'list': lambda a: Uc1541(a.arch).list(),
def parse_args():
"""Use ArgumentParser to check for script arguments and execute."""
- parser = ArgumentParser()
+ parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(help='supported commands',
dest='subcommand')
subparsers.required = True
@@ -659,44 +617,6 @@ def parse_args():
return args.func(args)
-def no_parse():
- """Failsafe argument "parsing". Note, that it blindly takes positional
- arguments without checking them. In case of wrong arguments it will
- silently exit"""
- try:
- if sys.argv[1] not in ('list', 'copyin', 'copyout', 'rm', 'mkdir',
- "run"):
- sys.exit(2)
- except IndexError:
- sys.exit(2)
-
- class Arg(object):
- """Mimic argparse object"""
- dst = None
- src = None
- arch = None
-
- arg = Arg()
-
- try:
- arg.arch = sys.argv[2]
- if sys.argv[1] in ('copyin', 'copyout'):
- arg.src = sys.argv[3]
- arg.dst = sys.argv[4]
- elif sys.argv[1] in ('rm', 'run', 'mkdir'):
- arg.dst = sys.argv[3]
- except IndexError:
- sys.exit(2)
-
- return CALL_MAP[sys.argv[1]](arg)
-
-
if __name__ == "__main__":
LOG.debug("Script params: %s", str(sys.argv))
- try:
- from argparse import ArgumentParser
- PARSE_FUNC = parse_args
- except ImportError:
- PARSE_FUNC = no_parse
-
- sys.exit(PARSE_FUNC())
+ sys.exit(parse_args())