fetch2gmail 1.0.4__tar.gz → 1.0.6__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 (24) hide show
  1. {fetch2gmail-1.0.4/src/fetch2gmail.egg-info → fetch2gmail-1.0.6}/PKG-INFO +37 -3
  2. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/README.md +36 -2
  3. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/pyproject.toml +1 -1
  4. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6/src/fetch2gmail.egg-info}/PKG-INFO +37 -3
  5. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/cli.py +4 -0
  6. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/web_ui.py +6 -13
  7. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/LICENSE +0 -0
  8. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/setup.cfg +0 -0
  9. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetch2gmail.egg-info/SOURCES.txt +0 -0
  10. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetch2gmail.egg-info/dependency_links.txt +0 -0
  11. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetch2gmail.egg-info/entry_points.txt +0 -0
  12. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetch2gmail.egg-info/requires.txt +0 -0
  13. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetch2gmail.egg-info/top_level.txt +0 -0
  14. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/__init__.py +0 -0
  15. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/auth_server.py +0 -0
  16. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/auth_ui.py +0 -0
  17. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/config.py +0 -0
  18. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/env_file.py +0 -0
  19. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/gmail_client.py +0 -0
  20. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/imap_client.py +0 -0
  21. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/log_buffer.py +0 -0
  22. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/run.py +0 -0
  23. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/state.py +0 -0
  24. {fetch2gmail-1.0.4 → fetch2gmail-1.0.6}/src/fetcher/ui_auth.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fetch2gmail
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Self-hosted email fetcher: IMAP to Gmail API import with idempotent state tracking
5
5
  Author: Fetch2Gmail Contributors
6
6
  License-Expression: MIT
@@ -240,9 +240,32 @@ All app files live in **one directory**: **config.json**, **credentials.json**,
240
240
  | `fetch2gmail run` | Run one fetch cycle. |
241
241
  | `fetch2gmail run --dry-run` | Connect to ISP and show what would be imported; no Gmail import, no delete. |
242
242
 
243
- ### Uninstall (computer used only for token)
243
+ ### Uninstall
244
244
 
245
- After copying **credentials.json** and **token.json** to the server, you can remove fetch2gmail from that computer: `pipx uninstall fetch2gmail`. Reinstall with `pipx install fetch2gmail` if you need to run `fetch2gmail auth` again later.
245
+ **Machine used only to get the token (no system service):** After copying **credentials.json** and **token.json** to the server, remove the app: `pipx uninstall fetch2gmail`. Reinstall with `pipx install fetch2gmail` if you need to run `fetch2gmail auth` again later.
246
+
247
+ **Machine where the app runs (system service + app):** To remove everything so you can reinstall or run from source and see your changes:
248
+
249
+ 1. **Stop and disable the systemd service, then remove the unit file:**
250
+ ```bash
251
+ sudo systemctl stop fetch2gmail
252
+ sudo systemctl disable fetch2gmail
253
+ sudo rm /etc/systemd/system/fetch2gmail.service
254
+ sudo systemctl daemon-reload
255
+ ```
256
+ (To confirm the service is gone: `systemctl status fetch2gmail` should report "not found".)
257
+
258
+ 2. **Uninstall the app:**
259
+ - **If you installed with pipx:** `pipx uninstall fetch2gmail`
260
+ - **If you installed from source in a venv:** deactivate the venv (`deactivate`) and delete the project directory (e.g. `rm -rf ~/fetch2gmail`), or just use a different terminal and run from your dev clone with `pip install -e .` so the installed copy is no longer used.
261
+
262
+ 3. **Optionally remove the data directory** (config, credentials, token, state, UI password file):
263
+ ```bash
264
+ rm -rf /opt/fetch2gmail
265
+ ```
266
+ Use the path you used as the data directory (e.g. `/opt/fetch2gmail` or `~/fetch2gmail`). Only do this if you no longer need the config or token; back them up first if you might reuse them.
267
+
268
+ **To test local changes:** Uninstall the system copy (steps 1 and 2 above), then from your git clone run `python3 -m venv .venv`, `source .venv/bin/activate`, `pip install -e .`. Use that terminal to run `fetch2gmail serve` (or reinstall the system service later with `fetch2gmail install-service` and point it at your data directory).
246
269
 
247
270
  ---
248
271
 
@@ -272,6 +295,17 @@ To run from a git clone (e.g. to test changes before pushing):
272
295
  - `fetch2gmail auth` — get token (put **credentials.json** in the current directory first)
273
296
  - `fetch2gmail run` or `fetch2gmail run --dry-run` — if you have **config.json** and secrets set up
274
297
 
