def __init__(self, exchange, symbol, contract_type, dry_run=True): Observable.__init__(self) self.id = None self.dry_run = dry_run self.exchange = exchange self.symbol = symbol.replace('_', '/').upper() self.contract_type = contract_type self.id = Contract.id Contract.id += 1 self.status = Contract.Status.NONE self.order_type = None self.price = None self.cost = None self.margin = 0 self.margin_rate = 0 self.fee = 0 self.guarantee = 20 self.amount = 0 self.filled = 0 self.remaining = 0 self.lever_rate = 10 self.timestamp = None
def __init__(self, id, vieja=None): Observable.__init__(self, id) self.vieja = None if vieja is not None: self.vieja = vieja else: self.vieja = Vieja()
def _init_(self, house): name = "Default" attack = 0 #compiler said to initialize these health = 0 Observable.__init__(self) self.add_observer(house)
def __init__(self, neighborhood, x, y): Observable.__init__(self) self.population = random.randrange(0, 10, 1) self.monsterMash = [] self.humansSaved = 0 self.add_observer(neighborhood) for i in range(0, self.population): pickMonster = random.randint(0, 3) monsterMash = self.monsterMash if (pickMonster == 0): monster = ghoul(self) monsterMash.append(monster) elif (pickMonster == 1): monster = vampire(self) monsterMash.append(monster) elif (pickMonster == 2): monster = zombie(self) monsterMash.append(monster) else: monster = werewolf(self) monsterMash.append(monster) self.myX = x self.myY = y if (self.population == 0): self.updateNeighborhood(self)
def __init__(self, conffile): Observable.__init__(self) cp = ConfigParser() cp.read(conffile) if not Globals.globSimulate: wiringpi.wiringPiSetupGpio() self.md = MotorDriver([ cp.getint("MotorDriver", "LEFT_L"), cp.getint("MotorDriver", "LEFT_R"), cp.getint("MotorDriver", "RIGHT_L"), cp.getint("MotorDriver", "RIGHT_R"), cp.getint("MotorDriver", "VERTICAL_L"), cp.getint("MotorDriver", "VERTICAL_R"), ]) self.md.start() self.ds = DistanceSensor( cp.getint("DistanceSensor", "TRIGGER"), cp.getint("DistanceSensor", "ECHO") ) self.ds.start() self.acl = AltitudeControlLoop(self.md, self.ds) self.update("MotorDriver", self.md) self.update("DistanceSensor", self.ds) self.update("AltitudeControlLoop", self.acl) self.md.subscribe(self.update) self.ds.subscribe(self.update) self.acl.subscribe(self.update) self.setCamera(False)
def __init__(self, button=None): ''' (Observable, Button) -> None Initialize a ButtonObservable object ''' Observable.__init__(self) self.button = button self.template = ''
def __init__(self, pt, pe): threading.Thread.__init__(self) Observable.__init__(self) self.pinTrigger = pt self.pinEcho = pe if not Globals.globSimulate: wiringpi.pinMode(self.pinTrigger, GPIO_OUTPUT) wiringpi.pinMode(self.pinEcho, GPIO_INPUT)
def __init__(self, playerName, address, port): Thread.__init__(self, name="PlayerClient-"+str(playerName)) Observable.__init__(self) self.address = address self.port = port #initialize the socket that this player will use self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.playerName = playerName #data received from the server self.data = None #connect to the server self.connect()
def __init__(self, host, port, myRam, nodeName, instructionFile): Observable.__init__(self) self.myRam = myRam self.nodeName = nodeName self.diskAccessCount = 0 self.localCacheHitCount = 0 self.neighbourCacheHitCount = 0 self.diskAccessCount = 0 self.localCacheHitCount = 0 self.instructionSheet = [] if instructionFile: self.instructionSheet = InstructionParser.getInstructionFromFile(instructionFile)
def __init__(self, exchange, symbol, period, contract_type): Observable.__init__(self) self.exchange = exchange self.symbol = symbol self.period = period self.contract_type = contract_type self.name = 'K[%s/%s/%s/%s]' % (self.exchange.name, self.symbol, self.period, self.contract_type) self.last_period = None self.speed = _K.SLOW self.k = None self.started = False logger.info('New K instance %s' % self.name)
def __init__(self, pins): threading.Thread.__init__(self) Observable.__init__(self) if len(pins) != 6: raise "MotorDriver needs 6 pins" self.motorPins = pins if not Globals.globSimulate: for pn in range(0, 6): pin = self.motorPins[pn] wiringpi.pinMode(pin, GPIO_OUTPUT) wiringpi.pinMode(18, GPIO_PWM) wiringpi.pwmWrite(18, self.pwmValue)
def __init__(self, game, rows, columns): self.hauntedHouses = rows * columns; #houses = [[house() for x in range(columns)] for y in range(rows)]; #This nested for loop will fill the board with new houses in a grid. Observable.__init__(self); r = rows c = columns self.add_observer(game); for x in range(0, c): self.houses.append([]); for y in range(0, r): newHome = house(self, x, y); newHome.add_observer(self); self.houses[x].append(newHome); self.hauntedHouses = self.hauntedHouses + 1;
def __init__(self, serialNumber, baudRate, device): Observable.__init__(self) # Attributes: self.setSerialNumber(serialNumber) # (string) self.__device = device self.__bytesize = serial.EIGHTBITS self.__parity = serial.PARITY_NONE self.__stopbits = serial.STOPBITS_ONE self.__xonxoff = 0 self.__connection = None self.__messageSize = None #we set the baud rate depending on the type of microcontroller self.__baudrate = baudRate #we open the connection try: self.__connection = serial.Serial(port=self.__device, baudrate=self.__baudrate, bytesize=self.__bytesize, parity=self.__parity, stopbits=self.__stopbits, xonxoff=self.__xonxoff) except serial.SerialException: print "Unable to connect to the device!"
def __init__(self, result_queue): print("[ StepperH ] initialising") self.result_queue = result_queue GPIO.setmode(GPIO.BCM) GPIO.setup(DIR, GPIO.OUT) GPIO.setup(STEP, GPIO.OUT) GPIO.output(DIR, CCW) Observable.__init__(self) self.amount_of_steps = 0 self.steps_taken = 1 self.delay = 0.06 self.count = 5 self.running = True # to stop stepper from main thread in the end self.sm = StateMachine.get_stepperh_machine(self, StepperH._states) print("[ StepperH ] Set delay between steps to " + str(self.delay) + "s") print("[ StepperH ] initialized")
def __init__(self, game): Observable.__init__(self) self.add_observer(game) self.health = random.randrange(0, 25) + 100 self.attack = random.randrange(0, 10) + 10 startingWeapon = HersheyKisses() self.inventory.append(startingWeapon) for i in range(0, 9): startingGear = random.randint(0, 2) if (startingGear == 0): candy = chocolateBars() self.inventory.append(candy) elif (startingGear == 1): candy = nerdBombs() self.inventory.append(candy) else: candy = sourStraw() self.inventory.append(candy)
def __init__(self, sock, server): '''Initialize a new PlayerHandler to communicate with the client's game engine''' #create a new Thread to handle this Player's Communication Thread.__init__(self, name="PlayerHandler"+str(PlayerHandler.PID)) #initialize the parent Observable.__init__(self) #assign our unique ID self.pid = PlayerHandler.PID #increment the PID for the next player PlayerHandler.PID+=1 #my name self.playerName = 'BOB' #server instance self.server = server #the socket connection for this Player self.sock = sock #data to be sent down the socket self.data = None #ack the connection self.ack()
def __init__(self, listenAddress="127.0.0.1", listenPort=8080): AbstractModule.__init__(self) threading.Thread.__init__(self) Observable.__init__(self) # Attributes: self.__oscInterpreters = [] # (OscInterpreter) self.setListenAddress(listenAddress) # (string) self.setListenPort(listenPort) # (int) self.__inSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.__inSocket.settimeout(10) self.__active = False #runnables for the CLI self.runnables.append("getActive()") self.runnables.append("setActive(bool active)") self.runnables.append("getListenPort()") self.runnables.append("setListenPort(int listenPort)") self.runnables.append("getListenAddress()") self.runnables.append("setListenAddress(string listenAddress)") self.runnables.append("addOscInterpreter(OscInterpreter obj)") self.runnables.append("removeOscInterpreter(OscInterpreter obj)")
def __init__(self, oscAddressPatternPrefix, hostAddress="127.0.0.1", hostPort=8000): AbstractModule.__init__(self) Observable.__init__(self) # Attributes: self.setOscAddressPatternPrefix(oscAddressPatternPrefix) # (string) if self.__oscAddressPatternPrefix.endswith("/"): self.setOscAddressPatternPrefix(self.__oscAddressPatternPrefix[:-1]) self.setHostAddress(hostAddress) # (string) self.setHostPort(hostPort) # (int) self.__msgBuffer = [] # (OscMsg[]) self.__outSocket = None#socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.__active = False #runnables for the CLI self.runnables.append("getActive()") self.runnables.append("setActive(bool active)") self.runnables.append("getHostAddress()") self.runnables.append("setHostAddress(string hostAddress)") self.runnables.append("getHostPort()") self.runnables.append("setHostPort(int hostPort)") self.runnables.append("getOscAddressPatternPrefix()") self.runnables.append("setOscAddressPatternPrefix(string oscAddressPatternPrefix)")
def __init__(self, path): Observable.__init__(self) self.player = amaroKPlayer(self) self.monitor = amaroKMonitor(self, sys.stdin) self.contextBrowser = amaroKContextBrowser(self, path)
def __init__(self, parent): amaroKObject.__init__(self, parent) Observable.__init__(self)
def __init__(self, device): self.device = device #AbstractDevice Observable.__init__(self) self.__acceptedAddressPrefixesIn = [] # (string[])
def __init__(self): Observable.__init__(self) self.__oscInterpreter = None self.__oscOut = [] # (MonomeOscOut)
def __init__(self, field, **options): Observable.__init__(self, **options) self.field = field
def __init__(self, house): self.attack = 0 self.health = 200 Observable.__init__(self) self.add_observer(house) self.name = "werewolf"
def __init__(self): dict.__init__(self) Observable.__init__(self) self.load()
def __init__(self, house): self.attack = 10 self.health = random.randrange(0, 50) + 50 Observable.__init__(self) self.add_observer(house) self.name = "zombie"
def __init__(self, house): self.attack = 15; self.health = random.randrange(0,40) + 40 Observable.__init__(self); self.add_observer(house); self.name = "ghoul"
def __init__(self, action = None, data=None): Observable.__init__(self) self._action = action self._data = data
def __init__(self, house): self.attack = 10 self.health = random.randrange(0, 100) + 100 Observable.__init__(self) self.add_observer(house) self.name = "vampire"
def __init__(self, name, menu_id, title, subtitle, description): GalleryObject.__init__(self, menu_id, title, subtitle) Observable.__init__(self) self.__name = name self.__description = description
def __init__(self, model): Observable.__init__(self) self.model = model
def __init__(self, parent, filepath): Thread.__init__(self) self.setDaemon(True) amaroKObject.__init__(self, parent) Observable.__init__(self)
def __init__(self): self.__contained = [] Observable.__init__(self)
def __init__(self): Observable.__init__(self) Thread.__init__(self) if Globals.globFakeCamera: self.cmd = ["./fakecam.py", "fakecam.mjpg"]
def __init__(self, md, ds): Observable.__init__(self) self.motorDriver = md self.distanceSensor = ds self.distanceSensor.subscribe(self.update)