parameters: (device)
docstring: Checks that storage is writable and if not makes it writable.
  
    Arguments:
      device: The device to check.
docstring_summary: Checks that storage is writable and if not makes it writable.
docstring_tokens: Checks that storage is writable and if not makes it writable .
function: def CheckExternalStorage(device):
    """Checks that storage is writable and if not makes it writable.
  
    Arguments:
      device: The device to check.
    """
    try:
      with device_temp_file.DeviceTempFile(
          device.adb, suffix='.sh', dir=device.GetExternalStoragePath()) as f:
        device.WriteFile(f.name, 'test')
    except device_errors.CommandFailedError:
      logging.info('External storage not writable. Remounting / as RW')
      device.RunShellCommand(['mount', '-o', 'remount,rw', '/'],
                             check_return=True, as_root=True)
      device.EnableRoot()
      with device_temp_file.DeviceTempFile(
          device.adb, suffix='.sh', dir=device.GetExternalStoragePath()) as f:
        device.WriteFile(f.name, 'test')
function_tokens: def CheckExternalStorage ( device ) : try : with device_temp_file . DeviceTempFile ( device . adb , suffix = '.sh' , dir = device . GetExternalStoragePath ( ) ) as f : device . WriteFile ( f . name , 'test' ) except device_errors . CommandFailedError : logging . info ( 'External storage not writable. Remounting / as RW' ) device . RunShellCommand ( [ 'mount' , '-o' , 'remount,rw' , '/' ] , check_return = True , as_root = True ) device . EnableRoot ( ) with device_temp_file . DeviceTempFile ( device . adb , suffix = '.sh' , dir = device . GetExternalStoragePath ( ) ) as f : device . WriteFile ( f . name , 'test' )