Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Alt
cb-util
Commits
17cfb156
Commit
17cfb156
authored
2 years ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
moved function to extract the timestamp from env here
parent
6fd2f46a
No related branches found
No related tags found
No related merge requests found
Pipeline
#50887
passed
2 years ago
Stage: test
Stage: deploy
Stage: trigger
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cbutil/util.py
+14
-0
14 additions, 0 deletions
cbutil/util.py
with
14 additions
and
0 deletions
cbutil/util.py
+
14
−
0
View file @
17cfb156
import
logging
import
logging
import
operator
import
operator
import
os
import
os
import
time
from
datetime
import
datetime
from
datetime
import
datetime
from
functools
import
reduce
from
functools
import
reduce
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -71,5 +73,17 @@ def time_conversion(time_stamp, *, pattern="%Y-%m-%d %H:%M:%S"):
...
@@ -71,5 +73,17 @@ def time_conversion(time_stamp, *, pattern="%Y-%m-%d %H:%M:%S"):
return
int
(
dt
.
timestamp
())
return
int
(
dt
.
timestamp
())
def
get_time_stamp_from_env
(
key
=
'
CI_PIPELINE_CREATED_AT
'
):
"""
Try to get the time stamp from the environment and
convert it to an int. If that fails use the current time
"""
try
:
return
time_conversion
(
os
.
environ
[
key
])
except
KeyError
:
logger
.
debug
(
f
'
Could not find timestamp with $
{
key
}
'
)
return
int
(
time
.
time
())
def
get_from_nested_dict
(
nested_dict
,
keys
):
def
get_from_nested_dict
(
nested_dict
,
keys
):
return
reduce
(
operator
.
getitem
,
keys
,
nested_dict
)
return
reduce
(
operator
.
getitem
,
keys
,
nested_dict
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment