code.fastix.org

Dateiansicht:

Datei:Projekte -> Linux,Python:Reale Mounts anzeigen -> show-real-mounts
md5:e9c8e345b8f2f003192b1beb56b60123
sha1:f3ed6a7f4e448ae0d0e535430744348e5b445e87
Download-Link:Download
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Options:
  5. # -w :  wait for a input at end (usefull in grafic envirements)
  6.  
  7. # Config:
  8. extraTypes='fuseblk, fuse.sshfs, nfs, smbfs, cifs, swap';
  9. ###
  10.  
  11. import sys, subprocess, os, time;
  12.  
  13.  
  14. def byte2string ( b ):
  15.     pythonArchitektur = int( sys.version.split( '.' )[0] );
  16.     if 3 == pythonArchitektur:
  17.         return str( b.strip(), 'UTF-8' );
  18.     return str( b.strip() );
  19.  
  20. p = subprocess.Popen( 'which blkid' , shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
  21. out, err = p.communicate();
  22.  
  23. if 0 != p.returncode :
  24.     print ( 'Fatal: Entweder ist das Kein Linux oder ihr Linux ist zu alt dafür...' );
  25.     sys.exit( 1 );
  26.  
  27. out = byte2string( out );
  28.  
  29. o = subprocess.Popen( out + ' -k', shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT );
  30. aShowTypes = o.stdout.readlines() + extraTypes.split( ',' );
  31. aShowTypes.sort();
  32.  
  33. cmd = 'mount | grep -iP \'';
  34.  
  35. c = 0;
  36. for s in aShowTypes :
  37.     s = byte2string( s ).strip( );
  38.     if 0 == c :
  39.         cmd += ' type ' + s + ' ';
  40.     else :
  41.         cmd += '| type ' + s + ' ';
  42.     c += 1;
  43.    
  44. cmd += '\' | sort -t \' \' -k 1';
  45.  
  46. os.system( cmd );
  47.  
  48. if  2 == len( sys.argv ) and '-w' == sys.argv[1] :
  49.         print '';
  50.         z = str( raw_input( '  Press [ENTER] ' ) );
  51.  
  52. print '';
  53.