298
+ **Testing the UI locally (no need to reinstall or touch the service):** To try code changes without stopping the system service or reinstalling, run the UI from your clone on a **different port** so it doesn’t conflict with the service. Point the app at your data directory (where your config, credentials, token, and `.ui_auth` live) so it finds everything:
299
+
300
+ ```bash
301
+ cd /path/to/your/fetch2gmail # your git clone
302
+ source .venv/bin/activate # or .venv\Scripts\activate on Windows
303
+ pip install -e . # if you haven’t already (editable = your changes are used)
304
+ FETCH2GMAIL_CONFIG=/path/to/your/data/config.json fetch2gmail serve --port 8766
305
+ ```
306
+
307
+ Replace `/path/to/your/data` with your actual data directory (e.g. `/opt/fetch2gmail` or `~/fetch2gmail`). Then open **http://127.0.0.1:8766** in your browser. The system service (if it’s running) stays on 8765; this process uses your local code. Edit code, restart this command, and refresh the browser to test. If you prefer to use port 8765, stop the service first (`sudo systemctl stop fetch2gmail`), run `fetch2gmail serve` (no `--port`), then start the service again when you’re done.
308
+
275
309
  5. **Before pushing: test the build** so the package still builds and you catch errors:
276
310
  ```bash
277
311
  pip install build
@@ -209,9 +209,32 @@ All app files live in **one directory**: **config.json**, **credentials.json**,
209
209
  | `fetch2gmail run` | Run one fetch cycle. |
210
210
  | `fetch2gmail run --dry-run` | Connect to ISP and show what would be imported; no Gmail import, no delete. |
211
211
 
212
- ### Uninstall (computer used only for token)
212
+ ### Uninstall
213
213
 
214
- After copying **credentials.json** and **token.json** to the server, you can remove fetch2gmail from that computer: `pipx uninstall fetch2gmail`. Reinstall with `pipx install fetch2gmail` if you need to run `fetch2gmail auth` again later.
214
+ **Machine used only to get the token (no system service):** After copying **credentials.json** and **token.json** to the server, remove the app: `pipx uninstall fetch2gmail`. Reinstall with `pipx install fetch2gmail` if you need to run `fetch2gmail auth` again later.
215
+
216
+ **Machine where the app runs (system service + app):** To remove everything so you can reinstall or run from source and see your changes:
217
+
218
+ 1. **Stop and disable the systemd service, then remove the unit file:**
219
+ ```bash
220
+ sudo systemctl stop fetch2gmail
221
+ sudo systemctl disable fetch2gmail
222
+ sudo rm /etc/systemd/system/fetch2gmail.service
223
+ sudo systemctl daemon-reload
224
+ ```
225
+ (To confirm the service is gone: `systemctl status fetch2gmail` should report "not found".)
226
+
227
+ 2. **Uninstall the app:**
228
+ - **If you installed with pipx:** `pipx uninstall fetch2gmail`
229
+ - **If you installed from source in a venv:** deactivate the venv (`deactivate`) and delete the project directory (e.g. `rm -rf ~/fetch2gmail`), or just use a different terminal and run from your dev clone with `pip install -e .` so the installed copy is no longer used.
230
+
231
+ 3. **Optionally remove the data directory** (config, credentials, token, state, UI password file):
232
+ ```bash
233
+ rm -rf /opt/fetch2gmail
234
+ ```
235
+ Use the path you used as the data directory (e.g. `/opt/fetch2gmail` or `~/fetch2gmail`). Only do this if you no longer need the config or token; back them up first if you might reuse them.
236
+
237
+ **To test local changes:** Uninstall the system copy (steps 1 and 2 above), then from your git clone run `python3 -m venv .venv`, `source .venv/bin/activate`, `pip install -e .`. Use that terminal to run `fetch2gmail serve` (or reinstall the system service later with `fetch2gmail install-service` and point it at your data directory).
215
238
 
216
239
  ---
217
240
 
@@ -241,6 +264,17 @@ To run from a git clone (e.g. to test changes before pushing):
241
264
  - `fetch2gmail auth` — get token (put **credentials.json** in the current directory first)
242
265
  - `fetch2gmail run` or `fetch2gmail run --dry-run` — if you have **config.json** and secrets set up
243
266
 
267
+ **Testing the UI locally (no need to reinstall or touch the service):** To try code changes without stopping the system service or reinstalling, run the UI from your clone on a **different port** so it doesn’t conflict with the service. Point the app at your data directory (where your config, credentials, token, and `.ui_auth` live) so it finds everything:
268
+
269
+ ```bash
270
+ cd /path/to/your/fetch2gmail # your git clone
271
+ source .venv/bin/activate # or .venv\Scripts\activate on Windows
272
+ pip install -e . # if you haven’t already (editable = your changes are used)
273
+ FETCH2GMAIL_CONFIG=/path/to/your/data/config.json fetch2gmail serve --port 8766
274
+ ```
275
+
276
+ Replace `/path/to/your/data` with your actual data directory (e.g. `/opt/fetch2gmail` or `~/fetch2gmail`). Then open **http://127.0.0.1:8766** in your browser. The system service (if it’s running) stays on 8765; this process uses your local code. Edit code, restart this command, and refresh the browser to test. If you prefer to use port 8765, stop the service first (`sudo systemctl stop fetch2gmail`), run `fetch2gmail serve` (no `--port`), then start the service again when you’re done.
277
+
244
278
  5. **Before pushing: test the build** so the package still builds and you catch errors:
245
279
  ```bash
