def setUp(self): self.handle = mock.Mock() self.handle.connect = mock.Mock() self.handle.sendall = mock.Mock() self.handle.recv.return_value = '' self.handle.close = mock.Mock() socket.socket = mock.Mock(return_value=self.handle) urllib2.urlopen = mock.Mock() self.makerbot = makerbotapi.Makerbot('169.254.0.79', auto_connect=False)
#!/usr/bin/python import makerbotapi import sys if __name__ == '__main__': if len(sys.argv) < 2: print "args: <ip address of your gen5> [<AUTH CODE>]" sys.exit(1) ip_address = sys.argv[1] if len(sys.argv) > 2: AUTH_CODE = sys.argv[2] else: AUTH_CODE = None makerbot = makerbotapi.Makerbot(ip_address, auth_code=AUTH_CODE) if AUTH_CODE == None: print "Press the flashing action button on your makerbot now" makerbot.authenticate_fcgi() print "Authenticated with code ", makerbot.auth_code makerbot.authenticate_json_rpc() botstate = makerbot.get_system_information() # print "State:", botstate.state # print "Extruder Temp:", botstate.extruder_temp # print "Preheat:", botstate.preheat_percent, "%" toolhead = botstate.toolheads[0] print "Tool ID: ", toolhead.tool_id