<commit_before>#!/usr/bin/env python
"""
Usage: python home.py [<serial>]

This program homes all APT controllers found, or the one specified
"""

import time
import pylibftdi
import pyAPT

def main(args):
  print 'Looking for APT controllers'
  drv = pylibftdi.Driver()
  controllers = drv.list_devices()
  serial = args[1]

  if serial:
    controllers = filter(lambda x:x[2] == serail, controllers)

  if controllers:
    for con in controllers:
      print 'Found %s %s S/N: %s'%con
      with pyAPT.Controller(serial_number=con[2]) as con:
        print '\tIdentifying controller'
        con.identify()
        print '\tResetting controller parameters'
        con.reset_params()
        print '\tHoming parameters:', con.request_home_params()
        print '\tHoming stage...',
        con.home(velocity=1)
        print 'homed'

      return 0
  else:
    print '\tNo APT controllers found. Maybe you need to specify a PID'
    return 1

if __name__ == '__main__':
  import sys
  sys.exit(main(sys.argv))
<commit_msg>Fixes a command line argument parse error in home.py<commit_after>#!/usr/bin/env python
"""
Usage: python home.py [<serial>]

This program homes all APT controllers found, or the one specified
"""

import time
import pylibftdi
import pyAPT

def main(args):
  print 'Looking for APT controllers'
  drv = pylibftdi.Driver()
  controllers = drv.list_devices()

  if len(args)>1:
    serial = args[1]
  else:
    serial = None

  if serial:
    controllers = filter(lambda x:x[2] == serail, controllers)

  if controllers:
    for con in controllers:
      print 'Found %s %s S/N: %s'%con
      with pyAPT.Controller(serial_number=con[2]) as con:
        print '\tIdentifying controller'
        con.identify()
        print '\tResetting controller parameters'
        con.reset_params()
        print '\tHoming parameters:', con.request_home_params()
        print '\tHoming stage...',
        con.home(velocity=1)
        print 'homed'

      return 0
  else:
    print '\tNo APT controllers found. Maybe you need to specify a PID'
    return 1

if __name__ == '__main__':
  import sys
  sys.exit(main(sys.argv))

{'fraction_non_alphanumeric': 0.10908239700374532, 'fraction_numerical': 0.006086142322097378, 'mean_word_length': 2.97951582867784, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3880080', 'n_tokens_mistral': 715, 'n_tokens_neox': 675, 'n_words': 215}