Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > fa1a1504a73b9e93566ca09d8ed490c4 > files > 25

digitemp-3.6.0-10.mga5.x86_64.rpm

#!/bin/env python

# Initalize the indicated serial port and continuously read the temperatures
# and graph them in a window. Show the discovered sensors and allow the user
# to select the color associated with it. 
# Also allow them to control the refresh rate.

""" DigiTemp PyGTK Graph display """

import string, os, sys, time, gtk


dt = {}

# Initalize the 1-wire network, print out whatever it says
def init_1wire():
   cmd = "digitemp -i -q -o\"T %R %N %.2C\" -O\"C %R %N %n %C\""
   for outline in os.popen(cmd).readlines()
      outline = outline[:-1];
      print outline

   # Ought to be able to check return code for success/failure


# Read all attached sensors
def read_sensors():
   cmd = "digitemp -a -q -o1"
   for outline in os.popen(cmd).readlines():
      outline = outline[:-1]
      S = string.split( outline, " " )

      if S[0] == 'T':
         # Add the temperature reading to a dictionary
         dt[S[1]] = S[3]

      if S[0] == 'C':
         # Add the counter reading to a dictionary
         dt[S[1]] = S[3]