Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CEOTR Public
app_common
Commits
59cf1bf5
Commit
59cf1bf5
authored
Oct 11, 2019
by
xaingling
Browse files
update time formation function os function and slack message
parent
60ff4395
Changes
3
Hide whitespace changes
Inline
Side-by-side
app_common/slack_message/slack_message.py
View file @
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
)
...
...
app_common/utilities/os_function.py
0 → 100644
View file @
59cf1bf5
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
app_common/utilities/time_format_functions.py
View file @
59cf1bf5
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment