How to use the pyfrc.util.print_err function in pyfrc

To help you get started, we’ve selected a few pyfrc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
from .. import config

        config.mode = "upload"

        # run the test suite before uploading
        # TODO: disabled for 2020
        if False and not options.skip_tests:
            from .cli_test import PyFrcTest

            tester = PyFrcTest()

            retval = tester.run_test(
                [], robot_class, options.builtin, ignore_missing_test=True
            )
            if retval != 0:
                print_err("ERROR: Your robot tests failed, aborting upload.")
                if not sys.stdin.isatty():
                    print_err("- Use --skip-tests if you want to upload anyways")
                    return retval

                print()
                if not yesno("- Upload anyways?"):
                    return retval

                if not yesno("- Are you sure? Your robot code may crash!"):
                    return retval

                print()
                print("WARNING: Uploading code against my better judgement...")

        # upload all files in the robot.py source directory
        robot_file = abspath(inspect.getfile(robot_class))
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
config.mode = "upload"

        # run the test suite before uploading
        # TODO: disabled for 2020
        if False and not options.skip_tests:
            from .cli_test import PyFrcTest

            tester = PyFrcTest()

            retval = tester.run_test(
                [], robot_class, options.builtin, ignore_missing_test=True
            )
            if retval != 0:
                print_err("ERROR: Your robot tests failed, aborting upload.")
                if not sys.stdin.isatty():
                    print_err("- Use --skip-tests if you want to upload anyways")
                    return retval

                print()
                if not yesno("- Upload anyways?"):
                    return retval

                if not yesno("- Are you sure? Your robot code may crash!"):
                    return retval

                print()
                print("WARNING: Uploading code against my better judgement...")

        # upload all files in the robot.py source directory
        robot_file = abspath(inspect.getfile(robot_class))
        robot_path = dirname(robot_file)
        robot_filename = basename(robot_file)
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
controller.ssh_exec_commands(sshcmd, True)
            except sshcontroller.SshExecError as e:
                doret = True
                if e.retval == 87:
                    print_err(
                        "ERROR: python3 was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 88:
                    print_err(
                        "ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
                elif e.retval == 91:
                    # Not an error; ssh in as admin and fix the startup dlls (Saves 24M of RAM)
                    # -> https://github.com/wpilibsuite/EclipsePlugins/pull/154
                    logger.info("Fixing StartupDLLs to save RAM...")
                    controller.username = "admin"
                    controller.ssh_exec_commands(
                        'sed -i -e "s/^StartupDLLs/;StartupDLLs/" /etc/natinst/share/ni-rt.ini',
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
print()
                print("WARNING: Uploading code against my better judgement...")

        # upload all files in the robot.py source directory
        robot_file = abspath(inspect.getfile(robot_class))
        robot_path = dirname(robot_file)
        robot_filename = basename(robot_file)
        cfg_filename = join(robot_path, ".deploy_cfg")

        if not options.nonstandard and robot_filename != "robot.py":
            print_err(
                "ERROR: Your robot code must be in a file called robot.py (launched from %s)!"
                % robot_filename
            )
            print_err()
            print_err(
                "If you really want to do this, then specify the --nonstandard argument"
            )
            return 1

        # This probably should be configurable... oh well

        deploy_dir = PurePosixPath("/home/lvuser")
        py_deploy_subdir = "py"
        py_new_deploy_subdir = "py_new"
        py_deploy_dir = deploy_dir / py_deploy_subdir

        # note below: deployed_cmd appears that it only can be a single line

        # In 2015, there were stdout/stderr issues. In 2016, they seem to
        # have been fixed, but need to use -u for it to really work properly
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
)

            controller.ssh_connect()

            try:
                # Housekeeping first
                logger.debug("SSH: %s", sshcmd)
                controller.ssh_exec_commands(sshcmd, True)
            except sshcontroller.SshExecError as e:
                doret = True
                if e.retval == 87:
                    print_err(
                        "ERROR: python3 was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 88:
                    print_err(
                        "ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
if e.retval == 87:
                    print_err(
                        "ERROR: python3 was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 88:
                    print_err(
                        "ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
                elif e.retval == 91:
                    # Not an error; ssh in as admin and fix the startup dlls (Saves 24M of RAM)
                    # -> https://github.com/wpilibsuite/EclipsePlugins/pull/154
                    logger.info("Fixing StartupDLLs to save RAM...")
                    controller.username = "admin"
                    controller.ssh_exec_commands(
                        'sed -i -e "s/^StartupDLLs/;StartupDLLs/" /etc/natinst/share/ni-rt.ini',
                        True,
                    )
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
"ERROR: python3 was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 88:
                    print_err(
                        "ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
                elif e.retval == 91:
                    # Not an error; ssh in as admin and fix the startup dlls (Saves 24M of RAM)
                    # -> https://github.com/wpilibsuite/EclipsePlugins/pull/154
                    logger.info("Fixing StartupDLLs to save RAM...")
                    controller.username = "admin"
                    controller.ssh_exec_commands(
                        'sed -i -e "s/^StartupDLLs/;StartupDLLs/" /etc/natinst/share/ni-rt.ini',
                        True,
                    )

                    controller.username = "lvuser"
                    doret = False
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
logger.debug("SSH: %s", sshcmd)
                controller.ssh_exec_commands(sshcmd, True)
            except sshcontroller.SshExecError as e:
                doret = True
                if e.retval == 87:
                    print_err(
                        "ERROR: python3 was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 88:
                    print_err(
                        "ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
                elif e.retval == 91:
                    # Not an error; ssh in as admin and fix the startup dlls (Saves 24M of RAM)
                    # -> https://github.com/wpilibsuite/EclipsePlugins/pull/154
                    logger.info("Fixing StartupDLLs to save RAM...")
                    controller.username = "admin"
                    controller.ssh_exec_commands(
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
try:
                # Housekeeping first
                logger.debug("SSH: %s", sshcmd)
                controller.ssh_exec_commands(sshcmd, True)
            except sshcontroller.SshExecError as e:
                doret = True
                if e.retval == 87:
                    print_err(
                        "ERROR: python3 was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 88:
                    print_err(
                        "ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
                elif e.retval == 91:
                    # Not an error; ssh in as admin and fix the startup dlls (Saves 24M of RAM)
                    # -> https://github.com/wpilibsuite/EclipsePlugins/pull/154
                    logger.info("Fixing StartupDLLs to save RAM...")
github robotpy / pyfrc / pyfrc / mains / cli_deploy.py View on Github external
"ERROR: WPILib was not found on the roboRIO: have you installed robotpy?"
                    )
                elif e.retval == 89:
                    print_err("ERROR: expected WPILib version %s" % wpilib.__version__)
                    print_err()
                    print_err("You should either:")
                    print_err(
                        "- If the robot version is older, upgrade the RobotPy on your robot"
                    )
                    print_err("- Otherwise, upgrade pyfrc on your computer")
                    print_err()
                    print_err(
                        "Alternatively, you can specify --no-version-check to skip this check"
                    )
                elif e.retval == 90:
                    print_err("ERROR: error running compileall")
                elif e.retval == 91:
                    # Not an error; ssh in as admin and fix the startup dlls (Saves 24M of RAM)
                    # -> https://github.com/wpilibsuite/EclipsePlugins/pull/154
                    logger.info("Fixing StartupDLLs to save RAM...")
                    controller.username = "admin"
                    controller.ssh_exec_commands(
                        'sed -i -e "s/^StartupDLLs/;StartupDLLs/" /etc/natinst/share/ni-rt.ini',
                        True,
                    )

                    controller.username = "lvuser"
                    doret = False
                else:
                    print_err("ERROR: %s" % e)

                if doret: