How to use the pyfrc.config.mode 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
def run(self, options, robot_class, **static_options):

        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
github robotpy / pyfrc / pyfrc / mains / cli_profiler.py View on Github external
def run(self, options, robot_class, **static_options):

        print("profiling is not yet implemented for RobotPy 2020")
        return 1

        from .. import config

        config.mode = "profiler"

        try:
            import cProfile
        except ImportError:
            print(
                "Error importing cProfile module for profiling, your python interpreter may not support profiling\n",
                file=sys.stderr,
            )
            return 1

        if len(options.args) == 0:
            print("ERROR: Profiler command requires arguments to run other commands")
            return 1

        file_location = abspath(inspect.getfile(robot_class))
github robotpy / robotpy-wpilib-utilities / robotpy_ext / misc / precise_delay.py View on Github external
stacklevel=2,
        )

        # The WPILib sleep/etc functions are slightly less stable as
        # they have more overhead, so only use them in simulation mode
        if wpilib.RobotBase.isSimulation():

            self.delay = wpilib.Timer.delay
            self.get_now = wpilib.Timer.getFPGATimestamp

            # Test to see if we're in a unit test, and switch the wait function
            # to run more efficiently -- otherwise full tests are dog slow
            try:
                import pyfrc.config

                if pyfrc.config.mode in ("test", "upload"):
                    self.wait = self._wait_unit_tests
            except:
                pass

        else:
            self.delay = time.sleep
            self.get_now = time.monotonic

        self.delay_period = float(delay_period)
        if self.delay_period < 0.001:
            raise ValueError("You probably don't want to delay less than 1ms!")

        self.next_delay = self.get_now() + self.delay_period