stock-weekly-report 0.1.0 → 0.1.2
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.
- package/cli.py +44 -13
- package/package.json +1 -1
- package/pyproject.toml +1 -1
package/cli.py
CHANGED
|
@@ -17,6 +17,7 @@ Usage:
|
|
|
17
17
|
|
|
18
18
|
import os
|
|
19
19
|
import re
|
|
20
|
+
import shutil
|
|
20
21
|
import smtplib
|
|
21
22
|
import subprocess
|
|
22
23
|
import sys
|
|
@@ -89,6 +90,26 @@ def _write_zprofile_var(var_name: str, value: str) -> None:
|
|
|
89
90
|
zprofile.write_text(content, encoding="utf-8")
|
|
90
91
|
|
|
91
92
|
|
|
93
|
+
def _detect_nlm() -> str:
|
|
94
|
+
"""Auto-detect the nlm binary path."""
|
|
95
|
+
# 1. Check PATH
|
|
96
|
+
found = shutil.which("nlm")
|
|
97
|
+
if found:
|
|
98
|
+
return found
|
|
99
|
+
# 2. Check common install locations
|
|
100
|
+
candidates = [
|
|
101
|
+
"~/.openclaw/workspace/venv/bin/nlm",
|
|
102
|
+
"~/.local/bin/nlm",
|
|
103
|
+
"/usr/local/bin/nlm",
|
|
104
|
+
]
|
|
105
|
+
for candidate in candidates:
|
|
106
|
+
expanded = Path(candidate).expanduser()
|
|
107
|
+
if expanded.exists():
|
|
108
|
+
return str(expanded)
|
|
109
|
+
# 3. Fall back to the most common location (expanded)
|
|
110
|
+
return str(Path("~/.openclaw/workspace/venv/bin/nlm").expanduser())
|
|
111
|
+
|
|
112
|
+
|
|
92
113
|
def _install_cron_job(schedule: str) -> None:
|
|
93
114
|
run_sh = PROJECT_ROOT / "run.sh"
|
|
94
115
|
lines = _get_crontab()
|
|
@@ -133,8 +154,8 @@ def init(ctx):
|
|
|
133
154
|
default_folder = cfg.get("parent_folder", str(PROJECT_ROOT / "data"))
|
|
134
155
|
parent_folder = click.prompt("Data folder path", default=default_folder)
|
|
135
156
|
|
|
136
|
-
# 2. nlm binary path
|
|
137
|
-
default_nlm = cfg.get("nlm_path"
|
|
157
|
+
# 2. nlm binary path (auto-detect if not already in config)
|
|
158
|
+
default_nlm = cfg.get("nlm_path") or _detect_nlm()
|
|
138
159
|
nlm_path = click.prompt("nlm binary path", default=default_nlm)
|
|
139
160
|
nlm_path_expanded = str(Path(nlm_path).expanduser())
|
|
140
161
|
if Path(nlm_path_expanded).exists():
|
|
@@ -142,22 +163,32 @@ def init(ctx):
|
|
|
142
163
|
else:
|
|
143
164
|
click.echo(f" ! nlm not found at {nlm_path_expanded} — fix this later if needed")
|
|
144
165
|
|
|
145
|
-
# 3. SMTP password → ~/.zprofile
|
|
166
|
+
# 3. SMTP password → ~/.zprofile (optional)
|
|
146
167
|
existing_password = os.environ.get("EMAIL_SMTP_PASSWORD", "")
|
|
147
168
|
if existing_password:
|
|
148
169
|
click.echo(" EMAIL_SMTP_PASSWORD is already set in environment.")
|
|
149
170
|
change_pw = click.confirm(" Update it?", default=False)
|
|
171
|
+
if change_pw:
|
|
172
|
+
smtp_password = click.prompt(
|
|
173
|
+
"Gmail App Password (saved to ~/.zprofile)", hide_input=True
|
|
174
|
+
)
|
|
175
|
+
_write_zprofile_var("EMAIL_SMTP_PASSWORD", smtp_password)
|
|
176
|
+
click.echo(" ✓ Saved to ~/.zprofile")
|
|
177
|
+
else:
|
|
178
|
+
smtp_password = existing_password
|
|
150
179
|
else:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
180
|
+
click.echo(" Gmail App Password is optional — skip to set it later via")
|
|
181
|
+
click.echo(" export EMAIL_SMTP_PASSWORD=<your-app-password> in ~/.zprofile")
|
|
182
|
+
set_pw = click.confirm(" Set it now?", default=False)
|
|
183
|
+
if set_pw:
|
|
184
|
+
smtp_password = click.prompt(
|
|
185
|
+
"Gmail App Password (saved to ~/.zprofile)", hide_input=True
|
|
186
|
+
)
|
|
187
|
+
_write_zprofile_var("EMAIL_SMTP_PASSWORD", smtp_password)
|
|
188
|
+
click.echo(" ✓ Saved to ~/.zprofile")
|
|
189
|
+
else:
|
|
190
|
+
smtp_password = ""
|
|
191
|
+
click.echo(" Skipped — remember to set EMAIL_SMTP_PASSWORD before running the pipeline.")
|
|
161
192
|
|
|
162
193
|
# 4. Sender email
|
|
163
194
|
default_from = cfg.get("email", {}).get("from", "")
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED