change creating of ~/Work

This commit is contained in:
Jakobus Schürz 2020-03-22 04:33:04 +01:00
parent 0c85e7d896
commit 67a2a877bb

View file

@ -16,6 +16,8 @@ import shutil
import json import json
import traceback import traceback
from pathlib import Path
try: try:
from fuse import FUSE, FuseOSError, Operations from fuse import FUSE, FuseOSError, Operations
except: except:
@ -302,11 +304,21 @@ class WorkdirFS(Operations):
def main(args): def main(args):
#FUSE(WorkdirFS(root), mountpoint, nothreads=True, foreground=True) #FUSE(WorkdirFS(root), mountpoint, nothreads=True, foreground=True)
# start FUSE filesystem # start FUSE filesystem
mountpoint = os.path.join(os.environ['HOME'], args.mountpoint) mountpoint = Path(os.path.join(os.environ['HOME'], args.mountpoint))
if not (os.path.isdir(mountpoint) or os.path.exists(mountpoint)): if mountpoint.is_link():
os.mkdir(mountpoint, 0o744) mountpoint.unlink();
if mountpoint.exist():
mountpoint.rename(mountpoint + datetime.now().strftime("%Y-%m-%d")
+ ''.join(random.choice(
string.ascii_uppercase + string.digits) for _ in range(6))
+ ".bak")
mountpoint.mkdir()
# if not (os.path.isdir(mountpoint) or os.path.exists(mountpoint)):
# if Path(mountpoint).is_symlink():
# os.path.remove
# os.mkdir(mountpoint, 0o744)
FUSE(WorkdirFS(args), os.path.join(os.environ['HOME'], args.mountpoint), FUSE(WorkdirFS(args), os.path.join(os.environ['HOME'], args.mountpoint),
nothreads=True, foreground=True, allow_other=True, allow_root=True) nothreads=True, foreground=True, allow_root=True)
if __name__ == '__main__': if __name__ == '__main__':
#main(sys.argv[2], sys.argv[1]) #main(sys.argv[2], sys.argv[1])