def __init__(self, owners: list, balance: float, administration): if owners: self.owners = owners else: raise TypeError( 'Expected list of Customer object(s) in self.owners, but got empty list []' ) for owner in self.owners: owner.bank_accounts.append(self) self.interest = None self.balance = balance self.minimum_bal = 30 self.overdraft_fee = 5 self.max_owner_qty = 2 self.administration = administration self.administration.add_account( self) # add this account to Administration's list of accounts # vv I need to change this! vv self.account_number = str( randint(10000000000, 99999999999)) # generates random number as account number self.history = {'Deposits': [], 'Withdrawals': [], 'Fees': []} self.doc_manager = DocManager(self, 'BankStatement.txt', 'BankNotices.txt')
def __init__(self, address, oplog_checkpoint, target_url, ns_set, u_key, auth_key, doc_manager=None, auth_username=None): file = inspect.getfile(inspect.currentframe()) cmd_folder = os.path.realpath(os.path.abspath(os.path.split(file)[0])) if doc_manager is not None: doc_manager = imp.load_source('DocManager', doc_manager) else: from doc_manager import DocManager time.sleep(1) super(Connector, self).__init__() #can_run is set to false when we join the thread self.can_run = True #The name of the file that stores the progress of the OplogThreads self.oplog_checkpoint = oplog_checkpoint #main address - either mongos for sharded setups or a primary otherwise self.address = address #The URL of the target system self.target_url = target_url #The set of relevant namespaces to consider self.ns_set = ns_set #The key that is a unique document identifier for the target system. #Not necessarily the mongo unique key. self.u_key = u_key #Password for authentication self.auth_key = auth_key #Username for authentication self.auth_username = auth_username #The set of OplogThreads created self.shard_set = {} #Dict of OplogThread/timestamp pairs to record progress self.oplog_progress = LockingDict() try: if target_url is None: if doc_manager is None: # imported using from... import self.doc_manager = DocManager(unique_key=u_key) else: # imported using load source self.doc_manager = doc_manager.DocManager(unique_key=u_key) else: if doc_manager is None: self.doc_manager = DocManager(self.target_url, unique_key=u_key) else: self.doc_manager = doc_manager.DocManager(self.target_url, unique_key=u_key) except SystemError: logging.critical("MongoConnector: Bad target system URL!") self.can_run = False return if self.oplog_checkpoint is not None: if not os.path.exists(self.oplog_checkpoint): info_str = "MongoC`onnector: Can't find OplogProgress file!" logging.critical(info_str) self.doc_manager.stop() self.can_run = False