dkinst 0.1.3__py3-none-any.whl → 0.2.0__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.
dkinst/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Den K Simple Installer"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '0.1.3'
4
+ __version__ = '0.2.0'
dkinst/cli.py CHANGED
@@ -9,6 +9,7 @@ import subprocess
9
9
  from rich.console import Console
10
10
  from rich.table import Table
11
11
 
12
+ from . import __version__
12
13
  from .installers._base import BaseInstaller
13
14
  from .installers import _base
14
15
  from . import installers
@@ -16,7 +17,7 @@ from . import installers
16
17
  console = Console()
17
18
 
18
19
 
19
- VERSION: str = "0.1.3"
20
+ VERSION: str = __version__
20
21
 
21
22
 
22
23
  def _get_installers() -> list[BaseInstaller]:
@@ -4,6 +4,8 @@ import tomllib
4
4
  from pathlib import Path
5
5
  from types import ModuleType
6
6
  from typing import Literal
7
+ import os
8
+ import ctypes
7
9
 
8
10
 
9
11
  INSTALLATION_PATH_PORTABLE_WINDOWS: str = "C:\\dkinst" # Installation path for portable files on Windows that don't have a default location.
@@ -254,4 +256,4 @@ def _extract_helper_args(
254
256
  tokens.append("/".join(act.option_strings))
255
257
  else: # positionals
256
258
  tokens.append(act.dest)
257
- return tokens
259
+ return tokens
@@ -0,0 +1,22 @@
1
+ import os
2
+ import ctypes
3
+
4
+
5
+ def is_admin() -> bool:
6
+ """
7
+ Function checks on Windows or POSIX OSes if the script is executed under Administrative Privileges.
8
+ :return: True / False.
9
+ """
10
+
11
+ if os.name == 'nt':
12
+ if ctypes.windll.shell32.IsUserAnAdmin() == 0:
13
+ result = False
14
+ else:
15
+ result = True
16
+ else:
17
+ if 'SUDO_USER' in os.environ and os.geteuid() == 0:
18
+ result = True
19
+ else:
20
+ result = False
21
+
22
+ return result
@@ -0,0 +1,106 @@
1
+ from pathlib import Path
2
+ from types import ModuleType
3
+ from typing import Literal
4
+ import subprocess
5
+ from rich.console import Console
6
+
7
+ from atomicshop.wrappers.nodejsw import install_nodejs_windows
8
+
9
+ from . import _base
10
+ from .helpers import permissions
11
+
12
+
13
+ console = Console()
14
+
15
+
16
+ TESSERACT_BIN_EXE_PATH: str = str(Path(__file__).parent.parent / "tesseract_bin" / "tesseract.exe")
17
+
18
+
19
+ class Robocorp(_base.BaseInstaller):
20
+ def __init__(self):
21
+ super().__init__()
22
+ self.name: str = Path(__file__).stem
23
+ self.description: str = "Robocorp Installer"
24
+ self.version: str = "1.0.2"
25
+ self.platforms: list = ["windows"]
26
+ self.helper: ModuleType | None = None
27
+
28
+ def install(self):
29
+ if not permissions.is_admin():
30
+ console.print("Please run this script as an Administrator.", style="red")
31
+ return 1
32
+
33
+ console.print(f"Installing Tesseract OCR", style="blue")
34
+ subprocess.check_call(["dkinst", "install", "tesseract_ocr"])
35
+
36
+ console.print("Installing NodeJS.", style="blue")
37
+ if not install_nodejs_windows.is_nodejs_installed():
38
+ install_nodejs_windows.install_nodejs_windows()
39
+ install_nodejs_windows.add_nodejs_to_path()
40
+ if not install_nodejs_windows.is_nodejs_installed():
41
+ console.print("Node.js installation failed.", style="red")
42
+ return 1
43
+
44
+ console.print("PIP Installing Robocorp.", style="blue")
45
+ subprocess.check_call(["pip", "install", "--upgrade", "rpaframework"])
46
+
47
+ console.print("PIP Installing Robocorp-Browser.", style="blue")
48
+ subprocess.check_call(["pip", "install", "--upgrade", "robotframework-browser"])
49
+
50
+ console.print("PIP Installing Robocorp-Recognition.", style="blue")
51
+ subprocess.check_call(["pip", "install", "--upgrade", "rpaframework-recognition"])
52
+
53
+ console.print("Installing Playwright browsers.", style="blue")
54
+ subprocess.check_call(["playwright", "install"])
55
+
56
+ console.print("Initializing Robocorp Browser.", style="blue")
57
+ subprocess.check_call(["rfbrowser", "init"])
58
+
59
+ console.print("Installing Additional modules.", style="blue")
60
+ subprocess.check_call(["pip", "install", "--upgrade", "matplotlib", "imagehash", "pynput"])
61
+
62
+ # Patch robocorp: Remove mouse to the center of the screen on control command.
63
+ # Import the library to find its path.
64
+ console.print(r"Patching: .\RPA\Windows\keywords\window.py", style="blue")
65
+ import RPA.Windows.keywords.window as window
66
+ window_file_path = window.__file__
67
+
68
+ # Patch the file.
69
+ with open(window_file_path, "r") as file:
70
+ file_content = file.read()
71
+ file_content = file_content.replace(
72
+ "window.item.MoveCursorToMyCenter(simulateMove=self.ctx.simulate_move)",
73
+ "# window.item.MoveCursorToMyCenter(simulateMove=self.ctx.simulate_move) # Patched to remove center placement during foreground window control."
74
+ )
75
+ with open(window_file_path, "w") as file:
76
+ file.write(file_content)
77
+
78
+ return 0
79
+
80
+ def update(
81
+ self,
82
+ force: bool = False
83
+ ):
84
+ self.install()
85
+
86
+ def _show_help(
87
+ self,
88
+ method: Literal["install", "uninstall", "update"]
89
+ ) -> None:
90
+ if method == "install":
91
+ method_help: str = (
92
+ "This method will install the following:\n"
93
+ " tesseract OCR binaries (dkinst).\n"
94
+ " NodeJS (dkinst).\n"
95
+ " Robocorp Framework (rpaframework - pip)\n"
96
+ " Robocorp-Browser Addon (robotframework-browser - pip)\n"
97
+ " Robocorp-Recognition Addon (rpaframework-recognition - pip).\n"
98
+ " Playwright Browsers\n"
99
+ " More pip packages: pynput, matplotlib, imagehash\n"
100
+ "\n"
101
+ )
102
+ print(method_help)
103
+ elif method == "update":
104
+ print("In this installer 'update()' is the same as 'install()'.")
105
+ else:
106
+ raise ValueError(f"Unknown method '{method}'.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkinst
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: Den K Simple Installer
5
5
  Author: Denis Kras
6
6
  License-Expression: MIT
@@ -0,0 +1,16 @@
1
+ dkinst/__init__.py,sha256=S9yw_pl4J-PdSgFEDS7IQqPh-mDYidu8SUSUrDHBeYg,78
2
+ dkinst/cli.py,sha256=4jLmbW73FInE21i1FXhuhM6eymWhA4Pvicl34H62K_4,9278
3
+ dkinst/config.toml,sha256=OaTuImf9xBIbTNCrC2MfAzpPLeuDdV2R5feIfT7xImA,48
4
+ dkinst/installers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ dkinst/installers/_base.py,sha256=03KA1u23EKhArJV_SNlST3ss-Pvs6U6YPUEZxHYC_94,10306
6
+ dkinst/installers/robocorp.py,sha256=WAO8s9VZfQ29cPve1xMr1y5R74WaNZJf-BOOjPsC1VU,4232
7
+ dkinst/installers/tesseract_ocr.py,sha256=LqcOJCTQJU3xPz3wm_nQI5Bt6bB5dgDPzf7WykpSM6A,2524
8
+ dkinst/installers/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ dkinst/installers/helpers/permissions.py,sha256=CYTDVOI0jh9ks0ZLnnOuPzppgCszFEc9-92DTkVTYi4,522
10
+ dkinst/installers/helpers/tesseract_ocr_manager.py,sha256=-Br9vHbqcQHRsNlDkakw5mLMxMBTydqXCblhpcBmp0A,17734
11
+ dkinst-0.2.0.dist-info/licenses/LICENSE,sha256=ohlj1rmsTHdctr-wyqmP6kbFC6Sff8pJd29v3pruZ18,1088
12
+ dkinst-0.2.0.dist-info/METADATA,sha256=t8sA7dOIwT_cOwOak7YTl4D-oarFbmfpbUnZ75n8SY4,2018
13
+ dkinst-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ dkinst-0.2.0.dist-info/entry_points.txt,sha256=YNgO3GufKMdA_oRqWEGAVh6k00oIuPItqqChoUtU278,43
15
+ dkinst-0.2.0.dist-info/top_level.txt,sha256=_dGNrME6z6Ihv2sxGC4hfAlnVuhoDlKwx-97LZ2xtQ0,7
16
+ dkinst-0.2.0.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- dkinst/__init__.py,sha256=Z2kqZNDNN63Q4uZN62BVMZrdvSMPNm6FwGHcDmA_Ppk,78
2
- dkinst/cli.py,sha256=fPYiqfB8IHEcw-Fq1Pjr9CLs5apg7hLXwsMso5d825s,9247
3
- dkinst/config.toml,sha256=OaTuImf9xBIbTNCrC2MfAzpPLeuDdV2R5feIfT7xImA,48
4
- dkinst/installers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- dkinst/installers/_base.py,sha256=_3t0_xkbHRvFtxpDkLkZw9_pizIEiK5sXTYMIWK3jUw,10278
6
- dkinst/installers/tesseract_ocr.py,sha256=LqcOJCTQJU3xPz3wm_nQI5Bt6bB5dgDPzf7WykpSM6A,2524
7
- dkinst/installers/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- dkinst/installers/helpers/tesseract_ocr_manager.py,sha256=-Br9vHbqcQHRsNlDkakw5mLMxMBTydqXCblhpcBmp0A,17734
9
- dkinst-0.1.3.dist-info/licenses/LICENSE,sha256=ohlj1rmsTHdctr-wyqmP6kbFC6Sff8pJd29v3pruZ18,1088
10
- dkinst-0.1.3.dist-info/METADATA,sha256=wLu4m9CilVOqIrarhuIW8svJ9dEYM_yHSt-fSGblYik,2018
11
- dkinst-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- dkinst-0.1.3.dist-info/entry_points.txt,sha256=YNgO3GufKMdA_oRqWEGAVh6k00oIuPItqqChoUtU278,43
13
- dkinst-0.1.3.dist-info/top_level.txt,sha256=_dGNrME6z6Ihv2sxGC4hfAlnVuhoDlKwx-97LZ2xtQ0,7
14
- dkinst-0.1.3.dist-info/RECORD,,
File without changes