Commit ab91a878 authored by James Coyle's avatar James Coyle

Merge branch 'james-dev' into 'master'

Bug fix

See merge request !17
parents 123c36a7 1dee8419
Pipeline #1264 failed with stages
in 47 minutes and 59 seconds
...@@ -12,6 +12,7 @@ stages: ...@@ -12,6 +12,7 @@ stages:
- deploy - deploy
- cleanup - cleanup
- db - db
- github
set-pypirc: set-pypirc:
...@@ -80,3 +81,13 @@ update_db: ...@@ -80,3 +81,13 @@ update_db:
- python3 update-db.py - python3 update-db.py
tags: tags:
- storjapi - storjapi
update_github:
stage: github
only:
- master
script:
- git remote add github [email protected]:JAC2703/storjstatus-client.git
- git push github master
tags:
- storjapi
...@@ -4,7 +4,7 @@ import argparse ...@@ -4,7 +4,7 @@ import argparse
import getpass import getpass
import json import json
import os import os
from os.path import expanduser import os.path
import requests import requests
import socket import socket
import ctypes import ctypes
...@@ -256,12 +256,21 @@ def cron_job(): ...@@ -256,12 +256,21 @@ def cron_job():
cron_job_linux() cron_job_linux()
def cron_job_linux(): def cron_job_linux():
tmp_cron = '/tmp/storjstatus.cron'
result = storjstatus_common.subprocess_result(['which', 'storjstatus-send']) result = storjstatus_common.subprocess_result(['which', 'storjstatus-send'])
if 'storjstatus-send' in result[0].decode('utf-8'): if 'storjstatus-send' in result[0].decode('utf-8'):
send_command = result[0].decode('utf-8').replace('\n', '') + ' >> /var/log/storjstatus.log 2>&1' send_command = result[0].decode('utf-8').replace('\n', '') + ' >> /var/log/storjstatus.log 2>&1'
cron = CronTab(tabfile='/etc/crontab', user=False) if os.path.isfile('/etc/crontab'):
cron_path = '/etc/crontab'
elif os.path.isfile('/etc/anacrontab'):
cron_path = '/etc/anacrontab'
else:
cron_path = tmp_cron
cron = CronTab(tabfile=cron_path, user=False)
# Check for existing cronjob and remove # Check for existing cronjob and remove
cron.remove_all(comment='storjstatus') cron.remove_all(comment='storjstatus')
...@@ -279,12 +288,11 @@ def cron_job_linux(): ...@@ -279,12 +288,11 @@ def cron_job_linux():
minute = cron_minute(minute) minute = cron_minute(minute)
job.minute.also.on(minute) job.minute.also.on(minute)
try: if cron_path == tmp_cron:
cron.write() print('*************************WARNING************************************')
storjstatus_common.subprocess_result(['service', 'cron', 'reload']) print('Could not find your system cronfile, please add a cron manually for:')
print("Cron set for: " + job.render()) print(' ' + job.render())
except PermissionError: print('*************************WARNING************************************')
print_error('Unable to create cron job. Exiting.')
else: else:
print_error('There was an error finding the storjstatus-send command. Check your storjstatus installation.') print_error('There was an error finding the storjstatus-send command. Check your storjstatus installation.')
......
__version__ = '0.3.3' __version__ = '0.3.5'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment