forked from jgyates/genmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientInterface.py
49 lines (37 loc) · 1.35 KB
/
ClientInterface.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
#!/usr/bin/env python
#------------------------------------------------------------
# FILE: ClientInterface.py
# PURPOSE:
#
# AUTHOR: Jason G Yates
# DATE: 17-Dec-2016
# MODIFICATIONS:
#------------------------------------------------------------
import datetime, time, sys, smtplib, signal, os, threading, socket
from genmonlib import mylog, myclient
#---------- Signal Handler ------------------------------------------
def signal_handler(signal, frame):
sys.exit(0)
#------------------- Command-line interface for monitor -----------------#
if __name__=='__main__': # usage program.py [server_address]
address='localhost' if len(sys.argv)<2 else sys.argv[1]
# log errors in this module to a file
log = mylog.SetupLogger("client", "client.log")
# Set the signal handler
signal.signal(signal.SIGINT, signal_handler)
MyClientInterface = myclient.ClientInterface(host = address, log = log)
try:
while True:
try:
line = raw_input(">")
except NameError:
pass
line = input(">")
if line.lower() == "exit":
break
if len(line):
data = MyClientInterface.ProcessMonitorCommand(line)
print(data)
except Exception as e1:
print ("Error: " + str(e1))
MyClientInterface.Close()