-
Notifications
You must be signed in to change notification settings - Fork 80
/
run
executable file
·89 lines (70 loc) · 3.32 KB
/
run
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
from __future__ import print_function
import sys
import subprocess
import threading
import glob
def Str(value):
if isinstance(value, list):
return " ".join(value)
if isinstance(value, basestring):
return value
return str(value)
def Glob(value):
ret = glob.glob(value)
if(len(ret) < 1):
ret = [value]
return ret
for i in range(4-len(sys.argv)):
sys.argv.append("")
if(str(sys.argv[1]) == ""):
print("")
print("Enter command arguments with run")
print(" ./run install - Install all dependencies for visma")
print(" ./run visma - Open visma GUI")
print(" ./run test - Run all the tests and generates coverage report")
print(" ./run test path/to/test_file.py - Runs all tests and shows coverage for given file")
print(" ./run test syntax - Run syntax test using pylama")
print(" ./run test modules - Run tests using pytest for all modules")
print(" ./run test coverage - After running all the tests, open coverage report")
print(" ./run pack - Generate builds for visma package")
print(" ./run pack upload - Generate builds and then upload to test.pypi.org")
print(" ./run pack final - Generate builds and upload final build to pypi.org")
print(" ./run clean - Clean all cache, reports and builds")
print("")
elif (str(sys.argv[1]) == "install"):
subprocess.call("python3 -m pip install -r requirements.txt", shell=True)
elif (str(sys.argv[1]) == "visma"):
subprocess.call("python3 main.py", shell=True)
elif str(sys.argv[1]) == "test":
if str(sys.argv[2]) == "syntax" or str(sys.argv[2]) == "":
print("Python Syntax Test ...")
subprocess.call("pylama", shell=True)
elif (str(sys.argv[2]) == "modules"):
print("Python Modules Test ...")
subprocess.call("pytest", shell=True)
if str(sys.argv[2]) != "" and str(sys.argv[2]) != "coverage" and str(sys.argv[2]) != "syntax" and str(sys.argv[2]) != "modules":
print("Python Test for " + str(sys.argv[2]) + " ...")
subprocess.call("coverage run --source ./ -m pytest " + str(sys.argv[2]) + " -v", shell=True)
elif str(sys.argv[2]) == "":
print("Python Modules Test with Coverage ...")
subprocess.call("coverage run --source ./ -m pytest -v", shell=True)
if str(sys.argv[2]) == "" or str(sys.argv[2]) == "coverage" or str(sys.argv[3]) == "coverage":
subprocess.call("coverage report", shell=True)
subprocess.call("coverage html", shell=True)
if str(sys.argv[2]) == "coverage" or str(sys.argv[3]) == "coverage":
def thread1():
subprocess.call("nohup xdg-open ./htmlcov/index.html", shell=True)
threading.Thread(target=thread1).start()
elif str(sys.argv[1]) == "pack":
subprocess.call("mv main.py visma", shell=True)
subprocess.call("python3 setup.py sdist bdist_wheel", shell=True)
subprocess.call("mv ./visma/main.py ./", shell=True)
if str(sys.argv[2]) == "upload":
subprocess.call("twine upload --repository-url https://test.pypi.org/legacy/", Str(Glob("dist/*")), shell=True)
elif str(sys.argv[2]) == "final":
subprocess.call("twine upload", Str(Glob("dist/*")), shell=True)
elif str(sys.argv[1]) == "clean":
subprocess.call("git clean -xdf", shell=True)
else:
print("Invalid arguments")