-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·46 lines (40 loc) · 1.26 KB
/
setup.py
File metadata and controls
executable file
·46 lines (40 loc) · 1.26 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import time
import wget
import ssl
import os
from sh import gunzip
# Ignore ssl
ssl._create_default_https_context = ssl._create_unverified_context
# Define the local filename to save data
local_file = 'title.basics.tsv.gz'
print("##########-Clean Up-##########")
cmd = "docker-compose down -v"
print(cmd)
os.system(cmd)
os.system("rm -rf postgres/" + local_file)
os.system("rm -rf postgres/title.basics.tsv")
# Define the remote file to retrieve
remote_url = 'https://datasets.imdbws.com/title.basics.tsv.gz'
# Make http request for remote file data
print("Downloading dataset '" + local_file + "' from " + remote_url)
wget.download(remote_url,"postgres/" + local_file)
# Extract Archive
print("\n##########-Extracting Archive.-##########")
try:
gunzip("postgres/" + local_file)
except Exception as err:
print("{}".format(err))
# run containers
print("##########-Starting Containers...-##########")
cmd = "docker-compose up -d --build"
print(cmd)
os.system(cmd)
print("##########-Clean Up-##########")
os.system("rm -rf postgres/" + local_file)
os.system("rm -rf postgres/title.basics.tsv")
os.system("rm -rf postgres/*.tmp")
print("##########-Test API-##########")
time.sleep(18)
cmd = "curl localhost:3000/api/v1/movies | python3 -m json.tool"
print(cmd)
os.system(cmd)