Skip to content

Commit

Permalink
launching the parser through the command manager and writing to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
xxfeel committed Dec 14, 2023
1 parent d5e54c9 commit 65a520f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion adaptive_hockey_federation/core/management/commands/fill-db.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import os
import subprocess

from django.core.management.base import BaseCommand

from adaptive_hockey_federation.settings import BASE_DIR

RESOURSES_ROOT = os.path.join(BASE_DIR, 'resourses')
PARSER_MAIN = os.path.join(BASE_DIR, 'parser/parser.py')


class Command(BaseCommand):
help = "Описание команды"

def handle(self, *args, **options):
return 'Я заготовка'
run_parser = subprocess.getoutput(
f'poetry run python {PARSER_MAIN} -r -p {RESOURSES_ROOT}'
)
with open(
f'{RESOURSES_ROOT}/result.txt',
'w',
encoding='utf-8',
) as file:
print(run_parser)
file.write(run_parser)

0 comments on commit 65a520f

Please sign in to comment.