Skip to content

Commit 502db79

Browse files
committed
mavproxy.py: add option to not run startup scripts
for future use in ArduPilot's autotest
1 parent 3192cae commit 502db79

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

MAVProxy/mavproxy.py

+27-21
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,30 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg):
12311231
os.environ['MAVLINK20'] = '1'
12321232
mavversion = "2"
12331233

1234+
def run_startup_scripts():
1235+
start_scripts = []
1236+
if not opts.setup:
1237+
if 'HOME' in os.environ:
1238+
start_scripts.append(os.path.join(os.environ['HOME'], ".mavinit.scr"))
1239+
start_script = mp_util.dot_mavproxy("mavinit.scr")
1240+
start_scripts.append(start_script)
1241+
if (mpstate.settings.state_basedir is not None and
1242+
opts.aircraft is not None):
1243+
start_script = os.path.join(mpstate.aircraft_dir, "mavinit.scr")
1244+
start_scripts.append(start_script)
1245+
for start_script in start_scripts:
1246+
if os.path.exists(start_script):
1247+
print("Running script (%s)" % (start_script))
1248+
run_script(start_script)
1249+
1250+
if opts.aircraft is not None:
1251+
start_script = os.path.join(opts.aircraft, "mavinit.scr")
1252+
if os.path.exists(start_script):
1253+
run_script(start_script)
1254+
else:
1255+
print("no script %s" % start_script)
1256+
1257+
12341258
if __name__ == '__main__':
12351259
from optparse import OptionParser
12361260
parser = OptionParser("mavproxy.py [options]")
@@ -1301,6 +1325,7 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg):
13011325
parser.add_option("--version", action='store_true', help="version information")
13021326
parser.add_option("--default-modules", default="log,signing,wp,rally,fence,ftp,param,relay,tuneopt,arm,mode,calibration,rc,auxopt,misc,cmdlong,battery,terrain,output,adsb,layout", help='default module list')
13031327
parser.add_option("--udp-timeout",dest="udp_timeout", default=0.0, type='float', help="Timeout for udp clients in seconds")
1328+
parser.add_option("--no-startup-scripts", action='store_true', help="Do not run .mavinit.scr and other startup scripts")
13041329

13051330
(opts, args) = parser.parse_args()
13061331
if len(args) != 0:
@@ -1482,27 +1507,8 @@ def quit_handler(signum = None, frame = None):
14821507
elif opts.aircraft is not None:
14831508
mpstate.aircraft_dir = opts.aircraft
14841509

1485-
start_scripts = []
1486-
if not opts.setup:
1487-
if 'HOME' in os.environ:
1488-
start_scripts.append(os.path.join(os.environ['HOME'], ".mavinit.scr"))
1489-
start_script = mp_util.dot_mavproxy("mavinit.scr")
1490-
start_scripts.append(start_script)
1491-
if (mpstate.settings.state_basedir is not None and
1492-
opts.aircraft is not None):
1493-
start_script = os.path.join(mpstate.aircraft_dir, "mavinit.scr")
1494-
start_scripts.append(start_script)
1495-
for start_script in start_scripts:
1496-
if os.path.exists(start_script):
1497-
print("Running script (%s)" % (start_script))
1498-
run_script(start_script)
1499-
1500-
if opts.aircraft is not None:
1501-
start_script = os.path.join(opts.aircraft, "mavinit.scr")
1502-
if os.path.exists(start_script):
1503-
run_script(start_script)
1504-
else:
1505-
print("no script %s" % start_script)
1510+
if not opts.no_startup_scripts:
1511+
run_startup_scripts()
15061512

15071513
if opts.cmd is not None:
15081514
for cstr in opts.cmd:

0 commit comments

Comments
 (0)