@ -1,7 +1,7 @@
from couchpotato . core . event import fireEvent , addEvent
from couchpotato . core . event import fireEvent , addEvent
from couchpotato . core . helpers . encoding import ss , toSafeString , \
from couchpotato . core . helpers . encoding import ss , toSafeString , \
toUnicode , sp
toUnicode , sp
from couchpotato . core . helpers . variable import getExt , md5 , isLocalIP , scanForPassword
from couchpotato . core . helpers . variable import getExt , md5 , isLocalIP , scanForPassword , tryInt
from couchpotato . core . logger import CPLog
from couchpotato . core . logger import CPLog
from couchpotato . environment import Env
from couchpotato . environment import Env
import requests
import requests
@ -307,6 +307,42 @@ class Plugin(object):
return ' '
return ' '
def checkFilesChanged ( self , files , unchanged_for = 60 ) :
now = time . time ( )
for cur_file in files :
# File got removed while checking
if not os . path . isfile ( cur_file ) :
file_too_new = now
break
# File has changed in last 60 seconds
file_time = self . self . getFileTimes ( cur_file )
for t in file_time :
if t > now - unchanged_for :
file_too_new = tryInt ( time . time ( ) - t )
break
if file_too_new :
break
if file_too_new :
try :
time_string = time . ctime ( file_time [ 0 ] )
except :
try :
time_string = time . ctime ( file_time [ 1 ] )
except :
time_string = ' unknown '
return file_too_new , time_string
return False , None
def getFileTimes ( self , file_path ) :
return [ os . path . getmtime ( file_path ) , os . path . getctime ( file_path ) if os . name != ' posix ' else 0 ]
def isDisabled ( self ) :
def isDisabled ( self ) :
return not self . isEnabled ( )
return not self . isEnabled ( )