246
280
  pip install build
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fetch2gmail"
7
- version = "1.0.4"
7
+ version = "1.0.6"
8
8
  description = "Self-hosted email fetcher: IMAP to Gmail API import with idempotent state tracking"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fetch2gmail
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Self-hosted email fetcher: IMAP to Gmail API import with idempotent state tracking
5
5
  Author: Fetch2Gmail Contributors
6
6
  License-Expression: MIT
@@ -240,9 +240,32 @@ All app files live in **one directory**: **config.json**, **credentials.json**,
240
240
  | `fetch2gmail run` | Run one fetch cycle. |
241
241
  | `fetch2gmail run --dry-run` | Connect to ISP and show what would be imported; no Gmail import, no delete. |
242
242
 
243
- ### Uninstall (computer used only for token)
243
+ ### Uninstall
244
244
 
245
- After copying **credentials.json** and **token.json** to the server, you can remove fetch2gmail from that computer: `pipx uninstall fetch2gmail`. Reinstall with `pipx install fetch2gmail` if you need to run `fetch2gmail auth` again later.
245
+ **Machine used only to get the token (no system service):** After copying **credentials.json** and **token.json** to the server, remove the app: `pipx uninstall fetch2gmail`. Reinstall with `pipx install fetch2gmail` if you need to run `fetch2gmail auth` again later.
246
+
247
+ **Machine where the app runs (system service + app):** To remove everything so you can reinstall or run from source and see your changes:
248
+
249
+ 1. **Stop and disable the systemd service, then remove the unit file:**
250
+ ```bash
251
+ sudo systemctl stop fetch2gmail
252
+ sudo systemctl disable fetch2gmail
253
+ sudo rm /etc/systemd/system/fetch2gmail.service
254
+ sudo systemctl daemon-reload
255
+ ```
256
+ (To confirm the service is gone: `systemctl status fetch2gmail` should report "not found".)
257
+
258
+ 2. **Uninstall the app:**
259
+ - **If you installed with pipx:** `pipx uninstall fetch2gmail`
260
+ - **If you installed from source in a venv:** deactivate the venv (`deactivate`) and delete the project directory (e.g. `rm -rf ~/fetch2gmail`), or just use a different terminal and run from your dev clone with `pip install -e .` so the installed copy is no longer used.
261
+
262
+ 3. **Optionally remove the data directory** (config, credentials, token, state, UI password file):
263
+ ```bash
264
+ rm -rf /opt/fetch2gmail
265
+ ```
266
+ Use the path you used as the data directory (e.g. `/opt/fetch2gmail` or `~/fetch2gmail`). Only do this if you no longer need the config or token; back them up first if you might reuse them.
267
+
268
+ **To test local changes:** Uninstall the system copy (steps 1 and 2 above), then from your git clone run `python3 -m venv .venv`, `source .venv/bin/activate`, `pip install -e .`. Use that terminal to run `fetch2gmail serve` (or reinstall the system service later with `fetch2gmail install-service` and point it at your data directory).
246
269
 
247
270
  ---
248
271
 
@@ -272,6 +295,17 @@ To run from a git clone (e.g. to test changes before pushing):
272
295
  - `fetch2gmail auth` — get token (put **credentials.json** in the current directory first)
273
296
  - `fetch2gmail run` or `fetch2gmail run --dry-run` — if you have **config.json** and secrets set up
274
297
 
298
+ **Testing the UI locally (no need to reinstall or touch the service):** To try code changes without stopping the system service or reinstalling, run the UI from your clone on a **different port** so it doesn’t conflict with the service. Point the app at your data directory (where your config, credentials, token, and `.ui_auth` live) so it finds everything:
299
+
300
+ ```bash
301
+ cd /path/to/your/fetch2gmail # your git clone
302
+ source .venv/bin/activate # or .venv\Scripts\activate on Windows
303
+ pip install -e . # if you haven’t already (editable = your changes are used)
304
+ FETCH2GMAIL_CONFIG=/path/to/your/data/config.json fetch2gmail serve --port 8766
305
+ ```
306
+
307
+ Replace `/path/to/your/data` with your actual data directory (e.g. `/opt/fetch2gmail` or `~/fetch2gmail`). Then open **http://127.0.0.1:8766** in your browser. The system service (if it’s running) stays on 8765; this process uses your local code. Edit code, restart this command, and refresh the browser to test. If you prefer to use port 8765, stop the service first (`sudo systemctl stop fetch2gmail`), run `fetch2gmail serve` (no `--port`), then start the service again when you’re done.
308
+
275
309
  5. **Before pushing: test the build** so the package still builds and you catch errors:
