OSDN Git Service

fix epg refreshing bugs.(use xml which used before with no error)
[rec10/rec10-git.git] / rec10 / trunk / src / checker.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
5 import time
6 import os
7 def checkB25Decode(b25filepath,decodedfilepath):
8     if os.path.isfile(decodedfilepath):##tsファイルが存在している
9         dtime=time.time()-os.path.getmtime(decodedfilepath)
10         dtime=int(dtime)
11         if dtime > 120 :
12             return compareFilesize(b25filepath,decodedfilepath,10) and minimizeCheck(decodedfilepath, 1000)
13         else:
14             time.sleep(100)
15             if dtime > 120 :
16                 return compareFilesize(b25filepath,decodedfilepath,10) and minimizeCheck(decodedfilepath, 1000)
17     return 0
18 def compareFilesize(pathbase,path,percentage):
19     """
20     return true if size of path is larger than that of pathbase.
21     percentage is int(0< <100)
22     """
23     basesize=os.path.getsize(pathbase)
24     pathsize=os.path.getsize(path)
25     size=pathsize*100-basesize*percentage
26     if size<0:
27         return 0
28     else:
29         return 1
30 def minimizeCheck(filepath,minsize):
31     """
32     minsize is Megabytes
33     """
34     if os.path.getsize(filepath)>minsize*1000*1000:
35         return 1
36     else:
37         return 0