forked from Alexey/DAS_2024_1
Проблема с Docker на компьютере. Сохранение процесса.
This commit is contained in:
parent
822467bd99
commit
b13182c80e
1
kashin_maxim_lab_2/.gitignore
vendored
Normal file
1
kashin_maxim_lab_2/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
var/
|
7
kashin_maxim_lab_2/docker-compose.yml
Normal file
7
kashin_maxim_lab_2/docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
|
||||
program_0:
|
||||
build:
|
||||
context: ./program_0
|
||||
volumes:
|
||||
- ./data:/var/data
|
7
kashin_maxim_lab_2/program_0/Dockerfile
Normal file
7
kashin_maxim_lab_2/program_0/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /program_0
|
||||
|
||||
COPY main.py /program_0/
|
||||
|
||||
CMD ["python", "main.py"]
|
37
kashin_maxim_lab_2/program_0/main.py
Normal file
37
kashin_maxim_lab_2/program_0/main.py
Normal file
@ -0,0 +1,37 @@
|
||||
import random
|
||||
import os
|
||||
|
||||
folder_path = './kashin_maxim_lab_2/var/data'
|
||||
|
||||
def creat_folder():
|
||||
if not os.path.exists(folder_path):
|
||||
os.makedirs(folder_path)
|
||||
else:
|
||||
print(f"Папка `{folder_path}` уже существует!")
|
||||
|
||||
def delete_files_in_folder():
|
||||
for filename in os.listdir(folder_path):
|
||||
file_path = os.path.join(folder_path, filename)
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
print(f'Ошибка при удалении файла {file_path}. {e}')
|
||||
|
||||
def creat_file():
|
||||
for i in range(random.randrange(10, 20)):
|
||||
file = open(f'{folder_path}/file_{i}.txt', 'w+')
|
||||
for i in range(random.randrange(10, 50)):
|
||||
file.write(f'{create_lines()} \n')
|
||||
file.close()
|
||||
|
||||
def create_lines():
|
||||
lines = [i for i in range(random.randrange(1, 50),random.randrange(50, 100),random.randrange(1, 10))]
|
||||
return lines
|
||||
|
||||
if os.path.exists(folder_path):
|
||||
delete_files_in_folder()
|
||||
creat_file()
|
||||
else:
|
||||
creat_folder()
|
||||
creat_file()
|
Loading…
Reference in New Issue
Block a user