File tree Expand file tree Collapse file tree 4 files changed +13
-22
lines changed
Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Original file line number Diff line number Diff line change 77
88from app .api .hooks .schema .request import HookRequest
99from app .media .ffprobe_schema import FfprobeOutput
10- from app .task_builder import TKB
10+ from app .task_builder import build_task
1111
1212logger = logging .getLogger (__name__ )
1313
@@ -33,7 +33,7 @@ class MetadataExtractor:
3333 """Class to handle metadata extraction and compliance checking."""
3434
3535 async def _run_ffprobe (self , filepath : Path ) -> str :
36- stdout , _ = await TKB (
36+ stdout , _ = await build_task (
3737 f"ffprobe -v quiet -show_format -show_streams -of json { shlex .quote (str (filepath ))} "
3838 ).execute ()
3939 return stdout
Original file line number Diff line number Diff line change 88from .archive_store import Archive
99from .media .comand_template import ProfileTemplateArguments , TemplatedCommandGenerator
1010from .media .ffprobe_schema import FfprobeOutput
11- from .task_builder import TKB
11+ from .task_builder import build_task
1212
1313DESIRED_FORMATS = (
1414 FormatEnum .LARGE_THUMB ,
@@ -90,7 +90,7 @@ async def _process_format(
9090 command = template .render (template_args )
9191 self .logger .debug ("Generated command: %s" , command )
9292
93- await TKB (command ).execute ()
93+ await build_task (command ).execute ()
9494
9595 self .logger .info ("Creating video file entry for %s" , output_file )
9696 await self .django_api .create_video_file (filename = str (output_file ), file_format = file_format , video_id = video_id )
Original file line number Diff line number Diff line change 1- import asyncio
1+ """RSX-11M for life"""
22
3- from app . runner import Task
3+ from asyncio import create_subprocess_shell , subprocess
44
5+ from app .runner import Task
56
6- def TKB (command : str ) -> Task :
7- """Task Builder for running subprocesses asynchronously. The name is a reference to RSX-11M+ :)
87
9- This function takes a command string, splits it into arguments, and creates a Task
10- that can be executed asynchronously. It uses asyncio's subprocess capabilities to
11- run the command in a subprocess, capturing both stdout and stderr.
8+ def build_task (shell_command : str ) -> Task :
9+ """Creates a Task to run a shell command asynchronously.
1210
1311 Args:
14- command (str): The shell command to run.
15-
12+ shell_command (str): The shell command to run.
1613 """
17- return Task (
18- asyncio .create_subprocess_shell (
19- command ,
20- stdout = asyncio .subprocess .PIPE ,
21- stderr = asyncio .subprocess .PIPE ,
22- )
23- )
14+ return Task (create_subprocess_shell (shell_command , stdout = subprocess .PIPE , stderr = subprocess .PIPE ))
Original file line number Diff line number Diff line change 11import pytest
22
3- from app .task_builder import TKB
3+ from app .task_builder import build_task
44
55
66@pytest .mark .asyncio
@@ -9,6 +9,6 @@ async def test_basic_run(tmp_path):
99 test_path .touch ()
1010 assert test_path .exists ()
1111
12- await TKB (f"rm { test_path } " ).execute ()
12+ await build_task (f"rm { test_path } " ).execute ()
1313
1414 assert not test_path .exists ()
You can’t perform that action at this time.
0 commit comments