276
310
  ```bash
277
311
  pip install build
@@ -219,6 +219,10 @@ def _cmd_set_ui_password(args: argparse.Namespace) -> None:
219
219
  if not password:
220
220
  print("Password cannot be empty.", file=sys.stderr)
221
221
  sys.exit(1)
222
+ password_confirm = getpass.getpass("Confirm password: ")
223
+ if password != password_confirm:
224
+ print("Passwords do not match.", file=sys.stderr)
225
+ sys.exit(1)
222
226
  create_ui_auth(config_dir, username, password)
223
227
  print("Done. The web UI will now require this username and password when you run it")
224
228
 
@@ -228,19 +228,19 @@ def api_auth_required() -> dict[str, Any]:
228
228
 
229
229
  @app.get("/api/auth/session")
230
230
  def api_auth_session(request: Request) -> dict[str, bool]:
231
- """Whether the current request is logged in (UI password passed, or Google session, or no auth)."""
231
+ """Whether the current request is logged in; ui_password_mode=True when .ui_auth is used (hide Log out)."""
232
232
  cfg_dir = _config_dir_safe()
233
233
  if load_ui_auth(cfg_dir):
234
- return {"logged_in": True}
235
- return {"logged_in": verify_request(request, cfg_dir, _config_exists())}
234
+ return {"logged_in": True, "ui_password_mode": True}
235
+ return {"logged_in": verify_request(request, cfg_dir, _config_exists()), "ui_password_mode": False}
236
236
 
237
237
 
238
238
  @app.post("/api/logout")
239
239
  def api_logout():
240
- """Clear session and redirect. With Basic Auth, browser may still re-send credentials; redirect to / with hint."""
240
+ """Clear session and redirect. Log out button is hidden when .ui_auth is used (Basic Auth cannot be cleared from the page)."""
241
241
  cfg_dir = _config_dir_safe()
242
242
  if load_ui_auth(cfg_dir):
243
- resp = RedirectResponse(url="/?logged_out=1", status_code=302)
243
+ resp = RedirectResponse(url="/", status_code=302)
244
244
  else:
245
245
  resp = RedirectResponse(url="/login", status_code=302)
246
246
  clear_session_cookie(resp)
@@ -626,7 +626,6 @@ _HTML_PAGE = """
626
626
  <body>
627
627
  <h1>Fetch2Gmail <span class="logout" id="logoutSpan" style="display:none"><form method="post" action="/api/logout" style="display:inline"><button type="submit">Log out</button></form></span></h1>
628
628
  <p id="subtitle">IMAP to Gmail import. Configure below.</p>
629
- <p id="loggedOutMsg" style="display:none" class="status"></p>
630
629
  <p id="loadingMsg">Loading...</p>
631
630
 
632
631
  <div id="credentialsFirst" style="display:none">
@@ -723,7 +722,7 @@ _APP_JS = r"""
723
722
  document.getElementById('landing').style.display = 'block';
724
723
  return;
725
724
  }
726
- document.getElementById('logoutSpan').style.display = 'inline';
725
+ if (!session.ui_password_mode) document.getElementById('logoutSpan').style.display = 'inline';
727
726
  loadConfig().then(function(c) { if (c) { loadStatus(); loadLogs(); } });
728
727
  }).catch(function() {
729
728
  document.getElementById('loadingMsg').style.display = 'none';
@@ -736,12 +735,6 @@ _APP_JS = r"""
736
735
  document.getElementById('subtitle').textContent = 'Gmail connected. You can run a fetch now.';
737
736
  history.replaceState({}, '', '/');
738
737
  }
739
- if (params.get('logged_out') === '1') {
740
- var el = document.getElementById('loggedOutMsg');
741
- el.style.display = 'block';
742
- el.textContent = 'You clicked Log out. When using password protection, the browser may still send your password. To fully log out, close this tab or use a private window.';
743
- history.replaceState({}, '', '/');
744
- }
745
738
  if (params.get('error') === 'no_credentials') document.getElementById('subtitle').innerHTML = '<span class="error">Put credentials.json in the app folder and try Connect Gmail again.</span>';
746
739
 
747
740
  function hideLoading() { var el = document.getElementById('loadingMsg'); if (el) el.style.display = 'none'; }
File without changes
File without changes