FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-lambda-local/lambda_local/context.py at master · suzil/python-lambda-local · GitHub
suzil
/
python-lambda-local
Public
forked from
HDE/python-lambda-local
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-lambda-local
/
lambda_local
/
context.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (46 loc) · 1.74 KB
Breadcrumbs
python-lambda-local
/
lambda_local
/
context.py
Copy path
File metadata and controls
55 lines (46 loc) · 1.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''
Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.)
Licensed under MIT.
'''
from
__future__
import
print_function
from
datetime
import
datetime
from
datetime
import
timedelta
import
uuid
class
Context
(
object
):
def
__init__
(
self
,
timeout_in_seconds
,
aws_request_id
=
uuid
.
uuid4
(),
function_name
=
"undefined"
,
function_version
=
"$LATEST"
,
log_group_name
=
"undefined"
,
log_stream_name
=
"undefined"
,
invoked_function_arn
=
"undefined"
,
memory_limit_in_mb
=
'0'
,
client_context
=
None
,
identity
=
None
):
self
.
function_name
=
function_name
self
.
function_version
=
function_version
self
.
invoked_function_arn
=
invoked_function_arn
self
.
memory_limit_in_mb
=
memory_limit_in_mb
self
.
aws_request_id
=
aws_request_id
self
.
log_group_name
=
log_group_name
self
.
log_stream_name
=
log_stream_name
self
.
identity
=
identity
self
.
client_context
=
client_context
self
.
_timeout_in_seconds
=
timeout_in_seconds
self
.
_duration
=
timedelta
(
seconds
=
timeout_in_seconds
)
def
get_remaining_time_in_millis
(
self
):
if
self
.
_timelimit
is
None
:
raise
Exception
(
"Context not activated."
)
return
millis_interval
(
datetime
.
now
(),
self
.
_timelimit
)
def
log
(
self
,
msg
):
print
(
msg
)
def
_activate
(
self
):
self
.
_timelimit
=
datetime
.
now
()
+
self
.
_duration
return
self
def
millis_interval
(
start
,
end
):
"""start and end are datetime instances"""
diff
=
end
-
start
millis
=
diff
.
days
*
24
*
60
*
60
*
1000
millis
+=
diff
.
seconds
*
1000
millis
+=
diff
.
microseconds
/
1000
return
millis
Back
|
FazBrowse Home
|
New Git URL