Skip to content

Commit

Permalink
BUGFIX: bad import pathname in rebootLogger
Browse files Browse the repository at this point in the history
MINOR: log name fixed for weatherPiArduino
MINOR: consistent header layout in rebootLogger, logger
MINOR: updateCode now creates missing directories
MINOR: crontab now uses different logname for weatherPiArduino
MINOR: code 100 instead of 200 for already running script in
weatherPiArduino
  • Loading branch information
Geoff Munn committed Feb 17, 2017
1 parent d50b875 commit f9df6c0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
6 changes: 4 additions & 2 deletions telemetry/autorun/rebootLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

sys.path.append(os.path.abspath('/home/pi/telemetry/'))
from functions import send_email
from environent_config import wxoutside_sensor_name
from environment_config import wxoutside_sensor_name

date=time.strftime("%Y-%m-%d %H:%M")

Expand All @@ -15,8 +15,10 @@
print ('Message: System restarted at ' + str(date))

header='v1/' + str(wxoutside_sensor_name) + "/system event/" + str(date) + "\n"

body="Action: system restarted\n"
body=body + + 'Time: ' + str(date) + "\n";
body=body + 'Time: ' + str(date) + "\n";
body=body + 'Message: System restarted at ' + str(date) + "\n"
body=body + "Code: 100\n"

send_email('System event response', header + body)
7 changes: 4 additions & 3 deletions telemetry/cron/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def modification_date(filename):

host_name=socket.gethostname()

logs=['am2315', 'aquaflex', 'compaction', 'rebootLogger', 'updateCode', 'weatherPiArduino_controller']
logs=['am2315', 'aquaflex', 'compaction', 'rebootLogger', 'updateCode', 'weatherPiArduino']

for log_name in logs:
filepath='/home/pi/telemetry/logs/' + str(log_name) + '.*.log'
Expand All @@ -37,8 +37,9 @@ def modification_date(filename):

modified_date=modification_date(textfile)

header=str(version) + '/' + str(log_name) + '/' + str(modified_date) + '/' + str(host_name) + "\n"

#header=str(version) + '/' + str(log_name) + '/' + str(modified_date) + '/' + str(host_name) + "\n"
header=str(version) + '/' + str(host_name) + '/' + str(log_name) + '/' + str(modified_date) + "\n"

server = smtplib.SMTP(wxoutside_email_server, wxoutside_email_port)
server.starttls()
server.login(wxoutside_sensor_email, wxoutside_sensor_password)
Expand Down
1 change: 0 additions & 1 deletion telemetry/cron/sendTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
if valid==True and email_sent==False:
json_items=values

#header=str(version) + '/' + str(date) + '/' + str(hour) + '/' + str(host_name) + "\n"
header=str(version) + '/' + host_name + '/telemetry/' + str(date) + ' ' + str(hour) + ':00' + "\n"

for value_item in values:
Expand Down
8 changes: 7 additions & 1 deletion telemetry/cron/updateCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ def get_latest(url):
try:
r = requests.get(url, stream=True)
z = zipfile.ZipFile(StringIO.StringIO(r.content))
z.extractall(path='/home/pi/telemetry/releases')

releases_path='/home/pi/telemetry/releases'

if not os.path.exists(releases_path):
os.makedirs(releases_path)

z.extractall(path=releases_path)

return True

Expand Down
4 changes: 2 additions & 2 deletions telemetry/misc/crontab.master
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
# Run sensors:
1 * * * * /usr/bin/python3 /home/pi/telemetry/sensors/am2315.py > /home/pi/telemetry/logs/am2315.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1
1 * * * * /usr/bin/python /home/pi/telemetry/sensors/aquaflex.py > /home/pi/telemetry/logs/aquaflex.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1
2 * * * * /usr/bin/python /home/pi/telemetry/sensors/weatherPiArduino/weatherPiArduino_controller.py > /home/pi/telemetry/logs/weatherPiArduino.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1
2 * * * * /usr/bin/python /home/pi/telemetry/sensors/weatherPiArduino/weatherPiArduino_controller.py > /home/pi/telemetry/logs/weatherPiArduino_controller.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1

# minute 10 reserved for hardware stats
30 * * * * /usr/bin/python3 /home/pi/telemetry/sensors/am2315.py > /home/pi/telemetry/logs/am2315.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1
31 * * * * /usr/bin/python /home/pi/telemetry/sensors/weatherPiArduino/weatherPiArduino_controller.py > /home/pi/telemetry/logs/weatherPiArduino.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1
31 * * * * /usr/bin/python /home/pi/telemetry/sensors/weatherPiArduino/weatherPiArduino_controller.py > /home/pi/telemetry/logs/weatherPiArduino_controller.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1

# Notifications:
51 * * * * /usr/bin/python /home/pi/telemetry/cron/sendHardwareStats.py > /home/pi/telemetry/logs/sendHardwareStats.log 2>&1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import time

sys.path.append(os.path.abspath('/home/pi/telemetry/'))

from functions import date_time

process_found=False
Expand All @@ -22,8 +21,8 @@

full_date=str(date) + ' ' + str(hour) + ':' + str(minutes)
print ('Time: ' + full_date)
print ('Code: 200')
print ('Code: 100')
print ('Message: Script already running')
exit()

os.system("/home/pi/telemetry/sensors/weatherPiArduino/weatherPiArduino_agent.py")
os.system("/home/pi/telemetry/sensors/weatherPiArduino/weatherPiArduino_agent.py")

0 comments on commit f9df6c0

Please sign in to comment.