utils_devops 0.1.149__tar.gz → 0.1.150__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.
- {utils_devops-0.1.149 → utils_devops-0.1.150}/PKG-INFO +1 -1
- {utils_devops-0.1.149 → utils_devops-0.1.150}/pyproject.toml +1 -1
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/ssh_ops.py +45 -6
- {utils_devops-0.1.149 → utils_devops-0.1.150}/README.md +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/__init__.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/__init__.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/datetimes.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/envs.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/files.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/logs.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/script_helpers.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/strings.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/core/systems.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/__init__.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/aws_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/docker_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/git_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/interaction_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/metrics_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/network_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/nginx_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/notification_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/performance_ops.py +0 -0
- {utils_devops-0.1.149 → utils_devops-0.1.150}/src/utils_devops/extras/vault_ops.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: utils_devops
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.150
|
|
4
4
|
Summary: Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: devops,automation,nginx,cli,jinja2,yaml,config,diff,templating,logging,docker,compose,file-ops
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "utils_devops"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.150" # Bumped for new string features + diffing
|
|
4
4
|
description = "Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools"
|
|
5
5
|
authors = ["Hamed Sheikhan <sh.sheikhan.m@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -534,24 +534,23 @@ def _inject_environment_variables(
|
|
|
534
534
|
) -> str:
|
|
535
535
|
"""
|
|
536
536
|
Creates a command string that safely injects environment variables.
|
|
537
|
-
Works for both Windows and Linux remote targets.
|
|
538
537
|
"""
|
|
539
538
|
if not environment:
|
|
540
539
|
return base_command
|
|
541
540
|
|
|
542
|
-
# Create a temporary script to set environment and run the command
|
|
543
541
|
env_lines = []
|
|
544
|
-
if systems.is_linux
|
|
542
|
+
if systems.is_linux:
|
|
545
543
|
# Linux syntax: export VAR='value'
|
|
546
544
|
for key, value in environment.items():
|
|
545
|
+
print(f"DEBUG _inject_environment_variables: key='{key}', value='{value}', type={type(value)}") # DEBUG
|
|
547
546
|
escaped_value = value.replace("'", "'\"'\"'")
|
|
548
547
|
env_lines.append(f"export {key}='{escaped_value}'")
|
|
549
548
|
env_setup = " && ".join(env_lines)
|
|
550
549
|
prefix = f"{env_setup} && "
|
|
551
|
-
elif systems.is_windows
|
|
550
|
+
elif systems.is_windows:
|
|
552
551
|
# Windows syntax (PowerShell)
|
|
553
552
|
for key, value in environment.items():
|
|
554
|
-
|
|
553
|
+
print(f"DEBUG _inject_environment_variables: key='{key}', value='{value}', type={type(value)}") # DEBUG
|
|
555
554
|
escaped_value = value.replace("'", "''").replace("`", "``")
|
|
556
555
|
env_lines.append(f"$env:{key}='{escaped_value}'")
|
|
557
556
|
env_setup = "; ".join(env_lines)
|
|
@@ -559,6 +558,41 @@ def _inject_environment_variables(
|
|
|
559
558
|
|
|
560
559
|
return f"{prefix}{base_command}"
|
|
561
560
|
|
|
561
|
+
def _detect_remote_os(client) -> str:
|
|
562
|
+
"""
|
|
563
|
+
Detect the operating system of the remote SSH host.
|
|
564
|
+
Returns: "linux", "windows", or "unknown"
|
|
565
|
+
"""
|
|
566
|
+
try:
|
|
567
|
+
# Try Linux command first
|
|
568
|
+
stdin, stdout, stderr = client.exec_command("uname -s", timeout=5)
|
|
569
|
+
output = stdout.read().decode('utf-8', errors='ignore').strip().lower()
|
|
570
|
+
if "linux" in output or "darwin" in output:
|
|
571
|
+
return "linux"
|
|
572
|
+
except:
|
|
573
|
+
pass
|
|
574
|
+
|
|
575
|
+
try:
|
|
576
|
+
# Try Windows command
|
|
577
|
+
stdin, stdout, stderr = client.exec_command("ver", timeout=5)
|
|
578
|
+
output = stdout.read().decode('utf-8', errors='ignore').strip().lower()
|
|
579
|
+
if "windows" in output or "microsoft" in output:
|
|
580
|
+
return "windows"
|
|
581
|
+
except:
|
|
582
|
+
pass
|
|
583
|
+
|
|
584
|
+
# Try PowerShell (Windows)
|
|
585
|
+
try:
|
|
586
|
+
stdin, stdout, stderr = client.exec_command("Get-Host", timeout=5)
|
|
587
|
+
output = stdout.read().decode('utf-8', errors='ignore').strip().lower()
|
|
588
|
+
if "powershell" in output or "windows" in output:
|
|
589
|
+
return "windows"
|
|
590
|
+
except:
|
|
591
|
+
pass
|
|
592
|
+
|
|
593
|
+
# Default to linux (backward compatibility)
|
|
594
|
+
return "linux"
|
|
595
|
+
|
|
562
596
|
def ssh_execute_command(
|
|
563
597
|
host: str,
|
|
564
598
|
command: Union[str, List[str]],
|
|
@@ -600,10 +634,15 @@ def ssh_execute_command(
|
|
|
600
634
|
else:
|
|
601
635
|
command_str = command
|
|
602
636
|
|
|
637
|
+
with ssh_connect(
|
|
638
|
+
host, username, password, key_file, port, **kwargs
|
|
639
|
+
) as client:
|
|
640
|
+
# 1. DETECT REMOTE OS
|
|
641
|
+
remote_os = _detect_remote_os(client)
|
|
603
642
|
|
|
604
643
|
# Add environment variables
|
|
605
644
|
if environment:
|
|
606
|
-
command_str = _inject_environment_variables(environment, command_str)
|
|
645
|
+
command_str = _inject_environment_variables(environment, command_str,remote_os=remote_os)
|
|
607
646
|
|
|
608
647
|
# Add sudo
|
|
609
648
|
if sudo:
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|