#!/usr/bin/python import sys import time import glob import os import commands import MySQLdb path = '/opt/tempberrypi' def getVarFromFile(filename): import imp f = open(filename) global data data = imp.load_source('data', '', f) f.close() getVarFromFile(path + '/etc/TBp1.conf') def getColorFromFile(filename): import imp f = open(filename) global color color = f.readlines() f.close() getColorFromFile(path + '/etc/color_hex.txt') from random import randint colors = [] for i in range(10): colors.append('%06X' % randint(0, 0xFFFFFF)) # find the path of a sensor directory that starts with 28 db = MySQLdb.connect(data.servername,data.username,data.password,data.dbname) cursor = db.cursor() def temp_status(): # Select qSQL with id=4. server_temperature = "Fahrenheit" cursor.execute("SELECT value FROM sensors_system WHERE name = 'server_temperature'") #data = cursor.fetchall() #print "data = "+str(data[1]) row = cursor.fetchone() if row: server_temperature = row[0] return server_temperature server_temperature = temp_status() i = 1 textdata = '' sensadata = '' cursor.execute("SELECT * FROM sensors_info WHERE sensor_plot = 'on' AND sensor_type = 'Temperature' ORDER BY sid ASC") #print "data = "+str(data[1]) #row = cursor.fetchone() row = cursor.fetchall() for row in cursor: if (row[4] == "on" and row[5] == "yes" and row[7] == "on"): name = row[1] if (row[3] != ''): name = row[3] sensadata = sensadata + " DEF:temp"+str(i)+"=/opt/tempberrypi/rrds/sensortemp.rrd:temp"+str(i)+":MAX LINE"+str(i)+":temp"+str(i)+""+color[i].strip('\r\n')+":\""+ str(name) + "\"" print "sensadata"+str(sensadata)+"" i = i + 1 plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) continue cursor.execute("SELECT * FROM sensors_info WHERE sensor_plot = 'on' AND sensor_type = 'Soil Sensor' ORDER BY sid ASC") #print "data = "+str(data[1]) #row = cursor.fetchone() row = cursor.fetchall() for row in cursor: if (row[4] == "on" and row[5] == "yes" and row[7] == "on"): name = row[1] if (row[3] != ''): name = row[3] #print "ID="+str(row[1])+"" i = i + 1 plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_atemp_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_atemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_atemp_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_atemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_atemp_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_atemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_atemp_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_atemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_atemp_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_atemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_stemp_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_stemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_stemp_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_stemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_stemp_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_stemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_stemp_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_stemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_stemp_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_stemp.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_light_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_light.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_light_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_light.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_light_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_light.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_light_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_light.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_light_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_light.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_humidity_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_humidity.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_humidity_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_humidity.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_humidity_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_humidity.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_humidity_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_humidity.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_humidity_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_humidity.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist1_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist1.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist1_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist1.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist1_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist1.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist1_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist1.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist1_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist1.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist2_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist2.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist2_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist2.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist2_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist2.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist2_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist2.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist2_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist2.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist3_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist3.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist3_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist3.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist3_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist3.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist3_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist3.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist3_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist3.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) plot_1h = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist4_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist4.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1h) plot_1d = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist4_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist4.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1d) plot_1w = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist4_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist4.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1w) plot_1m = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist4_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist4.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1m) plot_1y = '/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/' + str(row[1]) + '_moist4_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label "Temperature ' + server_temperature + '" DEF:temp1=/opt/tempberrypi/rrds/' + str(row[1]) + '_moist4.rrd:temp1:MAX LINE1:temp1#0000FF:"' + str(name) + '"' os.system(plot_1y) continue cursor.close () db.close() plot_h = "/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/sensortemp_1h.png -h 500 -w 700 -a PNG --slope-mode --start -3600 --end now --vertical-label 'Temperature " + server_temperature + "' " + sensadata plot_d = "/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/sensortemp_1d.png -h 500 -w 700 -a PNG --slope-mode --start -86400 --end now --vertical-label 'Temperature " + server_temperature + "' " + sensadata plot_w = "/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/sensortemp_1w.png -h 500 -w 700 -a PNG --slope-mode --start -604800 --end now --vertical-label 'Temperature " + server_temperature + "' " + sensadata plot_m = "/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/sensortemp_1m.png -h 500 -w 700 -a PNG --slope-mode --start -2628000 --end now --vertical-label 'Temperature " + server_temperature + "' " + sensadata plot_y = "/usr/bin/rrdtool graph /opt/tempberrypi/www/plots/sensortemp_1y.png -h 500 -w 700 -a PNG --slope-mode --start -31536000 --end now --vertical-label 'Temperature " + server_temperature + "' " + sensadata plot_h_out = commands.getoutput(plot_h) plot_d_out = commands.getoutput(plot_d) plot_w_out = commands.getoutput(plot_w) plot_m_out = commands.getoutput(plot_m) plot_y_out = commands.getoutput(plot_y) chown = "chown -R www-data:www-data /opt/tempberrypi/www/plots" chown_out = commands.getoutput(chown) commands.getoutput("/bin/rm ./c") sys.exit()