Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion restartLiveMon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@
# if it is killed.
# just add this to your crontab:
# */10 * * * * /home/pi/source/ukmon-pitools/restartLiveMon.sh >/dev/null 2>&1
force=0
if [ $# -gt 0 ]
then
force=1
fi
x=$(ps -ef | grep liveMon |wc -l)
if [ $x -lt 2 ]
if [[ $x -lt 2 || $force -eq 1 ]]
then
pids=$(ps -ef | grep liveMon | grep -v grep | awk '{print $2}')
if [ "$pids" != "" ]
then
kill -9 $pids
fi
echo "restarting liveMonitor"
/home/pi/source/ukmon-pitools/liveMonitor.sh >> /home/pi/RMS_data/logs/ukmon-live.log 2>&1 &
fi
24 changes: 14 additions & 10 deletions sendToLive.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,22 @@ def singleUpload(cap_dir, dir_file):
exit(1)

# get credentials
with open(os.path.join(myloc, 'live.key'), 'r') as inif:
lines = inif.readlines()
for li in lines:
if 'AWS_ACCESS_KEY_ID' in li:
awskey = li.split('=')[1].strip()
if 'AWS_SECRET_ACCESS_KEY' in li:
awssec = li.split('=')[1].strip()
if 'AWS_DEFAULT_REGION' in li:
awsreg = li.split('=')[1].strip()
if awssec is None or awskey is None or awsreg is None:
try:
with open(os.path.join(myloc, 'live.key'), 'r') as inif:
lines = inif.readlines()
for li in lines:
if 'AWS_ACCESS_KEY_ID' in li:
awskey = li.split('=')[1].strip()
if 'AWS_SECRET_ACCESS_KEY' in li:
awssec = li.split('=')[1].strip()
if 'AWS_DEFAULT_REGION' in li:
awsreg = li.split('=')[1].strip()
except Exception:
print('unable to locate AWS credentials, aborting')
exit(1)
if awssec is None or awskey is None or awsreg is None:
print('credentials file malformed, aborting')
exit(1)

conn = boto3.Session(aws_access_key_id=awskey, aws_secret_access_key=awssec, region_name=awsreg)
s3 = conn.resource('s3')
Expand Down