# Path: chirp/common/conf.py



import getopt
import os
import re
import subprocess
import sys
from chirp.common.conf import MOUNT_BY_HDSN_ROOT
    return ["/dev/" + name for name in all_names]


def get_serial_number(dev_name):
    """Get a hard drive's serial number by using hdparm."""
    hdparm_cmd = [HDPARM_BIN, "-I", dev_name]
    hdparm = subprocess.Popen(hdparm_cmd, stdout=subprocess.PIPE)
    ret_code = hdparm.wait()
    assert ret_code == 0
    match = re.search("Serial Number:\s+(.+)$",
                     hdparm.stdout.read(), re.MULTILINE)
    return match and  match.group(1)


def do_mount():
    """Mount all data drives."""
    sys.stderr.write("+++ Mounting CHIRP data drives\n")

    # Compute the list of partitions that are alone on a device.
    # These are the only ones we attempt to mount.
    all_partitions = get_all_partitions()
    has_other_parts = set(p[:-1] for p in all_partitions
                          if not p.endswith("1"))
    part1_only = [p for p in all_partitions
                  if p.endswith("1") and not p[:-1] in has_other_parts]

    for dev_name in part1_only:
        serial_num = get_serial_number(dev_name)
        assert serial_num


# Path: chirp/common/conf.py



# Path: chirp/sysadmin/do_automount.py
import getopt
import os
import re
import subprocess
import sys
from chirp.common.conf import MOUNT_BY_HDSN_ROOT

    return ["/dev/" + name for name in all_names]


def get_serial_number(dev_name):
    """Get a hard drive's serial number by using hdparm."""
    hdparm_cmd = [HDPARM_BIN, "-I", dev_name]
    hdparm = subprocess.Popen(hdparm_cmd, stdout=subprocess.PIPE)
    ret_code = hdparm.wait()
    assert ret_code == 0
    match = re.search("Serial Number:\s+(.+)$",
                     hdparm.stdout.read(), re.MULTILINE)
    return match and  match.group(1)


def do_mount():
    """Mount all data drives."""
    sys.stderr.write("+++ Mounting CHIRP data drives\n")

    # Compute the list of partitions that are alone on a device.
    # These are the only ones we attempt to mount.
    all_partitions = get_all_partitions()
    has_other_parts = set(p[:-1] for p in all_partitions
                          if not p.endswith("1"))
    part1_only = [p for p in all_partitions
                  if p.endswith("1") and not p[:-1] in has_other_parts]

    for dev_name in part1_only:
        serial_num = get_serial_number(dev_name)
        assert serial_num


        mount_dir = os.path.join(MOUNT_BY_HDSN_ROOT, serial_num)