OSDN Git Service

fix b25 auto deleting and auto move 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-2010 Yukikaze
5 import os
6 import time
7 import recdblist
8 def checkB25Decode(b25filepath, decodedfilepath):
9     ret = 0
10     if os.path.isfile(decodedfilepath):##tsファイルが存在している
11         dtime = time.time()-os.path.getmtime(decodedfilepath)
12         dtime = int(dtime)
13         if dtime > 20:
14             if (compareFilesize(b25filepath, decodedfilepath, 10) and minimizeCheck(decodedfilepath, 800)):
15                 ret = 1
16         else:
17             time.sleep(30)
18             dtime = time.time()-os.path.getmtime(decodedfilepath)
19             dtime = int(dtime)
20             if dtime > 20:
21                 if (compareFilesize(b25filepath, decodedfilepath, 10) and minimizeCheck(decodedfilepath, 800)):
22                     ret = 1
23     #recdblist.printutf8("deleting b25 is " + str(ret))
24     return ret
25 def compareFilesize(pathbase, path, percentage):
26     """
27     return true if size of path is larger than that of pathbase.
28     percentage is int(0< <100)
29     """
30     basesize = os.path.getsize(pathbase)
31     pathsize = os.path.getsize(path)
32     size = pathsize * 100-basesize * percentage
33     if size < 0:
34         return 0
35     else:
36         return 1
37 def minimizeCheck(filepath, minsize):
38     """
39     minsize is Megabytes
40     """
41     if os.path.getsize(filepath) > minsize * 1000 * 1000:
42         return 1
43     else:
44         return 0