Spaces:
Runtime error
Runtime error
Pranjal Pruthi
commited on
Commit
·
687de06
1
Parent(s):
659fb2b
Add application files and dependencies
Browse files
app.py
CHANGED
|
@@ -52,7 +52,6 @@ def run_command_with_progress(command, status_placeholder, progress_bar, tool_na
|
|
| 52 |
output_lines = []
|
| 53 |
error_lines = []
|
| 54 |
|
| 55 |
-
start_time = time.time()
|
| 56 |
duration = None
|
| 57 |
|
| 58 |
while True:
|
|
@@ -69,8 +68,8 @@ def run_command_with_progress(command, status_placeholder, progress_bar, tool_na
|
|
| 69 |
if '[download]' in read:
|
| 70 |
match = re.search(r'(\d+\.\d+)%', read)
|
| 71 |
if match:
|
| 72 |
-
progress = float(match.group(1))
|
| 73 |
-
progress_bar.progress(progress
|
| 74 |
|
| 75 |
if fd == process.stderr.fileno():
|
| 76 |
read = process.stderr.readline()
|
|
@@ -88,12 +87,9 @@ def run_command_with_progress(command, status_placeholder, progress_bar, tool_na
|
|
| 88 |
if time_match and duration:
|
| 89 |
hours, minutes, seconds = map(float, time_match.groups())
|
| 90 |
current_time = hours * 3600 + minutes * 60 + seconds
|
| 91 |
-
progress = (current_time / duration)
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
status_placeholder.text(f"{tool_name}: {progress:.2f}% complete, ETA: {eta:.2f} seconds")
|
| 96 |
-
progress_bar.progress(progress / 100)
|
| 97 |
|
| 98 |
if process.poll() is not None:
|
| 99 |
break
|
|
@@ -108,7 +104,6 @@ def run_command_with_progress(command, status_placeholder, progress_bar, tool_na
|
|
| 108 |
return return_code
|
| 109 |
|
| 110 |
|
| 111 |
-
|
| 112 |
def process_video(url):
|
| 113 |
# Generate a unique identifier for this processing session
|
| 114 |
session_id = str(uuid.uuid4())
|
|
|
|
| 52 |
output_lines = []
|
| 53 |
error_lines = []
|
| 54 |
|
|
|
|
| 55 |
duration = None
|
| 56 |
|
| 57 |
while True:
|
|
|
|
| 68 |
if '[download]' in read:
|
| 69 |
match = re.search(r'(\d+\.\d+)%', read)
|
| 70 |
if match:
|
| 71 |
+
progress = min(float(match.group(1)), 100) / 100
|
| 72 |
+
progress_bar.progress(progress)
|
| 73 |
|
| 74 |
if fd == process.stderr.fileno():
|
| 75 |
read = process.stderr.readline()
|
|
|
|
| 87 |
if time_match and duration:
|
| 88 |
hours, minutes, seconds = map(float, time_match.groups())
|
| 89 |
current_time = hours * 3600 + minutes * 60 + seconds
|
| 90 |
+
progress = min((current_time / duration), 1)
|
| 91 |
+
status_placeholder.text(f"{tool_name}: {progress*100:.2f}% complete")
|
| 92 |
+
progress_bar.progress(progress)
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
if process.poll() is not None:
|
| 95 |
break
|
|
|
|
| 104 |
return return_code
|
| 105 |
|
| 106 |
|
|
|
|
| 107 |
def process_video(url):
|
| 108 |
# Generate a unique identifier for this processing session
|
| 109 |
session_id = str(uuid.uuid4())
|