Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethernet library being installed #108

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ex_installer/arduino_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,14 @@ def upgrade_platforms(self, file_path, queue):
acli = ThreadedArduinoCLI(file_path, params, queue)
acli.start()

def install_library(self, file_path, library, queue):
"""
Install the specified Arduino library
"""
params = ["lib", "install", library, "--format", "jsonmini"]
acli = ThreadedArduinoCLI(file_path, params, queue)
acli.start()

def list_boards(self, file_path, queue):
"""
Returns a list of attached boards
Expand Down
29 changes: 29 additions & 0 deletions ex_installer/manage_arduino_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# Import local modules
from .common_widgets import WindowLayout, CreateToolTip
from . import images
from .product_details import product_details as pd


class ManageArduinoCLI(WindowLayout):
Expand Down Expand Up @@ -75,6 +76,9 @@ def __init__(self, parent, *args, **kwargs):
"Arduino AVR": "arduino:avr"
}

# Set up list for library installs
self.library_list = []

# Set title and logo
self.set_title_logo(images.EX_INSTALLER_LOGO)
self.set_title_text("Manage the Arduino CLI")
Expand Down Expand Up @@ -147,6 +151,7 @@ def __init__(self, parent, *args, **kwargs):

def set_state(self):
self.next_back.hide_log_button()
self.get_library_list()
if self.acli.is_installed(self.acli.cli_file_path()):
self.cli_state_label.configure(text=self.installed_text,
text_color="#00353D",
Expand All @@ -165,6 +170,16 @@ def set_state(self):
command=lambda event="install_cli": self.manage_cli(event))
self.next_back.disable_next()

def get_library_list(self):
"""
Get list of library dependencies from product details
"""
self.library_list = []
for product in pd:
if "arduino_libraries" in pd[product]:
for library in pd[product]["arduino_libraries"]:
self.library_list.append(library)

def update_package_list(self, switch):
"""
Maintain the list of packages to install/refresh when switches updated
Expand Down Expand Up @@ -234,6 +249,7 @@ def manage_cli(self, event):
elif event == "refresh_cli" or self.process_phase == "extract_cli":
if event == "refresh_cli":
self.disable_input_states(self)
self.get_library_list()
if self.process_status == "success" or event == "refresh_cli":
self.process_start("config_cli", "Configuring the Arduino CLI", "Manage_CLI")
for widget in self.extra_platforms_frame.winfo_children():
Expand All @@ -260,6 +276,19 @@ def manage_cli(self, event):
self.process_start("install_packages", f"Installing package {package}", "Manage_CLI")
self.acli.install_package(self.acli.cli_file_path(), self.package_dict[package], self.queue)
del self.package_dict[package]
else:
self.process_stop()
self.manage_cli("install_libraries")
elif self.process_status == "error":
self.process_error(self.process_topic)
self.restore_input_states()
elif event == "install_libraries" or self.process_phase == "install_libraries":
if self.process_status == "success" or event == "install_libraries":
if len(self.library_list) > 0:
library = self.library_list[0]
del self.library_list[0]
self.process_start("install_libraries", "Install Arduino library " + library, "Manage_CLI")
self.acli.install_library(self.acli.cli_file_path(), library, self.queue)
else:
self.process_start("upgrade_platforms", "Upgrading Arduino platforms", "Manage_CLI")
self.acli.upgrade_platforms(self.acli.cli_file_path(), self.queue)
Expand Down
3 changes: 3 additions & 0 deletions ex_installer/product_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"other_config_files": [
r"^my.*\.[^?]*example\.cpp$|(^my.*\.cpp$)",
r"^my.*\.[^?]*example\.h$|(^my.*\.h$)"
],
"arduino_libraries": [
"Ethernet"
]
},
"ex_ioexpander": {
Expand Down
Loading