-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_take_dark_frame.py
More file actions
executable file
·29 lines (26 loc) · 1.51 KB
/
test_take_dark_frame.py
File metadata and controls
executable file
·29 lines (26 loc) · 1.51 KB
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
#!/usr/bin/python3
# Importing required packages
import argparse
import requests
import json
# command line arguments
parser = argparse.ArgumentParser(prog='test_take_dark_frame.py',
description='Take a dark frame by sending a request to the API server.')
parser.add_argument('-i', '--ip_address', type=str, default='150.204.240.129', help='The IP address the server is running on.')
parser.add_argument('-p', '--port_number', type=int, default=5100, help='The port number the server is running on.')
parser.add_argument('-e', '--exposure_time', type=float, default=1.0, help='The dark exposure length in decimal seconds.')
parser.add_argument('-m', '--multrun', type=str, help='An optional parameter to control whether the generated dark filename is the start of a new multrun, or the next frame in the current multrun. Specify one of: [start|next].')
args = parser.parse_args()
# Composing a payload for API
payload = {'exposure_time' : args.exposure_time }
if args.multrun is not None:
payload["multrun"] = str(args.multrun)
# Defining content type for our payload
headers = {'Content-type': 'application/json'}
# Compose the API endpoint URL
urlname = "http://" + str(args.ip_address) + ":" + str(args.port_number) + "/takeDarkFrame"
print ("Invoking end-point: ", urlname, " with payload:", json.dumps(payload))
# Sending a post request to the server (API) and receiving a reply
response = requests.post(url=urlname , data=json.dumps(payload), headers=headers)
# Printing out the response of API
print(response.text)