예제 #1
0
    def attach(self, port=None, fqbn=None, sketch_path=None, discovery_timeout=None, protocol=None):
        """
        Calls the :code:`board attach` command.

        :param port: Upload port address, e.g.: COM3 or /dev/ttyACM2
        :type port: str or NoneTYpe
        :param fqbn: Fully Qualified Board Name, e.g.: arduino:avr:uno
        :type fqbn: str or NoneTYpe
        :param sketch_path: The path of the sketch to attach to the board
        :type sketch_path: str or NoneTYpe
        :param discovery_timeout: Max time to wait for port discovery, e.g.: 30s, 1m (default 5s)
        :type discovery_timeout: str or NoneTYpe
        :param protocol: Upload port protocol, e.g: serial
        :type protocol: str or NoneTYpe
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.ATTACH]
        if port:
            args.extend([flags.PORT, CommandBase._strip_arg(port)])
        if protocol:
            args.extend([flags.PROTOCOL, CommandBase._strip_arg(protocol)])
        if fqbn:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        if sketch_path:
            args.append(CommandBase._strip_arg(sketch_path))
        if discovery_timeout:
            args.extend([flags.DISCOVERY_TIMEOUT, CommandBase._strip_arg(discovery_timeout)])
        return self._exec(args)
예제 #2
0
    def __call__(self,
                 daemonize=None,
                 port=None,
                 debug=None,
                 debug_filter=None,
                 ip=None):
        """
        Calls the :code:`daemon` command

        :param daemonize: Do not terminate daemon process if the parent process dies
        :type daemonize: bool or NoneType
        :param port: The TCP port the daemon will listen to
        :type port: str, integer or NoneType
        :param debug: Enable debug logging of gRPC calls
        :type debug: bool or NoneType
        :param debug_filter: Display only the provided gRPC calls
        :type debug_filter: str or NoneType
        :param ip: The IP address the daemon will listen to (default "127.0.0.1")
        :type ip: str or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = []
        if daemonize is True:
            args.append(flags.DAEMONIZE)
        if port:
            args.extend([flags.PORT, CommandBase._strip_arg(str(port))])
        if debug is True:
            args.append(flags.DEBUG)
        if debug_filter:
            args.extend(
                [flags.DEBUG_FILTER,
                 CommandBase._strip_arg(debug_filter)])
        return self._exec(args)
예제 #3
0
    def __call__(self,
                 fqbn=None,
                 input_dir=None,
                 port=None,
                 interpreter=None,
                 info=None,
                 programmer=None,
                 sketch=None,
                 discovery_timeout=None,
                 protocol=None):
        """
        Calls the :code:`debug` command

        :param fqbn: Fully Qualified Board Name, e.g.: arduino:avr:uno
        :type fqbn: str or NoneType
        :param input_dir: Directory containing binaries for debug.
        :type input_dir: str or NoneType
        :param port: Debug port, e.g.: COM10 or /dev/ttyACM0
        :type port: str or NoneType
        :param interpreter: Debug interpreter e.g.: console, mi, mi1, mi2, mi3 (default "console")
        :type interpreter: str or NoneType
        :param info: Show metadata about the debug session instead of starting the debugger.
        :type info: str or NoneType
        :param programmer: Programmer to use for debugging
        :type programmer: str or NoneType
        :param sketch: The sketch to debug
        :type sketch: str or NoneType
        :param discovery_timeout: Max time to wait for port discovery, e.g.: 30s, 1m (default 5s)
        :type discovery_timeout: str or NoneType
        :param protocol: Upload port protocol, e.g: serial
        :type protocol: str or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = []
        if fqbn:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        if input_dir:
            args.extend([flags.INPUT_DIR, CommandBase._strip_arg(input_dir)])
        if port:
            args.extend([flags.PORT, CommandBase._strip_arg(port)])
        if interpreter:
            args.extend(
                [flags.INTERPRETER,
                 CommandBase._strip_arg(interpreter)])
        if info is True:
            args.append(flags.INFO)
        if programmer:
            args.extend([flags.PROGRAMMER, CommandBase._strip_arg(programmer)])
        if sketch:
            args.append(CommandBase._strip_arg(sketch))
        if discovery_timeout:
            args.extend([
                flags.DISCOVERY_TIMEOUT,
                CommandBase._strip_arg(discovery_timeout)
            ])
        if protocol:
            args.extend([flags.PROTOCOL, CommandBase._strip_arg(protocol)])
        return self._exec(args)
예제 #4
0
    def examples(self, library, fqbn=None):
        """
        Calls the :code:`lib examples` command

        :param library: The name of the library
        :type library: str
        :param fqbn: The board FQBN
        :type fqbn: str or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.EXAMPLES, CommandBase._strip_arg(library)]
        if fqbn is not None:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        return self._exec(args)
