OSDN Git Service

stop using trunk directory in rectool
[rec10/rec10-git.git] / rec10 / branches / 0.9.0 / 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 def checkB25Decode(b25filepath, decodedfilepath):
8     ret = 0
9     if os.path.isfile(decodedfilepath):##tsファイルが存在している
10         dtime = time.time()-os.path.getmtime(decodedfilepath)
11         dtime = int(dtime)
12         if dtime > 120:
13             if (compareFilesize(b25filepath, decodedfilepath, 10) and minimizeCheck(decodedfilepath, 800)):
14                 ret = 1
15         else:
16             time.sleep(100)
17             if dtime > 120:
18                 if (compareFilesize(b25filepath, decodedfilepath, 10) and minimizeCheck(decodedfilepath, 800)):
19                     ret = 1
20     #print "delete b25 is " + str(ret)
21     return ret
22 def compareFilesize(pathbase, path, percentage):
23     """
24     return true if size of path is larger than that of pathbase.
25     percentage is int(0< <100)
26     """
27     basesize = os.path.getsize(pathbase)
28     pathsize = os.path.getsize(path)
29     size = pathsize * 100-basesize * percentage
30     if size < 0:
31         return 0
32     else:
33         return 1
34 def minimizeCheck(filepath, minsize):
35     """
36     minsize is Megabytes
37     """
38     print os.path.getsize(filepath)
39     if os.path.getsize(filepath) > minsize * 1000 * 1000:
40         return 1
41     else:
42         return 0