pyx3270 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyx3270/__init__.py CHANGED
@@ -16,5 +16,5 @@ from pyx3270.emulator import X3270
16
16
  from pyx3270.offline import PyX3270Manager
17
17
 
18
18
  __author__ = 'MatheusLPolidoro'
19
- __version__ = '0.1.5'
19
+ __version__ = '0.1.7'
20
20
  __all__ = ['X3270', 'replay', 'record', 'PyX3270Manager']
pyx3270/bin/start.bin CHANGED
Binary file
pyx3270/cli.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import socket
3
+ import sys
3
4
  import threading
4
5
  from time import sleep
5
6
  from typing import Callable
@@ -110,7 +111,9 @@ def replay(
110
111
  except KeyboardInterrupt:
111
112
  rich.print('\n[x] Interrompido pelo usuário.')
112
113
  state.command_process.terminate()
113
- os._exit(0)
114
+ if emulator:
115
+ emu.terminate()
116
+ sys.exit(0)
114
117
 
115
118
 
116
119
  @app.command()
@@ -125,12 +128,12 @@ def record(
125
128
  port = int(*port) if port else 3270
126
129
 
127
130
  rich.print(f'[+] RECORD na porta {port}')
128
-
131
+ reconnect = False
129
132
  try:
130
133
  while True:
131
- if emulator:
134
+ if emulator and not reconnect:
132
135
  emu = X3270(visible=True, model=model, save_log_file=True)
133
- else:
136
+ elif not reconnect:
134
137
  emu = None
135
138
 
136
139
  server_thread = start_server_thread(
@@ -142,13 +145,19 @@ def record(
142
145
 
143
146
  if emulator:
144
147
  rich.print('[+] Conectando ao emulador...')
145
- emu.connect_host('localhost', port, tls, mode_3270=False)
148
+ if reconnect:
149
+ emu.reconnect_host()
150
+ else:
151
+ emu.connect_host('localhost', port, tls, mode_3270=False)
146
152
 
147
153
  rich.print(f'[+] Escutando localhost, origem {host=} {port=}')
148
154
  control_replay(server_thread)
155
+ reconnect = True
149
156
  except KeyboardInterrupt:
150
157
  rich.print('\n[x] Interrompido pelo usuário.')
151
- os._exit(0)
158
+ if emulator:
159
+ emu.terminate()
160
+ sys.exit(0)
152
161
 
153
162
 
154
163
  if __name__ == '__main__':
pyx3270/emulator.py CHANGED
@@ -370,7 +370,7 @@ class Wc3270App(ExecutableApp):
370
370
 
371
371
  class Ws3270App(ExecutableApp):
372
372
  args = [
373
- get_binary_path("windows", "ws3270"),
373
+ get_binary_path('windows', 'ws3270'),
374
374
  '-xrm',
375
375
  'ws3270.unlockDelay:False',
376
376
  ]
@@ -740,6 +740,7 @@ class X3270(AbstractEmulator, X3270Cmd):
740
740
  self.port = None
741
741
  self.tls = None
742
742
  self.mode_3270 = None
743
+ self.last_command_time = None
743
744
  logger.debug('X3270 inicializado')
744
745
 
745
746
  def _create_app(self) -> None:
@@ -774,6 +775,7 @@ class X3270(AbstractEmulator, X3270Cmd):
774
775
  cmd = Command(self.app, cmdstr)
775
776
  cmd.execute()
776
777
  self.status = Status(cmd.status_line)
778
+ self.last_command_time = time()
777
779
  logger.debug(f'Comando executado, status: {self.status}')
778
780
  return cmd
779
781
  except NotConnectedException:
@@ -816,6 +818,17 @@ class X3270(AbstractEmulator, X3270Cmd):
816
818
  def is_connected(self) -> bool:
817
819
  logger.debug('Verificando estado de conexão')
818
820
  try:
821
+ # Verifica tempo desde o último comando
822
+ elapsed_max = 600
823
+ if self.last_command_time:
824
+ elapsed = time() - self.last_command_time
825
+ if elapsed > elapsed_max:
826
+ logger.warning(
827
+ f'Tempo de inatividade excedido: '
828
+ f'{elapsed:.2f} segundos'
829
+ )
830
+ return False
831
+
819
832
  self.query('ConnectionState')
820
833
  is_connected = self.status.connection_state.startswith(b'C(')
821
834
  logger.info(f'Estado de conexão: {is_connected}')
@@ -1,4 +1,5 @@
1
1
  import os
2
+
2
3
  from PyInstaller.utils.hooks import get_package_paths
3
4
 
4
5
  # Caminho do pacote instalado
@@ -16,7 +17,9 @@ if os.path.isdir(bin_dir):
16
17
  # Caminho relativo a partir da pasta bin (ex: windows/wc3270.exe)
17
18
  rel_path = os.path.relpath(full_path, bin_dir)
18
19
  # Corrige o destino para ser uma pasta, não um arquivo
19
- target_dir = os.path.join('pyx3270', 'bin', os.path.dirname(rel_path))
20
+ target_dir = os.path.join(
21
+ 'pyx3270', 'bin', os.path.dirname(rel_path)
22
+ )
20
23
  datas.append((full_path, target_dir))
21
24
 
22
25
  __all__ = ['datas']
pyx3270/offline.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import subprocess
2
- import sys
3
2
  from logging import getLogger
4
3
  from time import sleep
5
4
 
@@ -11,8 +10,6 @@ logger = getLogger(__name__)
11
10
  class PyX3270Manager:
12
11
  def __init__(self, emu: AbstractEmulator, directory='./screens'):
13
12
  self.command = [
14
- sys.executable,
15
- '-m',
16
13
  'pyx3270',
17
14
  'replay',
18
15
  '--directory',
@@ -48,6 +45,7 @@ class PyX3270Manager:
48
45
  return
49
46
  self.emu.pf(1)
50
47
  sleep(0.1)
48
+ self.emu.pf(1)
51
49
 
52
50
  def next(self):
53
51
  """Define a tela específica e aguarda processamento corretamente."""
@@ -75,6 +73,7 @@ class PyX3270Manager:
75
73
  def change_directory(self, directory: str):
76
74
  """Troca o diretório de carregamento das telas."""
77
75
  self._exec(f'change directory {directory}')
76
+ sleep(1)
78
77
  self.emu.pf(1)
79
78
 
80
79
  def terminate(self):
pyx3270/server.py CHANGED
@@ -107,7 +107,7 @@ def find_directory(base_dir: str, search_name: str) -> str | None:
107
107
  ): # Compara de forma insensível a maiúsculas/minúsculas
108
108
  return os.path.join(base_dir, dir_name)
109
109
 
110
- return None # Retorna None se não encontrar um diretório correspondente
110
+ return None
111
111
 
112
112
 
113
113
  def convert_s(hex_string: str) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyx3270
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Uma interface comum utilizada para automações de terminais 3270 da IBM.
5
5
  Author-email: MatheusLPolidoro <mattpolidoro4@gmail.com>
6
6
  Project-URL: Documentation, https://matheuslpolidoro.github.io/pyx3270/
@@ -1,35 +1,34 @@
1
1
  docs/gen_tree.py,sha256=DQbnAfFVeeMT2mZMzByKVdM1Qm_O0q3mRrzKqKfSQ5M,11374
2
- pyx3270/__init__.py,sha256=pJu4quNUGZOa7kI6y9YCAhg17ftOlamSnPtYvYR-IXI,1226
2
+ pyx3270/__init__.py,sha256=_mE6bVXgKTHAQItHYXhqDlDs9pWuCx-7xf_gpCGiD2A,1226
3
3
  pyx3270/__main__.py,sha256=YyGX6Wbn7bgOvXjHIeGf8Z2so8MEtXXMRcaJnqR8tU4,70
4
- pyx3270/cli.py,sha256=_Vrmg-p1i889q9zS-k7IBS6_OHDMWtTt2b6-Mx5Esdk,4571
5
- pyx3270/emulator.py,sha256=8qj25lOQx2geIJiKi3ajo0qJToTE2qC3ZmZLTMMqlIQ,31820
4
+ pyx3270/cli.py,sha256=UozbD7kvCTKiNTK9mdiLlsOVBSwrjjXg8B99rDBYUz0,4868
5
+ pyx3270/emulator.py,sha256=WCK9mWcCA6PhXrPbeJePSp-xcPFYirGdXJ86tjUBUJg,32342
6
6
  pyx3270/exceptions.py,sha256=TtM9LugE5m4E01vI9PnzCE-BRMqigiWvoeGTLTDDbfo,607
7
7
  pyx3270/iemulator.py,sha256=tVEFNlZMSww2LsfdXZgmg2XJtT716uGvOHyU7G_UXBU,3081
8
8
  pyx3270/logging_config.py,sha256=k5sYSlaAe-_hkMR2V37eXRiQ4aPNRm6R7az1iEZ4IH4,1667
9
- pyx3270/offline.py,sha256=_ye3KC3FIkOEwSS0EykG4hdWSuu7zgJhl4dvI5-gCVw,2881
9
+ pyx3270/offline.py,sha256=jmZsabi_cLZvO4WXvrxFZ50p_CRQ9dkZ8pmo7oK3fM0,2863
10
10
  pyx3270/py.typed,sha256=eSgqDZOdQoML2kw4FABXkFkJeM2184WI1ojN8ed6k4Q,50
11
- pyx3270/server.py,sha256=57KufyvPAIEbKmIKdVvvoZ9eJgDqo1OPg02MMvY41IE,14170
11
+ pyx3270/server.py,sha256=5M4xovZGNdkYj7EB_BvHCNE43aLGA95puZhmoJk99tY,14107
12
12
  pyx3270/state.py,sha256=8MHyzT89IHWrXmVgbiSxvsfKSLQhsaZsXj4OOediPxA,72
13
13
  pyx3270/tn3270.py,sha256=-trKVI3uimpte6_IzYjwGv4UpGIEacKjI1knQFunNi0,6640
14
14
  pyx3270/x3270_commands.py,sha256=A65TZmjYakx9U8iiw60InxgVHkFc6XN2mYiFYiJQV8Y,9088
15
- pyx3270/bin/start.bin,sha256=HcQargbf60Mi902TLm1cYk9XfhoOq5ktCk7fhka3oZg,831
16
- pyx3270/bin/start.bin.bak,sha256=v1thzPr4nUjqNMlSPT9P9aY4RJuRa4mvE0b9es-cfvQ,831
15
+ pyx3270/bin/start.bin,sha256=k9epfaJ84n2HyYnhYLF3qieYRjIvdQ-eL5kS6a_LH9E,831
17
16
  pyx3270/bin/linux/s3270,sha256=2hIg5zTQ47okqtMUyiObLQWCdGLQw0uOw3NyuvWhfKk,2880816
18
17
  pyx3270/bin/linux/x3270,sha256=udKhVgQZDEu6_QQ37GeoH4zZwFQaw0x7OYw80Kh6-58,1719552
19
18
  pyx3270/bin/windows/wc3270.exe,sha256=gYE5ge5cgLlwkd1R5GG2WWAlQt_veXCydb8rARtP3lI,3570888
20
19
  pyx3270/bin/windows/ws3270.exe,sha256=eearMtLt-VtQrODep-PMxLZglVR5gb7-Le6OX3-tw_E,2904696
21
20
  pyx3270/hook/__init__.py,sha256=y0FL6nUHAtFJY2o_PWl1LxbvHPcwaA_Uj-tZJTlNeuc,77
22
- pyx3270/hook/hook-pyx3270.py,sha256=w006LtuugFG7RryBEWnjsKqLyiqU5q-jFhJMKTBW8XI,779
21
+ pyx3270/hook/hook-pyx3270.py,sha256=YZr9Q_RQDPOvpt_QSTPxXiHZcmqNcgt7IPYGUsL2WwE,813
23
22
  site/gen_tree.py,sha256=DQbnAfFVeeMT2mZMzByKVdM1Qm_O0q3mRrzKqKfSQ5M,11374
24
23
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
24
  tests/conftest.py,sha256=eFhdOo-a-hlbx61S2c6JUcFOHVzlf3OpCTJW-4VM0Ls,8134
26
25
  tests/test_cli.py,sha256=JW0PBFxvux0J5ZFlzhSPiIie5NqQ2Q3dti_rZt_0HtA,3200
27
26
  tests/test_emulator.py,sha256=fpmKiGN1pyEN470XstCG8EsEpnaqFrBQ76tSp5_Sdas,69346
28
27
  tests/test_exceptions.py,sha256=pvpwEUFEEju2CgBR3QPpm6wspiwzP1jp5K7gX9Pagrw,1226
29
- tests/test_offline.py,sha256=bkwHMoevAl3UEj8UmclM4adSm0kujjNNX83Dlx1nBpM,5572
28
+ tests/test_offline.py,sha256=jIE2rd99I4t7oRobOsmf2uaiYswQ4m74e6Q9Mj4rGYk,5583
30
29
  tests/test_server.py,sha256=FlJ_gEhRtoESc1m9EKCfJRXeGJnMRyoUtKF1VkOYhBY,23608
31
- pyx3270-0.1.5.dist-info/METADATA,sha256=2otXGZmTsbnDnk5RpIGIVqyOIxGOUCGmP9SudvjCZwI,3417
32
- pyx3270-0.1.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
33
- pyx3270-0.1.5.dist-info/entry_points.txt,sha256=9kg9FaegDY2FXCVplltQGAmMiWia1LnnsPF7c1uQpa0,105
34
- pyx3270-0.1.5.dist-info/top_level.txt,sha256=ptTDzZHpMHYKlnFM01XeuAnLhdlYO2NZQeER6hp3euA,24
35
- pyx3270-0.1.5.dist-info/RECORD,,
30
+ pyx3270-0.1.7.dist-info/METADATA,sha256=Ns2mIUjK9S8Q1BZm11XtsZsvsxazoGEJpW0n73l3vPw,3417
31
+ pyx3270-0.1.7.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
32
+ pyx3270-0.1.7.dist-info/entry_points.txt,sha256=9kg9FaegDY2FXCVplltQGAmMiWia1LnnsPF7c1uQpa0,105
33
+ pyx3270-0.1.7.dist-info/top_level.txt,sha256=ptTDzZHpMHYKlnFM01XeuAnLhdlYO2NZQeER6hp3euA,24
34
+ pyx3270-0.1.7.dist-info/RECORD,,
tests/test_offline.py CHANGED
@@ -2,7 +2,7 @@ import gc
2
2
  import subprocess
3
3
  import sys
4
4
  import weakref
5
- from unittest.mock import MagicMock, patch
5
+ from unittest.mock import MagicMock, patch, call
6
6
 
7
7
  from pyx3270.offline import PyX3270Manager
8
8
 
@@ -17,8 +17,6 @@ def test_pyx3270_manager_init_and_terminate(mock_popen, x3270_cmd_instance):
17
17
 
18
18
  mock_popen.assert_called_once_with(
19
19
  [
20
- sys.executable,
21
- '-m',
22
20
  'pyx3270',
23
21
  'replay',
24
22
  '--directory',
@@ -58,7 +56,8 @@ def test_pyx3270_manager_exec(mock_logger, mock_popen, x3270_cmd_instance):
58
56
  )
59
57
  mock_process.stdin.write.assert_called_once_with(f'{command}\n')
60
58
  mock_process.stdin.flush.assert_called_once()
61
- manager.emu.pf.assert_called_once_with(1)
59
+ assert manager.emu.pf.call_count == 2
60
+ manager.emu.pf.assert_has_calls([call(1), call(1)])
62
61
 
63
62
 
64
63
  @patch('subprocess.Popen')
pyx3270/bin/start.bin.bak DELETED
Binary file