-
Notifications
You must be signed in to change notification settings - Fork 0
/
injector.py
61 lines (52 loc) · 1.86 KB
/
injector.py
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
from populator import populator
shade = 0
def argumentparser():
global shade
try:
import argparse
import sys
except:
print("\nxx Error importing arparse or sys module\n")
exit(1)
parser = argparse.ArgumentParser(
description='To process tables in images.', prog='populator')
parser.add_argument(
'-p', '--path', help='Path for the tabular source image')
parser.add_argument('-db', '--database',
help='Name of database')
parser.add_argument(
'-t', '--table', help='Name of the table')
parser.add_argument('-s', '--shade', help="Shade of heading", default=0)
if len(sys.argv) > 1:
args = parser.parse_args()
path = args.path
try:
f = open(path)
f.close()
except FileNotFoundError:
print("File not accessible")
print("\n### EXITING ###")
exit(1)
database_name = args.database if len(
args.database) != 0 else input("Enter the name of database: ")
table_name = args.table if len(args.table) != 0 else input(
"Enter the name of table: ")
shade = args.shade
else:
path = input("Enter image path: ")
try:
f = open(path)
f.close()
except FileNotFoundError:
print("\nxx File not accessible\n")
exit(1)
database_name = input("Enter the name of database: ")
table_name = input("Enter the name of table: ")
return (path, database_name, table_name)
def main():
print("\n==================== SEQUEL INJECTOR ====================\n")
path, database_name, table_name = argumentparser()
populator(path, database_name, table_name, shade)
print("\n=========================================================\n")
if __name__ == "__main__":
main()