From 3817be7007a14458fa9def004e26a62f15a2ff82 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 24 Apr 2020 01:21:55 +0200 Subject: Create working dirs on startup, if missing --- Filer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Filer.py b/Filer.py index bcd6165..e737047 100755 --- a/Filer.py +++ b/Filer.py @@ -7,6 +7,7 @@ from os import unlink, path, getenv, listdir, mkdir, urandom from shutil import rmtree from threading import Thread from random import randint +from sys import stderr, exit from flask import Flask, render_template, jsonify, request, redirect, send_from_directory from flask_dropzone import Dropzone @@ -171,6 +172,17 @@ thread = Thread(target=cleaner_thread, args=()) thread.daemon = True thread.start() +try: + if not path.exists(path.join(basedir, 'Dokumente')): + mkdir(path.join(basedir, 'Dokumente')) + if not path.exists(path.join(basedir, 'Mandanten')): + mkdir(path.join(basedir, 'Mandanten')) + if not path.exists(path.join(basedir, 'Public')): + mkdir(path.join(basedir, 'Public')) +except: + stderr.write("Error: Basedir not accessible\n") + exit(1) + if __name__ == "__main__": parser = ArgumentParser(description="Filer") parser.add_argument("-H", "--host", help="Hostname of the Flask app " + "[default %s]" % "127.0.0.1", default="127.0.0.1") -- cgit v1.2.3