예제 #5
0
    def __call__(self,
                 config=None,
                 describe=None,
                 discovery_timeout=None,
                 fqbn=None,
                 port=None,
                 protocol=None,
                 quiet=None):
        """
        Calls the :code:`monitor` command

        :param config: Configuration of the port.
        :type config: str or NoneType
        :param describe: Show all the settings of the communication port.
        :type describe: bool or NoneType
        :param discovery_timeout: Max time to wait for port discovery, e.g.: 30s, 1m (default 5s)
        :type discovery_timeout: str or NoneType
        :param fqbn: Fully Qualified Board Name, e.g.: arduino:avr:uno
        :type fqbn: str or NoneType
        :param port: Upload port address, e.g.: COM3 or /dev/ttyACM2
        :type port: str or NoneType
        :param protocol: Upload port protocol, e.g: serial
        :type protocol: str or NoneType
        :param quiet: Run in silent mode, show only monitor input and output.
        :type quiet: bool or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = []
        if config:
            args.extend([flags.CONFIG, CommandBase._strip_arg(config)])
        if describe is True:
            args.append(flags.DESCRIBE)
        if discovery_timeout:
            args.extend([
                flags.DISCOVERY_TIMEOUT,
                CommandBase._strip_args(discovery_timeout)
            ])
        if fqbn:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        if port:
            args.extend([flags.PORT, CommandBase._strip_arg(port)])
        if protocol:
            args.extend([flags.PROTOCOL, CommandBase._strip_arg(protocol)])
        if quiet is True:
            args.append(flags.QUIET)
        return self._exec(args)
예제 #6
0
    def deps(self, library):
        """
        Calls the :code:`lib deps` command

        :param library: The name of the library for dependency checking
        :type library: str
        :return: The output of the related command
        :rtype: dict
        """
        return self._exec([commands.DEPS, CommandBase._strip_arg(library)])
예제 #7
0
    def new(self, name):
        """
        Calls the :code:`sketch new` command

        :param name: The name of the sketch to create
        :type name: str
        :return: The output of the related command
        :rtype: dict
        """
        return self._exec([commands.NEW, CommandBase._strip_arg(name)])
예제 #8
0
    def __call__(self,
                 discovery_timeout=None,
                 fqbn=None,
                 port=None,
                 programmer=None,
                 protocol=None,
                 verify=None):
        """
        Calls the :code:`burn-bootloader` command

        :param fqbn: The fqbn of the board to burn
        :type fqbn: str or NoneType
        :param port: The port to use to burl the bootloader
        :type port: str or NoneTYpe
        :param programmer: The programmer to use for the burning process
        :type programmer: str or NoneTYpe
        :param verify: Verifies that the bootloader was successfully burnt
        :type verify: bool or NoneTYpe
        :param discovery_timeout: Max time to wait for port discovery, e.g.: 30s, 1m (default 5s)
        :type discovery_timeout: str or NoneType
        :param protocol: Upload port protocol, e.g: serial
        :type protocol: str or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = []
        if discovery_timeout:
            args.extend([
                flags.DISCOVERY_TIMEOUT,
                CommandBase._strip_arg(discovery_timeout)
            ])
        if fqbn:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        if port:
            args.extend([flags.PORT, CommandBase._strip_arg(port)])
        if programmer:
            args.extend([flags.PROGRAMMER, CommandBase._strip_arg(programmer)])
        if protocol:
            args.extend([flags.PROTOCOL, CommandBase._strip_arg(protocol)])
        if verify is True:
            args.append(flags.VERIFY)
        return self._exec(args)
