|
import gradio as gr |
|
import os |
|
from utils.steps import * |
|
|
|
|
|
testphase = None |
|
rootDir = None |
|
templatesDir = None |
|
|
|
|
|
def validate_directory(directory_path): |
|
if os.path.isdir(directory_path): |
|
return True |
|
else: |
|
return False |
|
|
|
|
|
def createFolders(): |
|
global rootDir, testphase, templatesDir |
|
if not rootDir: |
|
return "Error: Root directory not provided." |
|
if not templatesDir: |
|
return "Error: Templates directory not provided." |
|
if not testphase: |
|
return "Error: Phase not selected." |
|
|
|
|
|
if not validate_directory(rootDir): |
|
return f"Error: Root directory '{rootDir}' does not exist." |
|
if not validate_directory(templatesDir): |
|
return f"Error: Templates directory '{templatesDir}' does not exist." |
|
|
|
|
|
copyPasteTemplates(rootDir, testphase, templatesDir) |
|
return "Folders created successfully!" |
|
|
|
|
|
def run_steps(phase, root_dir, templates_dir): |
|
global testphase, rootDir, templatesDir |
|
testphase = phase |
|
rootDir = root_dir |
|
templatesDir = templates_dir |
|
|
|
|
|
result = createFolders() |
|
return result |
|
|
|
|
|
def validate_and_run(phase, root_dir, templates_dir): |
|
|
|
if not root_dir or not templates_dir: |
|
return "Error: Please provide both the root and templates directory paths." |
|
|
|
|
|
return run_steps(phase, root_dir, templates_dir) |
|
|
|
|
|
with gr.Blocks() as app: |
|
gr.Markdown("# Folder Creation Tool") |
|
|
|
phase_input = gr.Dropdown(choices=inputPhases.values(), label="Select Phase") |
|
root_dir_input = gr.Textbox(label="Root Directory", placeholder="Enter the root directory path") |
|
templates_dir_input = gr.Textbox(label="Templates Directory", placeholder="Enter the templates directory path") |
|
|
|
create_button = gr.Button("Create Folders") |
|
output = gr.Textbox(label="Output") |
|
|
|
create_button.click(validate_and_run, inputs=[phase_input, root_dir_input, templates_dir_input], outputs=output) |
|
|
|
app.launch() |
|
|