Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ The output will be like:
None
[root - INFO - 2017-04-19 12:39:05,515] REPORT RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 Duration: 2.27 ms
```

#### Dynamic events:

Instead of an event.json file, any executable can be passed to `python-lambda-local` as the event path.
In this case, it will be executed, and its stdout will be used as the event.
10 changes: 8 additions & 2 deletions lambda_local/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
'''

import json
import os
import subprocess


def read_event(path):
with open(path) as event:
data = json.load(event)
if os.path.isfile(path) and os.access(path, os.X_OK):
r = subprocess.run(path, stdout=subprocess.PIPE)
data = json.loads(r.stdout)
else:
with open(path) as event:
data = json.load(event)

return data