buildframework/helium/tools/common/python/scripts/searchnextdrive.py
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
    20 """
    20 """
    21     Script that prints the next free drive on the current system.
    21     Script that prints the next free drive on the current system.
    22     If none available it returns "Error: No free drive!". 
    22     If none available it returns "Error: No free drive!". 
    23     win32 only!
    23     win32 only!
    24 """
    24 """
    25 import string
    25 from fileutils import get_next_free_drive
    26 from win32api import GetLogicalDriveStrings
    26 def search_next_free_drive():
       
    27     try:
       
    28         return get_next_free_drive()
       
    29     except Exception, e:
       
    30         return "Error: No free drive!"
    27 
    31 
    28 DRIVE_LABELS = sorted(list(set(string.ascii_uppercase) - set(GetLogicalDriveStrings())), reverse=True)
    32 if __name__ == "__main__":
    29 if len(DRIVE_LABELS) != 0 :
    33     print search_next_free_drive()
    30     print DRIVE_LABELS[0] + ":"
       
    31 else:
       
    32     print "Error: No free drive!"
       
    33         
       
    34