forked from LiveCarta/BookConverter
@@ -12,10 +12,6 @@ RUN pip install -r /app/requirements.txt
|
|||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
RUN mkdir -p /app/logs
|
|
||||||
RUN mkdir -p /app/docx
|
|
||||||
RUN mkdir -p /app/json
|
|
||||||
RUN mkdir -p /app/html
|
|
||||||
VOLUME /app/logs
|
VOLUME /app/logs
|
||||||
|
|
||||||
CMD python /app/src/consumer.py
|
CMD python /app/src/util/check_dirs.py && python /app/src/consumer.py
|
||||||
|
|||||||
35
src/util/check_dirs.py
Normal file
35
src/util/check_dirs.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description="Utility for folders's clean up.")
|
||||||
|
parser.add_argument('-f', '--folders', type=str, nargs='*', help='Names of the folders to be cleaned.')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def check_dir(dir_path):
|
||||||
|
if not os.path.exists(dir_path):
|
||||||
|
try:
|
||||||
|
os.mkdir(dir_path)
|
||||||
|
except OSError as exc:
|
||||||
|
raise exc
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
folders = parse_args().folders
|
||||||
|
if not folders:
|
||||||
|
folders = ['docx', 'html', 'json', 'logs', 'config']
|
||||||
|
|
||||||
|
folder_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
folders = [os.path.join(folder_path, folder) for folder in folders]
|
||||||
|
|
||||||
|
try:
|
||||||
|
for folder in folders:
|
||||||
|
check_dir(folder)
|
||||||
|
|
||||||
|
except OSError as exc:
|
||||||
|
print(exc)
|
||||||
|
raise
|
||||||
Reference in New Issue
Block a user