예제 #9
0
    def init(self, dest_dir=None, dest_file=None, overwrite=None):
        """
        Calls the :code:`config init` command

        :param dest_dir: The directory where to save the file
        :type dest_dir: str or NoneType
        :param dest_file: A path where the file will be saved
        :type dest_file: str or NoneType
        :param overwrite: Overwrites an existing file
        :type overwrite: bool or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.INIT]
        if dest_dir:
            args.extend([flags.DEST_DIR, CommandBase._strip_arg(dest_dir)])
        if dest_file:
            args.extend([flags.DEST_FILE, CommandBase._strip_arg(dest_file)])
        if overwrite is True:
            args.append(flags.OVERWRITE)
        return self._exec(args)
예제 #10
0
    def delete(self, setting_name):
        """
        Calls the :code:`config delete` command

        :param setting_name: The name of the setting to delete
        :type setting_name: str
        :return: The output of the related command
        :rtype: dict
        """
        return self._exec(
            [commands.DELETE,
             CommandBase._strip_arg(setting_name)])
예제 #11
0
    def archive(self,
                sketch_path=".",
                archive_path=None,
                include_build_dir=None):
        """
        Calls the :code:`sketch archive` command

        :param sketch_path: The path to the sketch to archive
        :type sketch_path: str
        :param archive_path: The path of the output archive
        :type archive_path: str or NoneType
        :param include_build_dir: Includes the build directory in the archive
        :type include_build_dir: bool or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.ARCHIVE, CommandBase._strip_arg(sketch_path)]
        if archive_path is not None:
            args.append(CommandBase._strip_arg(archive_path))
        if include_build_dir is True:
            args.append(flags.INCLUDE_BUILD_DIR)
        return self._exec(args)
예제 #12
0
    def set(self, setting_name, values):
        """
        Calls the :code:`config set` command

        :param setting_name: The name of the setting to set
        :type setting_name: str
        :param values: The list of values to set
        :type values: list
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.SET, CommandBase._strip_arg(setting_name)]
        args.extend(CommandBase._strip_args(values))
        return self._exec(args)
예제 #13
0
    def remove(self, setting_name, values):
        """
        Calls the :code:`config remove` command

        :param setting_name: The name of the setting from which values will be removed
        :type setting_name: str
        :param values: The list of values to remove
        :type values: list
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.REMOVE, CommandBase._strip_arg(setting_name)]
        args.extend(CommandBase._strip_args(values))
        return self._exec(args)
예제 #14
0
    def __call__(self, shell, no_description=None):
        """
        Calls the :code:`completion` command

        :param shell: The shell name that will use completition
        :type shell: str
        :param no_description: Disable completion description for shells that support it
        :type no_description: bool or NoneTYpe
        :return: The output of the related command
        :rtype: dict
        """
        args = []
        if no_description is True:
            args.append(flags.NO_DESCRIPTION)
        args.append(CommandBase._strip_arg(shell))
        return self._exec(args)
예제 #15
0
    def listall(self, boardname=None, show_hidden=None):
        """
        Calls the :code:`board listall` command.

        :param boardname: The name of the board, all board will be returned if left unset (or None)
        :type boardname: str or NoneType
        :param show_hidden: Show also boards marked as 'hidden' in the platform
        :type show_hidden: bool or NoneTYpe
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.LISTALL]
        if boardname:
            args.append(CommandBase._strip_arg(boardname))
        if show_hidden is True:
            args.append(flags.SHOW_HIDDEN)
        return self._exec(args)
예제 #16
0
    def list(self, discovery_timeout=None, watch=None):
        """
        Calls the :code:`board list` command.

        :param discovery_timeout: Max time to wait for port discovery, e.g.: 30s, 1m (default 1s)
        :type discovery_timeout: str or NoneType
        :param watch: Command keeps running and prints list of connected boards whenever there is a change. Added to pyduinocli for completion but won't actually return, use a loop instead
        :type watch: bool or NoneTYpe
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.LIST]
        if discovery_timeout:
            args.extend([flags.DISCOVERY_TIMEOUT, CommandBase._strip_arg(discovery_timeout)])
        if watch is True:
            args.append(flags.WATCH)
        return self._exec(args)
예제 #17
0
    def search(self, boardname=None, show_hidden=None):
        """
        Calls the :code:`board search` command.

        :param boardname: The name of the board
        :type boardname: str or NoneType
        :param show_hidden: Show also boards marked as 'hidden' in the platform
        :type show_hidden: bool or NoneTYpe
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.SEARCH]
        if boardname:
            args.append(CommandBase._strip_arg(boardname))
        if show_hidden is True:
            args.append(flags.SHOW_HIDDEN)
        return self._exec(args)
예제 #18
0
    def details(self, fqbn, full=None, list_programmers=None):
        """
        Calls the :code:`board details` command.

        :param fqbn: The fqbn of the board
        :type fqbn: str
        :param full: Show full board details
        :type full: bool or NoneTYpe
        :param list_programmers: Show list of available programmers
        :type list_programmers: bool or NoneTYpe
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.DETAILS, flags.FQBN, CommandBase._strip_arg(fqbn)]
        if full is True:
            args.append(flags.FULL)
        if list_programmers is True:
            args.append(flags.LIST_PROGRAMMERS)
        return self._exec(args)
