From 0ac441d1325563bcf5ee54589cfad0d70da198b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 27 Feb 2020 10:41:13 +0100 Subject: [PATCH] remove empty directories. fix mounting gives ??? --- workdirfs.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/workdirfs.py b/workdirfs.py index a644647..bb37f10 100755 --- a/workdirfs.py +++ b/workdirfs.py @@ -22,7 +22,7 @@ except: try: from fusepy import FUSE, FuseOSError, Operations except: - print("please install fusepy for python3") + print("please install fusepy") raise errno.ModuleNotFoundError @@ -150,13 +150,15 @@ class WorkdirFS(Operations): print("Cleanup dir", self.yesterdaypath) zip_fileext=".gz" zip_compressionlevel=5 - for root, dirs, files in os.walk(self.yesterdaypath, topdown=False): + #for root, dirs, files in os.walk(self.yesterdaypath, topdown=False): + print("Archivepath",self.archivpathbase) + for root, dirs, files in os.walk(self.archivpathbase, topdown=False): for d in dirs: print("cleanup",os.path.join(root, d)) - if not _dir == self.todaypath and not os.listdir(os.path.join(root, d)): + if not d == self.todaypath and not os.listdir(os.path.join(root, d)): print("Directory is empty -> remove it", os.path.join(root, d)) - os.remove(os.path.join(root, d)) + os.rmdir(os.path.join(root, d)) if self.args.compress: for f in files: print("compress", os.path.join(root, f)) @@ -304,8 +306,8 @@ def main(args): #FUSE(WorkdirFS(root), mountpoint, nothreads=True, foreground=True) # start FUSE filesystem mountpoint = os.path.join(os.environ['HOME'], args.mountpoint) - if not (os.path.isdir(mountpoint) || os.path.exists(mountpoint)): - os.mkdir(mountpoint, "0744") + if not (os.path.isdir(mountpoint) or os.path.exists(mountpoint)): + os.mkdir(mountpoint, 0o744) FUSE(WorkdirFS(args), os.path.join(os.environ['HOME'], args.mountpoint), nothreads=True, foreground=True) if __name__ == '__main__':