Browse Source

Added SimonC failing UID fix

git-svn-id: svn+ssh://code.jive.eu/code/svn/vbs_fs@61 5b2df0cb-e17b-44c8-90c8-480d528b6e0d
master
Harro Verkouter 4 months ago
parent
commit
fd5c8260f0
1 changed files with 11 additions and 2 deletions
  1. +11
    -2
      vbs_ls

+ 11
- 2
vbs_ls View File

@@ -12,6 +12,15 @@ vbs_chunk = lambda recording: re.compile(r"^"+re.escape(recording)+r"\.(?
description = """List FlexBuff/Mark6 recording details, much like ls(1), allowing for filtering and/or sorting by size and/or time. In addition %(prog)s can accumulate totals (sizes) per pattern, e.g. to compute total size per experiment. By default vbs_ls searches the FlexBuff mountpoints for recordings. Using the '-6' flag and/or the '-R' argument (see below) the search path may be altered. Shell-style wildcards on the -R arguments are supported.
"""

# SimonC: "KeyError: 'getpwuid(): uid not found: 5000' If the user id doesn't exist"
def lookup_or_bust(resolver):
def lookup(num):
try: return resolver(num)[0]
except: return num
return lookup
getpwuid = lookup_or_bust(pwd.getpwuid)
getgrgid = lookup_or_bust(grp.getgrgid)

# Keep per vbs scattered recording totals in this object
class recording_data(object):
__slots__ = ['st_mtime', 'st_size', 'st_uid', 'st_gid', 'st_mode', 'rec_name', 'chunks']
@@ -38,8 +47,8 @@ class recording_data(object):
# decode uid, gid and permissions only once; the list is [(bit, 'char'), ...]
if self.st_uid is not None:
return
self.st_uid = pwd.getpwuid(statres.st_uid)[0]
self.st_gid = grp.getgrgid(statres.st_gid)[0]
self.st_uid = getpwuid(statres.st_uid)
self.st_gid = getgrgid(statres.st_gid)
# Only copy the permission bits &cet; we keep track of file/dir ourselves
self.st_mode = self.st_mode | (statres.st_mode & ~(stat.S_IFDIR|stat.S_IFREG))



Loading…
Cancel
Save