-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_console.py
81 lines (59 loc) · 1.76 KB
/
main_console.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
from os import system
import curses
import locale
from employee import Employee
from carnet import Carnet
locale.setlocale(locale.LC_ALL, '')
code = locale.getpreferredencoding()
def addstr_bold(y, x, text):
screen.attron(curses.A_BOLD)
screen.addstr(y, x, text)
screen.attroff(curses.A_BOLD)
def get_param(prompt_string):
screen.clear()
screen.border(0)
screen.addstr(2, 2, prompt_string)
screen.refresh()
input = screen.getstr(10, 10, 60)
return input
def execute_cmd(cmd_string):
system("clear")
a = system(cmd_string)
print ""
if a == 0:
pass # print "Command executed correctly"
else:
print "Command terminated with error"
raw_input("Press enter")
print ""
return a
x = 0
while x != ord('4'):
screen = curses.initscr()
screen.clear()
screen.border(0)
screen.addstr(1, 1, "Please enter a number...")
screen.addstr(4, 4, "1 - Search for a person")
screen.addstr(7, 4, "4 - Exit")
screen.refresh()
x = screen.getch()
if x == ord('1'):
person_id = get_param("Enter the person ID:")
emp = Employee(person_id)
if emp.pid is not None:
screen.clear()
screen.border(0)
screen.addstr(2, 4, "Name:")
addstr_bold(2, 14, emp.name.encode(code))
screen.addstr(3, 4, "Surname:")
addstr_bold(3, 14, emp.surname.encode(code))
screen.addstr(7, 4, "Press any key to cotinue...")
screen.refresh()
screen.getch()
curses.endwin()
status = execute_cmd("python camera.py %s" % person_id)
if status == 0:
carnet = Carnet(emp)
carnet.create()
curses.endwin()