예제 #19
0
    def list(self, all=None, updatable=None, fqbn=None):
        """
        Calls the :code:`lib list` command

        :param all: Includes built-in libraries
        :type all: bool or NoneType
        :param updatable: Only shows libraries that are not up to date
        :type updatable: bool or NoneType
        :param fqbn: Shows libraries for the specified board
        :type fqbn: str or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = [commands.LIST]
        if all is True:
            args.append(flags.ALL)
        if updatable is True:
            args.append(flags.UPDATABLE)
        if fqbn is not None:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        return self._exec(args)
예제 #20
0
 def __init__(self,
              cli_path="arduino-cli",
              config_file=None,
              additional_urls=None,
              log_file=None,
              log_format=None,
              log_level=None,
              no_color=None):
     """
     :param cli_path: The :code:`arduino-cli` command name if available in :code:`$PATH`. Can also be a direct path to the executable
     :type cli_path: str
     :param config_file: The path to the :code:`arduino-cli` configuration file to be used
     :type config_file: str or NoneType
     :param additional_urls: A list of URLs to custom board definitions files
     :type additional_urls: list or NoneType
     :param log_file: A path to a file where logs will be stored
     :type log_file: str or NoneType
     :param log_format: The format the logs will use
     :type log_format: str or NoneType
     :param log_level: The log level for the log file
     :type log_level: str or NoneType
     :param no_color: Disable colored output
     :type no_color: bool or NoneType
     """
     base_args = [cli_path, flags.FORMAT, ArduinoCliCommand.__FORMAT_JSON]
     if config_file:
         base_args.extend(
             [flags.CONFIG_FILE,
              CommandBase._strip_arg(config_file)])
     if additional_urls:
         base_args.extend([
             flags.ADDITIONAL_URLS,
             ",".join(CommandBase._strip_args(additional_urls))
         ])
     if log_file:
         base_args.extend(
             [flags.LOG_FILE,
              CommandBase._strip_arg(log_file)])
     if log_format:
         base_args.extend(
             [flags.LOG_FORMAT,
              CommandBase._strip_arg(log_format)])
     if log_level:
         base_args.extend(
             [flags.LOG_LEVEL,
              CommandBase._strip_arg(log_level)])
     if no_color is True:
         base_args.append(flags.NO_COLOR)
     CommandBase.__init__(self, base_args)
     self.__board = BoardCommand(self._base_args)
     self.__cache = CacheCommand(self._base_args)
     self.__compile = CompileCommand(self._base_args)
     self.__config = ConfigCommand(self._base_args)
     self.__core = CoreCommand(self._base_args)
     self.__daemon = DaemonCommand(self._base_args)
     self.__debug = DebugCommand(self._base_args)
     self.__lib = LibCommand(self._base_args)
     self.__sketch = SketchCommand(self._base_args)
     self.__upload = UploadCommand(self._base_args)
     self.__version = VersionCommand(self._base_args)
     self.__burn_bootloader = BurnBootloaderCommand(self._base_args)
     self.__completion = CompletionCommand(self._base_args)
     self.__outdated = OutdatedCommand(self._base_args)
     self.__update = UpdateCommand(self._base_args)
     self.__upgrade = UpgradeCommand(self._base_args)
     self.__monitor = MonitorCommand(self._base_args)
예제 #21
0
    def __call__(self,
                 sketch,
                 build_cache_path=None,
                 build_path=None,
                 build_properties=None,
                 fqbn=None,
                 output_dir=None,
                 port=None,
                 preprocess=None,
                 show_properties=None,
                 upload=None,
                 verify=None,
                 vid_pid=None,
                 warnings=None,
                 libraries=None,
                 library=None,
                 optimize_for_debug=None,
                 export_binaries=None,
                 programmer=None,
                 clean=None,
                 only_compilation_database=None,
                 discovery_timeout=None,
                 protocol=None):
        """
        Calls the :code:`compile` command

        :param sketch: The sketch to compile, can also be a path to a sketch
        :type sketch: str
        :param build_cache_path: Builds of 'core.a' are saved into this path to be cached and reused.
        :type build_cache_path: str or NoneType
        :param build_path: Path where to save compiled files. If omitted, a directory will be created in the default temporary path of your OS.
        :type build_path: str or NoneType
        :param build_properties: Override build properties with custom values.
        :type build_properties: list or NoneType
        :param fqbn: Fully Qualified Board Name, e.g.: arduino:avr:uno
        :type fqbn: str or NoneType
        :param output_dir: Save build artifacts in this directory.
        :type output_dir: str or NoneType
        :param port: Upload port, e.g.: COM10 or /dev/ttyACM0
        :type port: str or NoneType
        :param preprocess: Print preprocessed code to stdout instead of compiling.
        :type preprocess: bool or NoneType
        :param show_properties: Show all build properties used instead of compiling.
        :type show_properties: bool or NoneType
        :param upload: Upload the binary after the compilation.
        :type upload: bool or NoneType
        :param verify: Verify uploaded binary after the upload.
        :type verify: bool or NoneType
        :param vid_pid: When specified, VID/PID specific build properties are used, if board supports them.
        :type vid_pid: str or NoneType
        :param warnings: Optional, can be "none", "default", "more" and "all". Defaults to "none". Used to tell gcc which warning level to use (-W flag). (default "none")
        :type warnings: str or NoneType
        :param libraries: List of custom libraries dir paths separated by commas. Or can be used multiple times for multiple libraries dir paths.
        :type libraries: list or NoneType
        :param library: List of paths to libraries root folders. Libraries set this way have top priority in case of conflicts. Can be used multiple times for different libraries.
        :type library: list or NoneType
        :param optimize_for_debug: Optional, optimize compile output for debugging, rather than for release.
        :type optimize_for_debug: bool or NoneType
        :param export_binaries: If set built binaries will be exported to the sketch folder.
        :type export_binaries: bool or NoneType
        :param programmer: Optional, use the specified programmer to upload.
        :type programmer: str or NoneType
        :param clean: Optional, cleanup the build folder and do not use any cached build.
        :type clean: bool or NoneType
        :param only_compilation_database: Just produce the compilation database, without actually compiling.
        :type only_compilation_database: bool or NoneType
        :param discovery_timeout: Max time to wait for port discovery, e.g.: 30s, 1m (default 5s)
        :type discovery_timeout: str or NoneType
        :param protocol: Upload port protocol, e.g: serial
        :type protocol: str or NoneType
        :return: The output of the related command
        :rtype: dict
        """
        args = []
        if build_cache_path:
            args.extend([
                flags.BUILD_CACHE_PATH,
                CommandBase._strip_arg(build_cache_path)
            ])
        if build_path:
            args.extend([flags.BUILD_PATH, CommandBase._strip_arg(build_path)])
        if build_properties:
            for build_property in build_properties:
                args.extend([
                    flags.BUILD_PROPERTY,
                    CommandBase._strip_arg(build_property)
                ])
        if fqbn:
            args.extend([flags.FQBN, CommandBase._strip_arg(fqbn)])
        if output_dir:
            args.extend([flags.OUTPUT_DIR, CommandBase._strip_arg(output_dir)])
        if port:
            args.extend([flags.PORT, CommandBase._strip_arg(port)])
        if preprocess is True:
            args.append(flags.PREPROCESS)
        if show_properties is True:
            args.append(flags.SHOW_PROPERTIES)
        if upload is True:
            args.append(flags.UPLOAD)
        if verify is True:
            args.append(flags.VERIFY)
        if vid_pid:
            args.extend([flags.VID_PID, CommandBase._strip_arg(vid_pid)])
        if warnings:
            args.extend([flags.WARNINGS, CommandBase._strip_arg(warnings)])
        if libraries:
            for l in libraries:
                args.extend([flags.LIBRARIES, CommandBase._strip_arg(l)])
        if library:
            for l in library:
                args.extend([flags.LIBRARY, CommandBase._strip_arg(l)])
        if optimize_for_debug is True:
            args.append(flags.OPTIMIZE_FOR_DEBUG)
        if export_binaries is True:
            args.append(flags.EXPORT_BINARIES)
        if programmer:
            args.extend([flags.PROGRAMMER, CommandBase._strip_arg(programmer)])
        if clean is True:
            args.append(flags.CLEAN)
        if only_compilation_database is True:
            args.append(flags.ONLY_COMPILATION_DATABASE)
        if discovery_timeout:
            args.extend([
                flags.DISCOVERY_TIMEOUT,
                CommandBase._strip_arg(discovery_timeout)
            ])
        if protocol:
            args.extend([flags.PROTOCOL, CommandBase._strip_arg(protocol)])
        args.append(CommandBase._strip_arg(sketch))
        return self._exec(args)