<commit_before>#!/usr/bin/python

import commands, time

DEBUG = False

class SmartDisk():
  """
  A class to access information on S.M.A.R.T. disks.

  Usage: (under construction)
  """
  def __init__(self,diskid):
    self.diskid   = "/tmp/ubundiagd/smartinfo-" + diskid
    self.vars     = "-"
    self.health   = "-"
    self.selftest = "-"
    self.identity = commands.getoutput("cat " + self.diskid + "-i.dat").splitlines()
    retm=retd=rets=""
    for line in self.identity:
      if DEBUG:print line
      if (line != ''):
        ls=line.split()
        if (ls[0] == "Model"):
          retm = line.split(': ')[1].strip()
        if (ls[0] == "Device") and (ls[1] == "Model:"):
          retd = line.split(': ')[1].strip()
        if (ls[0] == "Serial"):
          rets = line.split(': ')[1].strip()
    self.identity = retm + " || " + retd + " (" + rets +")"

  def smart(self):
    self.vars     = commands.getoutput("cat " + self.diskid + "-A.dat").splitlines()
    self.health   = commands.getoutput("cat " + self.diskid + "-H.dat")
    self.selftest = commands.getoutput("cat " + self.diskid + "-l.dat")
    if DEBUG:print self.vars
    return 0

  def getdata(self,id):
    ret=""
    for line in self.vars:
      if (line != ''):
        ls=line.split()
        if (ls[0] == id):
          if DEBUG:print line.split()
          ret=ls[9]
    return ret

  def gethealth(self):
    return self.health

  def getlasttest(self):
    return self.selftest

  def getinfo(self):
    return self.identity

if __name__ == '__main__':

  DEBUG = True
<commit_msg>Also read the `*-i.dat` file every time `smart()` is called<commit_after>#!/usr/bin/python

import commands, time

DEBUG = False

class SmartDisk():
  """
  A class to access information on S.M.A.R.T. disks.

  Usage: (under construction)
  """
  def __init__(self,diskid):
    self.diskid   = "/tmp/ubundiagd/smartinfo-" + diskid
    self.vars     = "-"
    self.health   = "-"
    self.selftest = "-"
    self.identity = commands.getoutput("cat " + self.diskid + "-i.dat").splitlines()
    retm=retd=rets=""
    for line in self.identity:
      if DEBUG:print line
      if (line != ''):
        ls=line.split()
        if (ls[0] == "Model"):
          retm = line.split(': ')[1].strip()
        if (ls[0] == "Device") and (ls[1] == "Model:"):
          retd = line.split(': ')[1].strip()
        if (ls[0] == "Serial"):
          rets = line.split(': ')[1].strip()
    self.identity = retm + " || " + retd + " (" + rets +")"

  def smart(self):
    self.vars     = commands.getoutput("cat " + self.diskid + "-A.dat").splitlines()
    self.health   = commands.getoutput("cat " + self.diskid + "-H.dat")
    self.selftest = commands.getoutput("cat " + self.diskid + "-l.dat")

    self.identity = commands.getoutput("cat " + self.diskid + "-i.dat").splitlines()
    retm=retd=rets=""
    for line in self.identity:
      if DEBUG:print line
      if (line != ''):
        ls=line.split()
        if (ls[0] == "Model"):
          retm = line.split(': ')[1].strip()
        if (ls[0] == "Device") and (ls[1] == "Model:"):
          retd = line.split(': ')[1].strip()
        if (ls[0] == "Serial"):
          rets = line.split(': ')[1].strip()
    self.identity = retm + " || " + retd + " (" + rets +")"

    if DEBUG:print self.vars
    return 0

  def getdata(self,id):
    ret=""
    for line in self.vars:
      if (line != ''):
        ls=line.split()
        if (ls[0] == id):
          if DEBUG:print line.split()
          ret=ls[9]
    return ret

  def gethealth(self):
    return self.health

  def getlasttest(self):
    return self.selftest

  def getinfo(self):
    return self.identity

if __name__ == '__main__':

  DEBUG = True

{'fraction_non_alphanumeric': 0.18842530282637954, 'fraction_numerical': 0.007267833109017497, 'mean_word_length': 2.3031111111111113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1816493', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1307, 'n_words': 293}