salla-gitpuller 1.2.0__tar.gz → 1.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salla_gitpuller
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables
5
5
  Author-email: Mohammed Junaid <safijunaid.ss@gmail.com>, Muhammad Zahid <zahidmuhammad127@gmail.com>
6
6
  License: MIT
@@ -5,7 +5,7 @@ from .slack_notifier import SlackNotifier
5
5
  from .utils import transform_custom, get_repo_path, get_env_base_path
6
6
 
7
7
 
8
- __version__ = "1.2.0"
8
+ __version__ = "1.2.1"
9
9
  __all__ = [
10
10
  "GitPullExecutor",
11
11
  "AlertManager",
@@ -10,9 +10,6 @@ import requests
10
10
  SLACK_POST_MESSAGE_URL = "https://slack.com/api/chat.postMessage"
11
11
  SLACK_CONVERSATIONS_HISTORY_URL = "https://slack.com/api/conversations.history"
12
12
  DEFAULT_SLACK_CHANNEL = "C05MLHR55JT"
13
-
14
- # Unified across every Mage deployment — do not prefix with MAGE_WORKSPACE_NAME.
15
- # One hash per channel per day; field = gitpuller workspace, value = Slack thread_ts.
16
13
  REDIS_THREAD_KEY_PREFIX = "gitpuller:slack_thread"
17
14
  REDIS_CREATE_LOCK_TTL_SECONDS = 120
18
15
  REDIS_ERROR_MAX_CHARS = 1500
@@ -22,8 +19,16 @@ _redis_client = None
22
19
  _redis_init_attempted = False
23
20
 
24
21
 
22
+ def _env(*names: str, default: str = "") -> str:
23
+ for name in names:
24
+ value = (os.environ.get(name) or "").strip()
25
+ if value:
26
+ return value
27
+ return default
28
+
29
+
25
30
  def _get_redis_client():
26
- """Mage io_config.yaml first, then REDIS_HOST / REDIS_PORT / REDIS_PASSWORD."""
31
+ """WP_REDIS_* env vars first, then Mage io_config.yaml, then REDIS_*."""
27
32
  global _redis_client, _redis_init_attempted
28
33
  if _redis_client is not None:
29
34
  return _redis_client
@@ -37,27 +42,32 @@ def _get_redis_client():
37
42
  print("⚠️ redis package not installed; Slack thread_ts will not persist across pods")
38
43
  return None
39
44
 
40
- host = None
41
- password = None
42
- port = 6379
43
- try:
44
- from mage_ai.io.config import ConfigFileLoader
45
- from mage_ai.settings.repo import get_repo_path
45
+ host = _env("WP_REDIS_HOST")
46
+ password = _env("WP_REDIS_PASSWORD") or None
47
+ port = int(_env("WP_REDIS_PORT") or "6379")
46
48
 
47
- loader = ConfigFileLoader(os.path.join(get_repo_path(), "io_config.yaml"), "default")
48
- host = loader["REDIS_HOST"]
49
- password = loader["REDIS_PASSWORD"] or None
50
- port = int(loader["REDIS_PORT"])
51
- except Exception:
52
- host = None
49
+ if not host:
50
+ try:
51
+ from mage_ai.io.config import ConfigFileLoader
52
+ from mage_ai.settings.repo import get_repo_path
53
+
54
+ loader = ConfigFileLoader(os.path.join(get_repo_path(), "io_config.yaml"), "default")
55
+ host = loader["REDIS_HOST"]
56
+ password = loader["REDIS_PASSWORD"] or None
57
+ port = int(loader["REDIS_PORT"])
58
+ except Exception:
59
+ host = None
53
60
 
54
61
  if not host:
55
- host = (os.environ.get("REDIS_HOST") or "").strip() or None
56
- password = (os.environ.get("REDIS_PASSWORD") or "").strip() or None
57
- port = int(os.environ.get("REDIS_PORT") or 6379)
62
+ host = _env("REDIS_HOST") or None
63
+ password = _env("REDIS_PASSWORD") or None
64
+ port = int(_env("REDIS_PORT") or "6379")
58
65
 
59
66
  if not host:
60
- print("⚠️ Redis is not configured; Slack thread_ts will not persist across pods")
67
+ print(
68
+ "⚠️ Redis is not configured; Slack thread_ts will not persist across pods "
69
+ "(set WP_REDIS_HOST / WP_REDIS_PORT / WP_REDIS_PASSWORD)"
70
+ )
61
71
  return None
62
72
 
63
73
  try:
@@ -94,7 +104,11 @@ class SlackNotifier:
94
104
  bot_token: Optional[str] = None,
95
105
  channel: Optional[str] = None,
96
106
  ):
97
- self.bot_token = (bot_token or os.environ.get("CDM_PROD_SLACK_BOT_TOKEN") or "").strip() or None
107
+ self.bot_token = (
108
+ bot_token
109
+ or _env("WP_SLACK_DB_ALERTS_TOKEN", "CDM_PROD_SLACK_BOT_TOKEN")
110
+ or None
111
+ )
98
112
  self.channel = (
99
113
  (channel or os.environ.get("CDM_PROD_DB_SLACK_CHANNEL") or "").strip()
100
114
  or DEFAULT_SLACK_CHANNEL
@@ -105,11 +119,11 @@ class SlackNotifier:
105
119
  if not self.bot_token and not self.webhook_url:
106
120
  print(
107
121
  "⚠️ Slack not configured; skipping alerts "
108
- "(set CDM_PROD_SLACK_BOT_TOKEN, or CDM_SLACK_WEBHOOK_URL as fallback)"
122
+ "(set WP_SLACK_DB_ALERTS_TOKEN, or CDM_SLACK_WEBHOOK_URL as fallback)"
109
123
  )
110
124
  elif not self.bot_token:
111
125
  print(
112
- "⚠️ CDM_PROD_SLACK_BOT_TOKEN is not set; using webhook "
126
+ "⚠️ WP_SLACK_DB_ALERTS_TOKEN is not set; using webhook "
113
127
  "(alerts will not be threaded)"
114
128
  )
115
129
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "salla_gitpuller"
7
- version = "1.2.0"
7
+ version = "1.2.1"
8
8
  description = "A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salla_gitpuller
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables
5
5
  Author-email: Mohammed Junaid <safijunaid.ss@gmail.com>, Muhammad Zahid <zahidmuhammad127@gmail.com>
6
6
  License: MIT
File without changes