directory permission check, non zero return status

This commit is contained in:
Nimesh Ghelani 2016-01-17 17:14:46 +05:30
parent 344b227c2b
commit 395dd59718

View file

@ -547,6 +547,15 @@ def nonnegative_int(string):
raise argparse.ArgumentTypeError("Track gain value should be in range 0-99") raise argparse.ArgumentTypeError("Track gain value should be in range 0-99")
return intval return intval
def checkPathValidity(path):
if not os.path.isdir(result.path):
print "Error finding IPod directory. Maybe it is not connected or mounted?"
sys.exit(1)
if not os.access(result.path, os.W_OK):
print 'Unable to get write permissions in the IPod directory'
sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--disable-voiceover', action='store_true', help='Disable Voiceover Feature') parser.add_argument('--disable-voiceover', action='store_true', help='Disable Voiceover Feature')
@ -555,9 +564,7 @@ if __name__ == '__main__':
parser.add_argument('path') parser.add_argument('path')
result = parser.parse_args() result = parser.parse_args()
if not os.path.isdir(result.path): checkPathValidity(result.path)
print "Error finding IPod directory. Maybe it is not connected or mounted?"
sys.exit()
if result.rename_unicode: if result.rename_unicode:
check_unicode(result.path) check_unicode(result.path)