def deploy(channel_path, roku_ip): f = Figlet(font='slant') click.echo(f.renderText('RokuPi')) current_channel = Channel(channel_path) # create config if non-existent if current_channel.config_file is None: create_config_response = click.prompt('Would like to create config file y/n ', type=str, default='y') if handle_yes_no_response(create_config_response): handle_yes_no_response(create_config_response) click.echo(f'Default structure \n{STANDARD_CHANNEL_STRUCTURE}\nThis can be updated later') use_default_channel_structure = click.prompt( 'Would you like to use default channel structure y/n', type=str, default='y' ) if handle_yes_no_response(use_default_channel_structure): create_config_file(STANDARD_CHANNEL_STRUCTURE, current_channel.channel_path) else: example = 'manifest, someDir/**, anotherDir/**' click.echo(f'please input you channel structure, ' f'use unix glob pattern in comma separated values {example}') custom_channel_structure = input("Please input your channel structure: ") if custom_channel_structure != '': folders = custom_channel_structure.split(',') create_config_file(folders, current_channel.channel_path) current_channel.set_config_file_data() else: click.echo(f'please use an array of files {example}') # Parse manifest for data current_channel.manifest_data = parse_manifest(current_channel.channel_path / 'manifest') current_channel.set_config_file_data() # Stage channel contents and create archive stage_channel_contents(current_channel.channel_path, current_channel.config_data["files"]) stage_dir_path = current_channel.channel_path / STAGE_DIR out_dir = current_channel.channel_path / 'out' / current_channel.__str__() archive_staged_content_to_out(stage_dir_path, out_dir) # empty stage dir and remove empty_dir(str(stage_dir_path)) stage_dir_path.rmdir() # device selection if roku_ip is None: device_selection_results = None # No device defined in config if "device" not in current_channel.config_data.keys() or not bool(current_channel.config_data["device"]): device_selection_results = device_selection() device = device_selection_results["device"] # using device defined in config else: current_channel.set_config_file_data() device = current_channel.config_data["device"] use_config_roku = click.prompt(f'Would you like to use {device["name"]} @ {device["ip_address"]} y/n', type=str, default='y') # not using device in config but there is one if not handle_yes_no_response(use_config_roku): device_selection_results = device_selection() device = device_selection_results["device"] # scanning/manual input device saving if device_selection_results and device_selection_results["write_to_config"]: Roku.write_device_data_to_config(device, current_channel.config_file) current_channel.set_config_file_data() else: device = { "name": ' ', "username": '******', "password": '', "ip_address": roku_ip } try: # validate ip if ipaddress.ip_address(device["ip_address"]): device_password = click.prompt('device password', type=str, hide_input=True) device["password"] = device_password else: click.echo("IP address needs to be in IPV4 format") except ValueError: click.echo("IP address needs to be in IPV4 format") # ping device for availability data_from_device = query_ip_address_for_device_info(roku_ip) if data_from_device is None: click.echo("Unable to establish connection with device") return else: device["name"] = data_from_device["value"]["name"] save_device = click.prompt('Do you want to save this device y/n', type=str, default='y') if handle_yes_no_response(save_device): Roku.write_device_data_to_config(device, current_channel.config_file) current_channel.set_config_file_data() roku = Roku(device) roku.delete_channel() roku.deploy_channel(current_channel)