Below is the file 'System.py' from this revision. You can also download the file.
#!/usr/bin/env python # what do we need to track in System # # 1/ Location of Journal Store # 2/ Location of Ledger Store # 3/ Location of Chart of Accounts Store # # 4/ Max Journal ID # # # # Store as a shelf from time import time, sleep from Error import * from States import * from Store import Store import os, os.path class System: def __init__(self): #VS self.events = [] # self.connected = False self.file = None #self.db = None #self.cursor = None self.store = None pass def status(self): pass def next_event(self, timeout = None): if timeout < 0: timeout = 0 if len(self.events) > 0: timeout = 0 # while True: # (r, _, _) = select([self.rfh], [], [], timeout) # if r: # self.get_response(async = True) # timeout = 0 # else: # break if len(self.events) == 0: return (TICK, time()) ret = self.events[0] del self.events[0] return ret def connect_store(self,filename): # need to check file exists # readable/writeable by user # FIXME more checks needed print os.path.exists(filename) print not os.path.exists(filename) if not os.path.exists(filename): raise ConnectError self.store = Store() self.connected = self.store.connect(filename) self.file = filename def create_store(self,filename): # need to check file does not exists # dir is readable/writeable by user # FIXME more checks needed if os.path.exists(filename): raise CreateError self.store = Store() self.connected = self.store.create(filename) self.file = filename