#NEWLINE# def _wipe( dev ) : #NEWLINE# #INDENT# '\n    REALLY DESTRUCTIVE STUFF RIGHT AHEAD\n    ' #NEWLINE# endres = 0 #NEWLINE# dev = _devbase ( dev ) #NEWLINE# ( size , block , discard ) = _sizes ( dev ) #NEWLINE# if ( discard is None ) : #NEWLINE# #INDENT# log . error ( 'Unable to read SysFS props for {0}' . format ( dev ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not discard ) : #NEWLINE# #INDENT# log . warning ( '{0} seems unable to discard' . format ( dev ) ) #NEWLINE# wiper = 'dd' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not HAS_BLKDISCARD ) : #NEWLINE# #INDENT# log . warning ( 'blkdiscard binary not available, properly wipe the dev manually for optimal results' ) #NEWLINE# wiper = 'dd' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# wiper = 'blkdiscard' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# wipe_failmsg = 'Error wiping {0}: {{0}}' . format ( dev ) #NEWLINE# if ( wiper == 'dd' ) : #NEWLINE# #INDENT# blocks = 4 #NEWLINE# cmd = 'dd if=/dev/zero of=/dev/{0} bs=1M count={1}' . format ( dev , blocks ) #NEWLINE# endres += _run_all ( cmd , 'warn' , wipe_failmsg ) #NEWLINE# cmd += ' seek={0}' . format ( ( ( size / ( 1024 ** 2 ) ) - blocks ) ) #NEWLINE# endres += _run_all ( cmd , 'warn' , wipe_failmsg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wiper == 'blkdiscard' ) : #NEWLINE# #INDENT# cmd = 'blkdiscard /dev/{0}' . format ( dev ) #NEWLINE# endres += _run_all ( cmd , 'warn' , wipe_failmsg ) #NEWLINE# endres = 1 #NEWLINE# #UNINDENT# #UNINDENT# return ( endres > 0 )