Moved common attributes to extfslib, uadf now will complain on nodos or

corrupted images.
This commit is contained in:
2013-05-16 22:25:28 +02:00
parent c8407ff57b
commit ffb99d6515
4 changed files with 25 additions and 10 deletions

View File

@@ -79,7 +79,7 @@ disk images. Due to limitations of the
`unadf <http://freecode.com/projects/unadf>`_, file access inside disk image is `unadf <http://freecode.com/projects/unadf>`_, file access inside disk image is
read only. read only.
Note, that in case of no-dos images, directory listing will be empty. In case of corrupted or no-dos images, message will be shown.
Requirements Requirements
------------ ------------

View File

@@ -5,11 +5,12 @@ plugins for Midnight Commander.
Tested against python 2.7 and mc 4.8.7 Tested against python 2.7 and mc 4.8.7
Changelog: Changelog:
1.1 Added item pattern, and common git/uid attrs
1.0 Initial release 1.0 Initial release
Author: Roman 'gryf' Dobosz <gryf73@gmail.com> Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2013-05-12 Date: 2013-05-12
Version: 1.0 Version: 1.1
Licence: BSD Licence: BSD
""" """
import os import os
@@ -32,11 +33,15 @@ class Archive(object):
"read": "r", "read": "r",
"write": "w", "write": "w",
"delete": "d"} "delete": "d"}
ITEM = ("%(perms)s 1 %(uid)-8s %(gid)-8s %(size)8s %(datetime)s "
"%(display_name)s\n")
def __init__(self, fname): def __init__(self, fname):
"""Prepare archive content for operations""" """Prepare archive content for operations"""
if not os.path.exists(fname): if not os.path.exists(fname):
raise OSError("No such file or directory `%s'" % fname) raise OSError("No such file or directory `%s'" % fname)
self._uid = os.getuid()
self._gid = os.getgid()
self._arch = fname self._arch = fname
self._contents = self._get_dir() self._contents = self._get_dir()

17
uadf
View File

@@ -18,12 +18,13 @@ if comment or filename already contains any comma.
It also requires xdms utility, for optional dms support. It also requires xdms utility, for optional dms support.
Changelog: Changelog:
1.2 Added failsafe for filenames in archive with spaces and nodos message.
1.1 Moved common code into extfslib library 1.1 Moved common code into extfslib library
1.0 Initial release 1.0 Initial release
Author: Roman 'gryf' Dobosz <gryf73@gmail.com> Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2013-05-12 Date: 2013-05-16
Version: 1.1 Version: 1.2
Licence: BSD Licence: BSD
""" """
@@ -53,8 +54,6 @@ class UAdf(Archive):
"write": "w", "write": "w",
"delete": "d"} "delete": "d"}
DATETIME = "%s-%s-%s %02d:%s" DATETIME = "%s-%s-%s %02d:%s"
ITEM = ("%(perms)s 1 %(uid)-8s %(gid)-8s %(size)8s %(datetime)s "
"%(display_name)s\n")
def __init__(self, fname): def __init__(self, fname):
"""Prepare archive content for operations""" """Prepare archive content for operations"""
@@ -141,6 +140,10 @@ class UAdf(Archive):
Convert filenames to be Unix filesystem friendly Convert filenames to be Unix filesystem friendly
Add suffix to show user what kind of file do he dealing with. Add suffix to show user what kind of file do he dealing with.
""" """
if not self._contents:
sys.stderr.write("Nodos or archive error\n")
return 1
for entry in self._contents: for entry in self._contents:
sys.stdout.write(self.ITEM % entry) sys.stdout.write(self.ITEM % entry)
return 0 return 0
@@ -151,6 +154,12 @@ class UAdf(Archive):
if not real_src: if not real_src:
raise IOError("No such file or directory") raise IOError("No such file or directory")
if " " in real_src:
sys.stderr.write("unadf is unable to operate on filepath with "
"space inside.\nUse affs to mount image and than"
" extract desired files.\n")
return 1
extract_dir = mkdtemp() extract_dir = mkdtemp()
cmd = ["unadf", self._arch, real_src, "-d", extract_dir] cmd = ["unadf", self._arch, real_src, "-d", extract_dir]
if check_call(cmd, stdout=open(os.devnull, 'wb'), if check_call(cmd, stdout=open(os.devnull, 'wb'),

9
ulha
View File

@@ -7,12 +7,13 @@ Tested against python 2.7, lha[1] 1.14 and mc 4.8.7
[1] http://lha.sourceforge.jp [1] http://lha.sourceforge.jp
Changelog: Changelog:
1.2 Moved item pattern to extfslib module
1.1 Moved common code into extfslib library 1.1 Moved common code into extfslib library
1.0 Initial release 1.0 Initial release
Author: Roman 'gryf' Dobosz <gryf73@gmail.com> Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2013-05-12 Date: 2013-05-16
Version: 1.1 Version: 1.2
Licence: BSD Licence: BSD
""" """
import os import os
@@ -43,8 +44,7 @@ class ULha(Archive):
"read": "pq", "read": "pq",
"write": "aq", "write": "aq",
"delete": "dq"} "delete": "dq"}
ITEM = ("%(perms)s 1 %(uid)-8s %(gid)-8s %(size)8s %(month)s %(day)s " DATETIME = "%(month)s %(day)s %(yh)s"
"%(yh)s %(display_name)s\n")
def _get_dir(self): def _get_dir(self):
"""Prepare archive file listing""" """Prepare archive file listing"""
@@ -72,6 +72,7 @@ class ULha(Archive):
# really care about real user/group # really care about real user/group
entry['uid'] = self._uid entry['uid'] = self._uid
entry['gid'] = self._gid entry['gid'] = self._gid
entry['datetime'] = self.DATETIME % entry
if not entry['perms']: if not entry['perms']:
entry['perms'] = perms entry['perms'] = perms