forked from EduardoPagotto/Zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
executable file
·74 lines (52 loc) · 1.81 KB
/
client.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
#!/usr/bin/env python3
'''
Created on 20190822
Update on 20200916
@author: Eduardo Pagotto
'''
import time
import logging
import common as rpc
from Zero import ServiceBus
from Zero import ExceptionZeroRPC
def main():
try:
log = logging.getLogger('Client')
bus = ServiceBus(rpc.ADDRESS)
ponta = bus.getObject()
ponta.testeA('primeiro', 'segundo', val1='val1', val2='teste2', val3='DDD')
valor = ponta.getNome()
log.debug('Nome Atual: %s', valor)
time.sleep(5)
if valor == 'Jose':
ponta.setNome('Maria')
else:
ponta.setNome('Jose')
log.debug('RPC retorno: %s', ponta.is_alive_bitch())
valor = ponta.teste_target(4)
log.debug('RPC retorno: %s', valor)
dados = {'nome':'pagotto', 'idade':50, 'sexo':True, 'opt':{'val1':'teste1', 'lista':['um', 'dois']}}
retorno = ponta.get_dict(dados)
log.debug('RPC retorno:%s', str(retorno))
log.debug('esperar 80 segundos para proxima consulta')
time.sleep(80)
valor = ponta.getNome()
log.debug('Nome Atual: %s', valor)
time.sleep(40)
valor = ponta.getNome()
log.debug('Nome Atual: %s', valor)
#valor = ponta.sendTesteComando('texto',10, False, nome='eduardo', idade=50, peso=70.5, sexo=True)
#log.debug('RPC retorno: %s', valor)
except ExceptionZeroRPC as exp:
log.error('ERRO: {0}'.format(str(exp)))
except Exception as exp:
log.error('Falha: {0}'.format(str(exp)))
bus.close_all()
log.info('App desconectado')
if __name__ == '__main__':
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(threadName)-16s %(funcName)-20s %(message)s',
datefmt='%H:%M:%S',
)
main()