@@ -1305,7 +1305,10 @@ class Global(object):
1305
1305
def __init__ (self ):
1306
1306
self .path = os .path .join (os .path .expanduser ("~" ), '.mbed' )
1307
1307
if not os .path .exists (self .path ):
1308
- os .mkdir (self .path )
1308
+ try :
1309
+ os .mkdir (self .path )
1310
+ except (IOError , OSError ):
1311
+ pass
1309
1312
1310
1313
def get_cfg (self , * args , ** kwargs ):
1311
1314
return Cfg (self .path ).get (* args , ** kwargs )
@@ -1327,7 +1330,7 @@ def set(self, var, val):
1327
1330
try :
1328
1331
with open (fl ) as f :
1329
1332
lines = f .read ().splitlines ()
1330
- except IOError :
1333
+ except ( IOError , OSError ) :
1331
1334
lines = []
1332
1335
1333
1336
for line in lines :
@@ -1338,16 +1341,20 @@ def set(self, var, val):
1338
1341
if not val is None :
1339
1342
lines += [var + "=" + val ]
1340
1343
1341
- with open (fl , 'w' ) as f :
1342
- f .write ('\n ' .join (lines ) + '\n ' )
1344
+ try :
1345
+ with open (fl , 'w' ) as f :
1346
+ f .write ('\n ' .join (lines ) + '\n ' )
1347
+ except (IOError , OSError ):
1348
+ warning ("Unable to write config file %s" % fl )
1349
+ pass
1343
1350
1344
1351
# Gets config value
1345
1352
def get (self , var , default_val = None ):
1346
1353
fl = os .path .join (self .path , self .file )
1347
1354
try :
1348
1355
with open (fl ) as f :
1349
1356
lines = f .read ().splitlines ()
1350
- except IOError :
1357
+ except ( IOError , OSError ) :
1351
1358
lines = []
1352
1359
1353
1360
for line in lines :
0 commit comments