OSDN Git Service

d3e1615421bae7bac23d7498efbb97ef6a8ee2ec
[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 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 > 120:
14             if (compareFilesize(b25filepath, decodedfilepath, 10) and minimizeCheck(decodedfilepath, 800)):
15                 ret = 1
16         else:
17             time.sleep(100)
18             if dtime > 120:
19                 if (compareFilesize(b25filepath, decodedfilepath, 10) and minimizeCheck(decodedfilepath, 800)):
20                     ret = 1
21     #recdblist.printutf8("delete b25 is " + str(ret))
22     return ret
23 def compareFilesize(pathbase, path, percentage):
24     """
25     return true if size of path is larger than that of pathbase.
26     percentage is int(0< <100)
27     """
28     basesize = os.path.getsize(pathbase)
29     pathsize = os.path.getsize(path)
30     size = pathsize * 100-basesize * percentage
31     if size < 0:
32         return 0
33     else:
34         return 1
35 def minimizeCheck(filepath, minsize):
36     """
37     minsize is Megabytes
38     """
39     print os.path.getsize(filepath)
40     if os.path.getsize(filepath) > minsize * 1000 * 1000:
41         return 1
42     else:
43         return 0