@@ -1231,6 +1231,30 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg):
1231
1231
os .environ ['MAVLINK20' ] = '1'
1232
1232
mavversion = "2"
1233
1233
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
+
1234
1258
if __name__ == '__main__' :
1235
1259
from optparse import OptionParser
1236
1260
parser = OptionParser ("mavproxy.py [options]" )
@@ -1301,6 +1325,7 @@ def set_mav_version(mav10, mav20, autoProtocol, mavversionArg):
1301
1325
parser .add_option ("--version" , action = 'store_true' , help = "version information" )
1302
1326
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' )
1303
1327
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" )
1304
1329
1305
1330
(opts , args ) = parser .parse_args ()
1306
1331
if len (args ) != 0 :
@@ -1482,27 +1507,8 @@ def quit_handler(signum = None, frame = None):
1482
1507
elif opts .aircraft is not None :
1483
1508
mpstate .aircraft_dir = opts .aircraft
1484
1509
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 ()
1506
1512
1507
1513
if opts .cmd is not None :
1508
1514
for cstr in opts .cmd :
0 commit comments