-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
launching the parser through the command manager and writing to a file
- Loading branch information
Showing
1 changed file
with
17 additions
and
1 deletion.
There are no files selected for viewing
18 changes: 17 additions & 1 deletion
18
adaptive_hockey_federation/core/management/commands/fill-db.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |