<commit_before>#!/usr/bin/env python
from flask import Flask
from flask.ext.restful import abort, Resource, Api
import envoy

app = Flask(__name__)
api = Api(app)
ROOT_DEVICE_DIR = '/sys/bus/w1/devices'

def get_thermometers():
	r = envoy.run('ls %s' % ROOT_DEVICE_DIR)
	therms = [therm for therm in r.std_out.split('\n') if len(therm) > 0]
	return therms

class Thermometer(Resource):
	def get(self, therm_id):
		f=open(os.path.join(ROOT_DEVICE_DIR,therm_id), 'r')
		result=f.readlines()
		f.close()
		if "YES" in result[0]:
			return {'raw': result[1].replace('\n', '').split('t=')[1]}
	        else:
		    abort(500, "Thermometer not found")


class Thermometers(Resource):
    def get(self):
        return get_thermometers()

api.add_resource(Thermometers, '/thermometers')
api.add_resource(Thermometer, '/thermometers/<string:therm_id>')<commit_msg>fixed path for reading thermometer file<commit_after>#!/usr/bin/env python
from flask import Flask
from flask.ext.restful import abort, Resource, Api
import envoy
import os

app = Flask(__name__)
api = Api(app)
ROOT_DEVICE_DIR = '/sys/bus/w1/devices'

def get_thermometers():
	r = envoy.run('ls %s' % ROOT_DEVICE_DIR)
	therms = [therm for therm in r.std_out.split('\n') if len(therm) > 0]
	return therms

class Thermometer(Resource):
	def get(self, therm_id):
		f=open(os.path.join(ROOT_DEVICE_DIR,therm_id,'w1_slave'), 'r')
		result=f.readlines()
		f.close()
		if "YES" in result[0]:
			return {'raw': result[1].replace('\n', '').split('t=')[1]}
	        else:
		    abort(500, "Thermometer not found")


class Thermometers(Resource):
    def get(self):
        return get_thermometers()

api.add_resource(Thermometers, '/thermometers')
api.add_resource(Thermometer, '/thermometers/<string:therm_id>')
{'fraction_non_alphanumeric': 0.1553784860557769, 'fraction_numerical': 0.009675583380762664, 'mean_word_length': 4.782894736842105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7171730', 'n_tokens_mistral': 703, 'n_tokens_neox': 662, 'n_words': 144}