feat: baca SESSION_ID, USER_ID, EMPLOYEE_ID dari .env
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
4
.env.example
Normal file
4
.env.example
Normal file
@@ -0,0 +1,4 @@
|
||||
SESSION_ID=your_session_id_here
|
||||
USER_ID=41
|
||||
EMPLOYEE_ID=37
|
||||
AUTHOR=sas.fajri
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
run_daily.sh
|
||||
.env
|
||||
.claude/
|
||||
pending_*.json
|
||||
done_*.json
|
||||
|
||||
@@ -11,6 +11,7 @@ Contoh: Task A span 2 jam + Task B span 1.5 jam + Task C 1 commit →
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import urllib.request
|
||||
@@ -19,6 +20,23 @@ import argparse
|
||||
from datetime import date, datetime, timedelta
|
||||
from collections import defaultdict
|
||||
from decimal import Decimal, ROUND_HALF_UP
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def load_env() -> dict:
|
||||
"""Baca .env dari direktori script, return dict key=value."""
|
||||
env_path = Path(__file__).parent / ".env"
|
||||
env = {}
|
||||
if env_path.exists():
|
||||
for line in env_path.read_text().splitlines():
|
||||
line = line.strip()
|
||||
if line and not line.startswith("#") and "=" in line:
|
||||
k, v = line.split("=", 1)
|
||||
env[k.strip()] = v.strip()
|
||||
return env
|
||||
|
||||
|
||||
ENV = load_env()
|
||||
|
||||
BASE_URL = "https://odoo.aplikasi.web.id"
|
||||
TOTAL_HOURS = 8
|
||||
@@ -243,10 +261,10 @@ def main():
|
||||
today = date.today().isoformat()
|
||||
|
||||
parser = argparse.ArgumentParser(description="Daily timesheet: commit → Odoo (8 jam pro-rata)")
|
||||
parser.add_argument("--session-id", required=True, help="session_id cookie Odoo")
|
||||
parser.add_argument("--author", required=True, help="Git author filter, e.g. 'fajri'")
|
||||
parser.add_argument("--user-id", required=True, type=int, help="ID user Odoo")
|
||||
parser.add_argument("--employee-id", required=True, type=int, help="ID employee Odoo")
|
||||
parser.add_argument("--session-id", default=ENV.get("SESSION_ID"), help="session_id cookie Odoo")
|
||||
parser.add_argument("--author", default=ENV.get("AUTHOR"), help="Git author filter")
|
||||
parser.add_argument("--user-id", default=ENV.get("USER_ID"), type=int, help="ID user Odoo")
|
||||
parser.add_argument("--employee-id", default=ENV.get("EMPLOYEE_ID"), type=int, help="ID employee Odoo")
|
||||
parser.add_argument("--date", default=today, help=f"Tanggal YYYY-MM-DD (default: {today})")
|
||||
parser.add_argument("--dry-run", action="store_true", help="Preview saja, tidak upload")
|
||||
parser.add_argument("--save-pending", action="store_true", help="Simpan ke pending.json + notifikasi macOS")
|
||||
|
||||
Reference in New Issue
Block a user