2014-08-21, 11:01
Hello all,
I have recently come across an error with my Python script.
I am very new to python so it's probably just a really simple problem.
I have written a little script that will check if my external hard drive is mounted.
It does this by checking if a file is available on the drive.
But XBMC always returns "else: < invalid syntax on line 19".
I have tried different solutions that I have found on Google but none seem to work.
Here is the script:
Thank you for any help in advance
I have recently come across an error with my Python script.
I am very new to python so it's probably just a really simple problem.
I have written a little script that will check if my external hard drive is mounted.
It does this by checking if a file is available on the drive.
But XBMC always returns "else: < invalid syntax on line 19".
I have tried different solutions that I have found on Google but none seem to work.
Here is the script:
PHP Code:
import os
import os.path
import xbmc
import time
#This is the drive that the script will check for
PATH = xbmc.getinfolabel('Skin.String(DriveMount)')
#This will put everything in to a loop
while True:
#This will check the drive and see if the Drive file is available
#If the file exists it will notify the user saying the drive is mounted
if os.path.isfile(PATH + 'Drive.xbe') and os.access(PATH + 'Drive.xbe', os.R_OK):
print "File exists and is readable"
xbmc.executebuiltin('Notification(External Storage, Your external drive is mounted and ready to use,5000,)')
return False
#If the drive isn't mounted or file isn't available then it will search again
else:
xbmc.executebuiltin('Dialog.Close(1929)')
print "Either file is missing or is not readable"
#Sleep for a few seconds to lower CPU usage
time.sleep(5)
while False:
#This will make sure that the drive is mounted
#When unmounted it will then watch to see if it is mounted again
if os.path.isfile(PATH + 'Drive.xbe') and os.access(PATH + 'Drive.xbe', os.R_OK):
print "File exists and is readable"
#If the drive isn't mounted then it will start over
else:
print "Either file is missing or is not readable"
return True
#Sleep for a few seconds to lower CPU usage
time.sleep(5)
Thank you for any help in advance