| from modules.shared import cmd_opts |
| import os, inspect, re |
|
|
| script_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) |
| batchlinks_dir = os.path.join(script_dir, "batchlinks-downloader.py") |
|
|
| |
| with open(batchlinks_dir, 'r', encoding='utf-8') as f: |
| contents = f.read() |
|
|
| gradio_queue_on = False |
|
|
| try: |
| if cmd_opts.gradio_queue: |
| gradio_queue_on = True |
| except AttributeError: |
| if not cmd_opts.disable_queue: |
| gradio_queue_on = True |
|
|
| if gradio_queue_on: |
| |
| |
| new_contents = re.sub(r'^(\s*)#progress\(', r'\1progress(', contents, flags=re.MULTILINE) |
| contents = re.sub(r'civitvae\):', 'civitvae, progress=gr.Progress()):', new_contents, flags=re.MULTILINE) |
|
|
| with open(batchlinks_dir, 'w', encoding='utf-8') as f: |
| f.write(contents) |
|
|
| else: |
| |
| |
| new_contents = re.sub(r'^(\s*)progress\(', r'\1#progress(', contents, flags=re.MULTILINE) |
| contents = re.sub(r'civitvae,\s*progress=gr\.Progress\(\)\):$', 'civitvae):', new_contents, flags=re.MULTILINE) |
|
|
| with open(batchlinks_dir, 'w', encoding='utf-8') as f: |
| f.write(contents) |