Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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))
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