-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemulator.py
More file actions
84 lines (61 loc) · 1.89 KB
/
emulator.py
File metadata and controls
84 lines (61 loc) · 1.89 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
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
from py3270 import Emulator
import sys
import os
import logging
# logger = logging.getLogger()
# logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
USER_ENV = 'USER_3270'
PASSWORD_ENV = 'PASSWORD_3270'
MAINFRAME_IP = '192.168.111.1'
def password():
return os.environ[PASSWORD_ENV]
def username():
return os.environ[USER_ENV]
def connect_to_mainframe(em):
# logger.info("testing logger before mainframe")
em.connect(MAINFRAME_IP)
em.wait_for_field()
if em.string_found(11, 10, 'TPXA'):
print("TPXA screen successfully reached")
else:
print("Could not reach TPXA screen")
sys.exit()
def access_tpxa(em):
em.send_string("tpxa", 9, 18)
em.send_enter()
em.wait_for_field()
if em.string_found(14, 5, 'Utente'):
print("Login screen successfully reached")
else:
print("Could not reach Login screen")
sys.exit()
def login(em):
em.send_string(username(), 14, 22)
em.send_string(password(), 15, 22)
em.send_enter()
em.wait_for_field()
if em.string_found(7, 6, 'TSOB'):
print("Procedures list screen successfully reached")
else:
print("Could not reach procedures list screen")
sys.exit()
def environment_is_configured():
is_configured = True
if not USER_ENV in os.environ:
print("Error: " + USER_ENV + " environment variable not configured.")
is_configured = False
if not PASSWORD_ENV in os.environ:
print("Error: " + PASSWORD_ENV + " environment variable not configured.")
is_configured = False
return is_configured
def connect():
print("Starting connectivity test")
if not environment_is_configured():
sys.exit()
emulator = Emulator()
connect_to_mainframe(emulator)
access_tpxa(emulator)
login(emulator)
emulator.terminate()
print("Connectivity test completed successfully")
connect()