Commit ba6bf1fa authored by Kate Patterson's avatar Kate Patterson
Browse files

Merge branch 'update_app_common' into 'master'

update time formation function os function and slack message

See merge request ceotr/app_common!10
parents 269d0d7b 59cf1bf5
......@@ -28,13 +28,13 @@ class SlackMessenger:
self.project_name = project_name
self.channel = channel
def send_success_message(self, job_name, detail):
def send_success_message(self, job_name, detail, title=None, text=None):
self._set_up_checking()
self.send_message(job_name, detail)
self.send_message(job_name, detail, title=title, text=text)
def send_fail_message(self):
def send_fail_message(self, job_name, detail, title=None, text=None):
self._set_up_checking()
raise NotImplementedError
self.send_message(job_name, detail, status=FAILED, title=title, text=text)
def send_message(self, job_name, detail, status=SUCCEEDED, title=None, text=None):
sending_dict = self.text_dict_maker(job_name, status, detail, title=title, text=text)
......
import os
def is_sudo_user():
uid = os.getuid() if hasattr(os, 'getuid') else 65535
gid = os.getgid() if hasattr(os, 'getgid') else 65535
euid = os.geteuid() if hasattr(os, 'geteuid') else 65535
egid = os.getegid() if hasattr(os, 'getegid') else 65535
return not uid or not gid or not euid or not egid
......@@ -120,3 +120,23 @@ def convert_to_erddap_time_format(time_str):
ret_time_str = ret_time_str.replace(" ", 'T')
ret_time_str = ret_time_str + 'Z'
return ret_time_str
def seconds_to_days_hours_minutes_seconds(seconds):
"""Given second and then convert it into day hour minutes and second"""
days = 0
hours = 0
minutes = 0
if seconds < 60:
n_seconds = seconds
else:
minutes = int(seconds / 60)
n_seconds = seconds - minutes * 60
if minutes > 60:
hours = int(minutes / 60)
minutes = minutes - hours * 60
if hours > 24:
days = int(hours / 24)
hours = hours - days * 24
return days, hours, minutes, n_seconds
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