pyx3270 0.1.5__tar.gz → 0.1.7__tar.gz

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.
Files changed (40) hide show
  1. {pyx3270-0.1.5 → pyx3270-0.1.7}/PKG-INFO +1 -1
  2. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyproject.toml +1 -1
  3. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/__init__.py +1 -1
  4. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/bin/start.bin +0 -0
  5. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/cli.py +15 -6
  6. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/emulator.py +14 -1
  7. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/hook/hook-pyx3270.py +4 -1
  8. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/offline.py +2 -3
  9. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/server.py +1 -1
  10. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270.egg-info/PKG-INFO +1 -1
  11. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270.egg-info/SOURCES.txt +0 -1
  12. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/test_offline.py +3 -4
  13. pyx3270-0.1.5/pyx3270/bin/start.bin.bak +0 -0
  14. {pyx3270-0.1.5 → pyx3270-0.1.7}/README.md +0 -0
  15. {pyx3270-0.1.5 → pyx3270-0.1.7}/docs/gen_tree.py +0 -0
  16. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/__main__.py +0 -0
  17. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/bin/linux/s3270 +0 -0
  18. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/bin/linux/x3270 +0 -0
  19. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/bin/windows/wc3270.exe +0 -0
  20. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/bin/windows/ws3270.exe +0 -0
  21. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/exceptions.py +0 -0
  22. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/hook/__init__.py +0 -0
  23. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/iemulator.py +0 -0
  24. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/logging_config.py +0 -0
  25. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/py.typed +0 -0
  26. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/state.py +0 -0
  27. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/tn3270.py +0 -0
  28. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270/x3270_commands.py +0 -0
  29. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270.egg-info/dependency_links.txt +0 -0
  30. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270.egg-info/entry_points.txt +0 -0
  31. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270.egg-info/requires.txt +0 -0
  32. {pyx3270-0.1.5 → pyx3270-0.1.7}/pyx3270.egg-info/top_level.txt +0 -0
  33. {pyx3270-0.1.5 → pyx3270-0.1.7}/setup.cfg +0 -0
  34. {pyx3270-0.1.5 → pyx3270-0.1.7}/site/gen_tree.py +0 -0
  35. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/__init__.py +0 -0
  36. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/conftest.py +0 -0
  37. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/test_cli.py +0 -0
  38. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/test_emulator.py +0 -0
  39. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/test_exceptions.py +0 -0
  40. {pyx3270-0.1.5 → pyx3270-0.1.7}/tests/test_server.py +0 -0
@@ -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,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyx3270"
3
- version = "0.1.5"
3
+ version = "0.1.7"
4
4
  description = "Uma interface comum utilizada para automações de terminais 3270 da IBM."
5
5
  authors = [{name = "MatheusLPolidoro", email = "mattpolidoro4@gmail.com"}]
6
6
  readme = "README.md"
@@ -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']
@@ -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__':
@@ -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']
@@ -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):
@@ -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/
@@ -21,7 +21,6 @@ pyx3270.egg-info/entry_points.txt
21
21
  pyx3270.egg-info/requires.txt
22
22
  pyx3270.egg-info/top_level.txt
23
23
  pyx3270/bin/start.bin
24
- pyx3270/bin/start.bin.bak
25
24
  pyx3270/bin/linux/s3270
26
25
  pyx3270/bin/linux/x3270
27
26
  pyx3270/bin/windows/wc3270.exe
@@ -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')
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes