comparison Generic/durusdatabase.py @ 5:6502bfdaa84d

update import durus database
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Sat, 06 Nov 2010 21:30:33 +0100
parents 2ac1551ad2ab
children 0359329a1c26
comparison
equal deleted inserted replaced
4:4e976a99efb9 5:6502bfdaa84d
19 ## You should have received a copy of the GNU General Public License 19 ## You should have received a copy of the GNU General Public License
20 ## along with this program. If not, see <http://www.gnu.org/licenses/>. 20 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
21 21
22 # Modules 22 # Modules
23 import os.path 23 import os.path
24 import time
24 # Durus Modules 25 # Durus Modules
25 from durus.file_storage import FileStorage 26 from durus.file_storage import FileStorage
26 from durus.connection import Connection 27 from durus.connection import Connection
28 # pyArq Presupuestos Modules
29 from Generic import utils
27 30
28 class DurusFile(object): 31 class DurusFile(object):
29 def __init__(self, file, new): 32 def __init__(self, file, new):
30 self.__file = file 33 self.__file = file
31 if new: 34 if new:
42 45
43 def setBudget(self, budget): 46 def setBudget(self, budget):
44 self.__root["budget"] = budget 47 self.__root["budget"] = budget
45 self.__connection.commit() 48 self.__connection.commit()
46 49
50 class Read(object):
51 def __init__(self, filename=None, budget=None):
52 self.__budget = budget
53 self.__filename = filename
54 self.__cancel = False
55
56 def cancel(self):
57 """def cancel(self)
58
59 It do nothing
60 """
61 # TODO: Cancel reading Durus database.
62 self.__cancel = True
63
64 def readFile(self, budget=None, filename=None, interface=None):
65 if not filename is None:
66 self.__filename = filename
67 if self.__filename is None or self.__cancel == True:
68 return None
69 if not os.path.exists(self.__filename):
70 return None
71 print utils.mapping(_("Loading file: $1:"), (self.__filename,))
72 _time = time.time()
73 _durus_file = DurusFile(self.__filename, False)
74 self.__budget = _durus_file.getBudget()
75 _durus_file.close()
76 print utils.mapping(_("Loadig time: $1 seconds"),
77 (("%.2f" %(time.time()-_time)),))
78 return self.__budget