message: chore(api): factory tools: fix ip address check, cam test
  Use the utility functions in nmcli to find the wifi address instead of the sockets library directly. In addition, just get an image from the camera with the same command as the `/camera/picture` endpoint.
diff: +import asyncio
  import atexit
  import logging
  import optparse
  import os
  -import re
  -import socket
  import subprocess
  from opentrons import robot
  from opentrons.config import infer_config_base_dir
  from opentrons.drivers.rpi_drivers import gpio
  from opentrons.drivers import serial_communication
  +from opentrons.system import nmcli
  log = logging.getLogger(__name__)
  -IP_ADDRESS_SEARCH = re.compile(r'^(\d+\.\d+){3}')
  RESULT_SPACE = '\t- {}'
  FAIL = 'FAIL\t*** !!! ***'
  PASS = 'PASS'
  USB_MOUNT_FILEPATH = '/mnt/usbdrive'
  DATA_FOLDER = str(infer_config_base_dir())
  -VIDEO_FILEPATH = os.path.join(DATA_FOLDER, 'cam_test.mp4')
  +VIDEO_FILEPATH = os.path.join(DATA_FOLDER, 'cam_test.jpg')
  AUDIO_FILE_PATH = '/etc/audio/speaker-test.mp3'
  @@ -46,11 +45,11 @@ def _find_storage_device():
  def _this_wifi_ip_address():
  - gw = os.popen('ip -f inet addr show eth0').read().split()
  - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  - list_ips = [ip for ip in gw if IP_ADDRESS_SEARCH.match(ip)]
  - s.connect((list_ips[0], 0))
  - return s.getsockname()[0]
  + loop = asyncio.get_event_loop()
  + wifi_info = loop.run_until_complete(
  + nmcli.iface_info(nmcli.NETWORK_IFACES.WIFI))
  + assert wifi_info['ipAddress'], 'Not connected to wifi'
  + return wifi_info['ipAddress'].split('/')[0]
  def _erase_data(filepath):
  @@ -230,7 +229,7 @@ def test_speaker():
  def record_camera(filepath):
  print('USB Camera')
  # record 1 second of video from the USB camera
  - c = 'ffmpeg -video_size 320x240 -i /dev/video0 -t 00:00:01 {} -loglevel quiet' # NOQA
  + c = 'ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:1 -frames 1 {}' # NOQA
  try:
  run_quiet_process(c.format(filepath))
  print(RESULT_SPACE.format(PASS))
  