parameters: (fs_object, as_root=False)
return_statement: return run_cmd(command_line, as_root)
docstring: Delete file/folder, becoming root if necessary. Run some sanity checks on object
docstring_summary: Delete file/folder, becoming root if necessary. Run some sanity checks on object
docstring_tokens: Delete file / folder becoming root if necessary . Run some sanity checks on object
function: def safe_delete(fs_object, as_root=False):
      '''Delete file/folder, becoming root if necessary. Run some sanity checks on object'''
      from os import path
      
      banned_items = [ '/', '/usr', '/usr/bin', '/usr/local', '/bin',
                       '/sbin', '/opt', '/Library', '/System', '/System/Library',
                       '/var', '/tmp', '/var/tmp', '/lib', '/lib64', '/Users',
                       '/home', '/Applications', '/private', '/etc', '/dev',
                       '/Network', '/net', '/proc']
      if path.isdir(fs_object):
          del_opts = "-rf"
      else:
          del_opts = '-f'
  
      if object in banned_items:
          return FslIResult('', FslIResult, 'Will not delete %s!' % (object))
  
      command_line = " ".join(('rm', del_opts, fs_object))
      return run_cmd(command_line, as_root)
function_tokens: def safe_delete ( fs_object , as_root = False ) : from os import path banned_items = [ '/' , '/usr' , '/usr/bin' , '/usr/local' , '/bin' , '/sbin' , '/opt' , '/Library' , '/System' , '/System/Library' , '/var' , '/tmp' , '/var/tmp' , '/lib' , '/lib64' , '/Users' , '/home' , '/Applications' , '/private' , '/etc' , '/dev' , '/Network' , '/net' , '/proc' ] if path . isdir ( fs_object ) : del_opts = "-rf" else : del_opts = '-f' if object in banned_items : return FslIResult ( '' , FslIResult , 'Will not delete %s!' % ( object ) ) command_line = " " . join ( ( 'rm' , del_opts , fs_object ) ) return run_cmd ( command_line , as_root )