code.fastix.org

Dateiansicht:

Datei:Projekte -> Linux,Python:Reale Mounts anzeigen -> show_real_mounts
md5:b931957ac2a041f70e63d6343ed05eb1
sha1:4d3bbd4c98af0d63ee86f58e809f089848930954
Download-Link:Download
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys, subprocess, os;
  5.  
  6. def byte2string ( b ):
  7.     pythonArchitektur = int( sys.version.split( '.' )[0] );
  8.     if 3 == pythonArchitektur:
  9.         return str( b.strip(), "UTF-8" );
  10.     return str( b.strip() );
  11.  
  12. p = subprocess.Popen( 'which blkid' , shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
  13. out, err = p.communicate();
  14.  
  15. if 0 != p.returncode:
  16.     print ( 'Fatal: Entweder ist das Kein Linux oder ihr Linux ist zu alt dafür...' );
  17.     sys.exit( 1 );
  18.  
  19. out = byte2string( out );
  20.  
  21. o = subprocess.Popen( out + ' -k', shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT );
  22. aShowTypes = o.stdout.readlines();
  23.  
  24. cmd = 'mount | grep -P "';
  25.  
  26. c = 0;
  27. for s in aShowTypes:
  28.     s = byte2string( s );
  29.     if 0 == c :
  30.         cmd += ' type ' + s + ' ';
  31.     else:
  32.         cmd += '| type ' + s + ' ';
  33.     c += 1;
  34.    
  35. cmd += '|type fuseblk"|sort';
  36.  
  37. os.system( cmd );
  38.