Esempio n. 1
0
 def _runiteration(self):
     self._expire_blacklist()
     profiledir = self._config['common']['profiledir']
     factory = makerbot_driver.BotFactory(profiledir)
     available = self._detector.get_available_machines().copy()
     self._log.debug('self._available = %r', self._available)
     self._log.debug('available = %r', available)
     self._log.debug('blacklist = %r', self._blacklist)
     for portname in self._blacklist.keys():
         if portname in available:
             del available[portname]
     self._log.debug('available (post blacklist) = %r', available)
     old_keys = set(self._available.keys())
     new_keys = set(available.keys())
     detached = old_keys - new_keys
     attached = new_keys - old_keys
     self._log.debug('detached = %r', detached)
     self._log.debug('attached = %r', attached)
     for portname in detached:
         self._server.removeprinter(portname)
     if len(attached) > 0:
         for portname in attached:
             try:
                 s3g, profile = factory.build_from_port(portname, True)
                 printerid = available[portname]['iSerial']
                 fp = s3g.writer.file
                 s3gprinterthread = S3gPrinterThread(
                     self._server, self._config, portname, printerid,
                     profile, fp)
                 s3gprinterthread.start()
                 self._server.appendprinter(portname, s3gprinterthread)
             except:
                 self._log.exception('unhandled exception')
                 self.blacklist(portname)
     self._available = available.copy()
Esempio n. 2
0
 def setUp(self):
     self.s3g_mock = mock.Mock(makerbot_driver.s3g)
     self.inquisitor = makerbot_driver.BotInquisitor('/dev/dummy_port')
     self.inquisitor.create_s3g = mock.Mock()
     self.inquisitor.create_s3g.return_value = self.s3g_mock
     self.factory = makerbot_driver.BotFactory()
     self.factory.create_inquisitor = mock.Mock()
     self.factory.create_inquisitor.return_value = self.inquisitor
Esempio n. 3
0
 def test_leaves_bot_open(self):
     ignore = raw_input("Please Verify a valid MakerBot is connected(Y/n)>")
     self.assertEqual(ignore.lower(), 'Y'.lower())
     md = makerbot_driver.MachineDetector()
     md.scan()
     availMachine = md.get_first_machine()
     self.assertTrue(availMachine != None)
     print(availMachine)
     bFact = makerbot_driver.BotFactory()
     s3gObj, profile = bFact.build_from_port(availMachine, False)
     # re-opening s3g here fails
     self.assertFalse(s3gObj.is_open())
Esempio n. 4
0
                  help="The port you want to connect to (OPTIONAL)", default=None)
parser.add_option("-m", "--machine_type", dest="machine",
                  help="machine type", default="The Replicator")
parser.add_option("-v", "--version", dest="version",
                  help="The version of eeprom you want to read",
                  default="5.6"
                  )
parser.add_option("-o", "--output_file", dest="output_file",
                  help="The file you want to write out to")
(options, args) = parser.parse_args()

if options.port == None:
  md = makerbot_driver.MachineDetector()
  md.scan(options.machine)
  port = md.get_first_machine()
  if port is None:
    print "Cant Find %s" %(options.machine)
    sys.exit()
else:
  port = options.port
factory = makerbot_driver.BotFactory()
r, prof = factory.build_from_port(port)

reader = makerbot_driver.EEPROM.EepromReader.factory(r, fw_version=options.version)

entire_map = reader.read_entire_map()

dump = json.dumps(entire_map, sort_keys=True, indent=2)
with open(options.output_file, 'w') as f:
  f.write(dump)
Esempio n. 5
0
 def setUp(self):
     self.factory = makerbot_driver.BotFactory()