[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/VFS - OSFileSystem.py:1.1.2.7

Stephan Richter srichter@cbu.edu
Wed, 3 Apr 2002 06:29:35 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server/VFS
In directory cvs.zope.org:/tmp/cvs-serv1082/lib/python/Zope/Server/VFS

Modified Files:
      Tag: Zope3-Server-Branch
	OSFileSystem.py 
Log Message:
More work on FTP. I am trying to get the file transfer to work.


=== Zope3/lib/python/Zope/Server/VFS/OSFileSystem.py 1.1.2.6 => 1.1.2.7 ===
         else:
             try:
-                # if os.stat fails we ignore that file.
-                j = self.path_module.join
-                ld = map(lambda x, j=j, p=p: j(p, x), ld)
-                result = filter(None, map(safe_stat, ld))
-            except:
-                # ignore
-                pass
-
-            return ListProducer (result, 1, self.longify)
+                result = []
+                for file in ld:
+                    path = self.path_module.join(p, file)
+                    stat = safe_stat(path)
+                    if stat is not None:
+                        result.append((file, safe_stat(path)))
+                
+            finally:
+                return ListProducer(result, 1, self.longify)
 
 
     def longify(self, (path, stat_info)):
@@ -218,7 +218,7 @@
         
     
 months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
-                  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+          'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
 
 mode_table = {
         '0':'---',
@@ -234,6 +234,16 @@
 
 def unix_longify (file, stat_info):
         # for now, only pay attention to the lower bits
+
+    import pwd, grp
+
+    try: username = pwd.getpwuid(int(stat_info[stat.ST_UID]))[0]
+    except: username = stat_info[stat.ST_UID]
+
+    try: grpname = grp.getgrgid(int(stat_info[stat.ST_GID]))[0]
+    except: grpname = stat_info[stat.ST_GID]
+    
+
     mode = ('%o' % stat_info[stat.ST_MODE])[-3:]
     mode = ''.join(map (lambda x: mode_table[x], mode))
     if stat.S_ISDIR (stat_info[stat.ST_MODE]):
@@ -245,8 +255,8 @@
             dirchar,
             mode,
             stat_info[stat.ST_NLINK],
-            stat_info[stat.ST_UID],
-            stat_info[stat.ST_GID],
+            username,
+            grpname,
             stat_info[stat.ST_SIZE],
             date,
             file
@@ -281,6 +291,6 @@
 
 def safe_stat (path):
     try:
-        return (path, os.stat (path))
+        return os.stat(path)
     except:
         return None