<commit_before>import os
import os.path
import logging
import subprocess


class StorageDevices:
    @classmethod
    def disableNCQ(cls):
        devices = cls._getSSDDeviceNames()
        if not devices:
            logging.info('Did not find any non-rotational storage devices on which to disable NCQ.')
            return
        logging.info('Disabling NCQ for the following SSD devices: {}...'.format(devices))
        for device in devices:
            try:
                queueDepthPath = '/sys/block/{}/device/queue_depth'.format(device)
                logging.info(sh.run('busybox echo 1 > {}'.format(queueDepthPath)))
                logging.info(sh.run('busybox echo "{} is now:" '.format(queueDepthPath)))
                logging.info(sh.run('busybox cat {}'.format(queueDepthPath)))
            except Exception, ex:
                logging.info(ex.message)

    @classmethod
    def findFirstDeviceOfType(cls, deviceType, talkToServer=None):
        if deviceType == "SSD":
            devices = cls._getSSDDeviceNames()
        else:
            assert deviceType == "HDD", deviceType
            devices = cls._getHDDDeviceNames()
        if not devices:
            if talkToServer is not None:
                talkToServer.targetDeviceTypeNotFound(deviceType)
            raise Exception("Could not find a %s device to be used as a target device" % (deviceType,))
        logging.info("The following devices were found: %s" % (",".join(devices),))
        devicePath = os.path.join("/dev", devices[0])
        return devicePath

    @classmethod
    def readSmartDataFromAllDevices(cls):<commit_msg>Print the whole traceback instead of the exception message when failing to disable NCQ<commit_after>import os
import os.path
import logging
import traceback
import subprocess


class StorageDevices:
    @classmethod
    def disableNCQ(cls):
        devices = cls._getSSDDeviceNames()
        if not devices:
            logging.info('Did not find any non-rotational storage devices on which to disable NCQ.')
            return
        logging.info('Disabling NCQ for the following SSD devices: {}...'.format(devices))
        for device in devices:
            try:
                queueDepthPath = '/sys/block/{}/device/queue_depth'.format(device)
                logging.info(sh.run('busybox echo 1 > {}'.format(queueDepthPath)))
                logging.info(sh.run('busybox echo "{} is now:" '.format(queueDepthPath)))
                logging.info(sh.run('busybox cat {}'.format(queueDepthPath)))
            except:
                logging.info(traceback.format_exc())

    @classmethod
    def findFirstDeviceOfType(cls, deviceType, talkToServer=None):
        if deviceType == "SSD":
            devices = cls._getSSDDeviceNames()
        else:
            assert deviceType == "HDD", deviceType
            devices = cls._getHDDDeviceNames()
        if not devices:
            if talkToServer is not None:
                talkToServer.targetDeviceTypeNotFound(deviceType)
            raise Exception("Could not find a %s device to be used as a target device" % (deviceType,))
        logging.info("The following devices were found: %s" % (",".join(devices),))
        devicePath = os.path.join("/dev", devices[0])
        return devicePath

    @classmethod
    def readSmartDataFromAllDevices(cls):
{'fraction_non_alphanumeric': 0.10306490384615384, 'fraction_numerical': 0.001201923076923077, 'mean_word_length': 2.453319502074689, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '1855167', 'n_tokens_mistral': 900, 'n_tokens_neox': 881, 'n_words': 248}