AP manageur V1.1 (Bêta)
This commit is contained in:
1 parent
da07838fda
commit
0b685640f8
4 files changed
+136
-9
No files matched your search
@@ -10677,7 +10677,134 @@ def _download_gdrive(cfg, remote_filename, dest_path):
|
|||||||
dl_url = f"https://www.googleapis.com/drive/v3/files/{file_id}?alt=media"
|
dl_url = f"https://www.googleapis.com/drive/v3/files/{file_id}?alt=media"
|
||||||
dl_req = urllib.request.Request(dl_url, method='GET')
|
dl_req = urllib.request.Request(dl_url, method='GET')
|
||||||
dl_req.add_header('Authorization', f'Bearer {token}')
|
dl_req.add_header('Authorization', f'Bearer {token}')
|
||||||
except Exception:
|
with urllib.request.urlopen(dl_req, context=ctx, timeout=60) as resp:
|
||||||
|
with open(dest_path, 'wb') as out_f:
|
||||||
|
while True:
|
||||||
|
chunk = resp.read(65536)
|
||||||
|
if not chunk: break
|
||||||
|
out_f.write(chunk)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _download_webdav(cfg, remote_filename, dest_path):
|
||||||
|
server_url = str(cfg.get('url', '')).strip()
|
||||||
|
if not server_url: raise ValueError("URL WebDAV manquante")
|
||||||
|
if not server_url.endswith('/'): server_url += '/'
|
||||||
|
extra_path = str(cfg.get('path', '')).strip().strip('/')
|
||||||
|
if extra_path:
|
||||||
|
server_url += '/'.join(urllib.parse.quote(p) for p in extra_path.split('/')) + '/'
|
||||||
|
target_url = server_url + urllib.parse.quote(remote_filename)
|
||||||
|
user = str(cfg.get('user', '')).strip()
|
||||||
|
password = str(cfg.get('password', ''))
|
||||||
|
req = urllib.request.Request(target_url, method='GET')
|
||||||
|
if user or password:
|
||||||
|
auth_str = base64.b64encode(f"{user}:{password}".encode('utf-8')).decode('ascii')
|
||||||
|
req.add_header('Authorization', f'Basic {auth_str}')
|
||||||
|
ctx = ssl.create_default_context()
|
||||||
|
with urllib.request.urlopen(req, context=ctx, timeout=60) as resp:
|
||||||
|
with open(dest_path, 'wb') as out_f:
|
||||||
|
while True:
|
||||||
|
chunk = resp.read(65536)
|
||||||
|
if not chunk: break
|
||||||
|
out_f.write(chunk)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _download_s3(cfg, remote_filename, dest_path):
|
||||||
|
endpoint = str(cfg.get('endpoint', '') or 'https://s3.amazonaws.com').strip()
|
||||||
|
bucket = str(cfg.get('bucket', '')).strip()
|
||||||
|
if not bucket: raise ValueError("Bucket S3 manquant")
|
||||||
|
region = str(cfg.get('region', '') or 'us-east-1').strip()
|
||||||
|
access_key = str(cfg.get('access_key', '')).strip()
|
||||||
|
secret_key = str(cfg.get('secret_key', '')).strip()
|
||||||
|
prefix = str(cfg.get('path', '') or '').strip().strip('/')
|
||||||
|
key = f"{prefix}/{remote_filename}" if prefix else remote_filename
|
||||||
|
rclone_bin = find_bin('rclone')
|
||||||
|
if rclone_bin:
|
||||||
|
rc = tempfile.NamedTemporaryFile('w', delete=False)
|
||||||
|
try:
|
||||||
|
rc.write(f"[s3remote]\ntype = s3\nprovider = Other\nendpoint = {endpoint}\nregion = {region}\naccess_key_id = {access_key}\nsecret_access_key = {secret_key}\n")
|
||||||
|
rc.flush(); rc.close()
|
||||||
|
cmd = [rclone_bin, '--config', rc.name, 'copyto', f"s3remote:{bucket}/{key}", dest_path]
|
||||||
|
r = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
|
||||||
|
if r.returncode != 0:
|
||||||
|
raise RuntimeError(r.stderr.strip() or f"Erreur rclone copyto ({r.returncode})")
|
||||||
|
return True
|
||||||
|
finally:
|
||||||
|
if os.path.exists(rc.name):
|
||||||
|
try: os.unlink(rc.name)
|
||||||
|
except OSError: pass
|
||||||
|
raise RuntimeError("Client S3 introuvable (rclone requis)")
|
||||||
|
|
||||||
|
def download_remote_file(remote_filename, dest_path, custom_cfg=None):
|
||||||
|
cfg = custom_cfg or get_backup_remote_config()
|
||||||
|
provider = str(cfg.get('provider', 'ftp')).strip().lower()
|
||||||
|
p_cfg = cfg.get(provider, {}) if isinstance(cfg.get(provider), dict) else {}
|
||||||
|
if provider == 'ftp':
|
||||||
|
return _download_ftp(p_cfg, remote_filename, dest_path)
|
||||||
|
elif provider == 'sftp':
|
||||||
|
return _download_sftp(p_cfg, remote_filename, dest_path)
|
||||||
|
elif provider == 'dropbox':
|
||||||
|
return _download_dropbox(p_cfg, remote_filename, dest_path)
|
||||||
|
elif provider == 'gdrive':
|
||||||
|
return _download_gdrive(p_cfg, remote_filename, dest_path)
|
||||||
|
elif provider == 'webdav':
|
||||||
|
return _download_webdav(p_cfg, remote_filename, dest_path)
|
||||||
|
elif provider == 's3':
|
||||||
|
return _download_s3(p_cfg, remote_filename, dest_path)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Protocole distant {provider} non pris en charge pour le téléchargement")
|
||||||
|
|
||||||
|
def list_remote_files_detailed(custom_cfg=None):
|
||||||
|
cfg = custom_cfg or get_backup_remote_config()
|
||||||
|
if not cfg.get('enabled'):
|
||||||
|
return None, "Stockage distant désactivé"
|
||||||
|
provider = str(cfg.get('provider', 'ftp')).strip().lower()
|
||||||
|
p_cfg = cfg.get(provider, {}) if isinstance(cfg.get(provider), dict) else {}
|
||||||
|
|
||||||
|
ensure_backup_dir()
|
||||||
|
local_files = set()
|
||||||
|
try:
|
||||||
|
local_files = set(os.listdir(BACKUP_DIR))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
items = []
|
||||||
|
if provider == 'ftp':
|
||||||
|
import ftplib
|
||||||
|
host = str(p_cfg.get('host', '')).strip()
|
||||||
|
if not host: return [], ""
|
||||||
|
try: port = int(p_cfg.get('port') or 21)
|
||||||
|
except (ValueError, TypeError): port = 21
|
||||||
|
user = str(p_cfg.get('user', '')).strip() or 'anonymous'
|
||||||
|
password = str(p_cfg.get('password', ''))
|
||||||
|
rem_path = str(p_cfg.get('path', '') or '').strip()
|
||||||
|
use_tls = str(p_cfg.get('tls', 'none')).lower() in ('explicit', 'tls', 'ftps', '1', 'true')
|
||||||
|
ftp = ftplib.FTP_TLS(timeout=15) if use_tls else ftplib.FTP(timeout=15)
|
||||||
|
try:
|
||||||
|
ftp.connect(host, port)
|
||||||
|
ftp.login(user, password)
|
||||||
|
if use_tls: ftp.prot_p()
|
||||||
|
if rem_path and rem_path not in ('/', '.'):
|
||||||
|
for part in [p for p in rem_path.split('/') if p]:
|
||||||
|
try: ftp.cwd(part)
|
||||||
|
except Exception: pass
|
||||||
|
used_mlsd = False
|
||||||
|
try:
|
||||||
|
for line in ftp.mlsd():
|
||||||
|
name, facts = line
|
||||||
|
if facts.get('type') == 'file' and name.lower().endswith(BACKUP_ALLOWED_EXTS):
|
||||||
|
size = int(facts.get('size') or 0)
|
||||||
|
mtime_str = facts.get('modify', '')
|
||||||
|
dt_str = ''
|
||||||
|
if len(mtime_str) >= 14:
|
||||||
|
dt_str = f"{mtime_str[0:4]}-{mtime_str[4:6]}-{mtime_str[6:8]} {mtime_str[8:10]}:{mtime_str[10:12]}:{mtime_str[12:14]}"
|
||||||
|
items.append({
|
||||||
|
'name': name,
|
||||||
|
'size': size,
|
||||||
|
'size_str': format_bytes(size),
|
||||||
|
'date': dt_str,
|
||||||
|
'is_local': (name in local_files)
|
||||||
|
})
|
||||||
|
used_mlsd = True
|
||||||
pass
|
pass
|
||||||
if not used_mlsd:
|
if not used_mlsd:
|
||||||
try:
|
try:
|
||||||
|
|||||||
+4
-4
@@ -2376,7 +2376,7 @@
|
|||||||
Administration de l’AP Wi‑Fi</h2>
|
Administration de l’AP Wi‑Fi</h2>
|
||||||
<div class="sub" style="margin-top:4px"><span class="app-short-title">AP Manageur</span> <span
|
<div class="sub" style="margin-top:4px"><span class="app-short-title">AP Manageur</span> <span
|
||||||
class="app-version"
|
class="app-version"
|
||||||
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:11px;margin-left:4px">V1.1 (Béta)</span>
|
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:11px;margin-left:4px">V1.1 (Bêta)</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="loaderBadge"
|
<div id="loaderBadge"
|
||||||
style="display:inline-flex;align-items:center;gap:6px;background:rgba(56,189,248,0.12);border:1px solid rgba(56,189,248,0.3);color:var(--blue);padding:3px 12px;border-radius:20px;font-size:12px;font-weight:600;margin-top:8px">
|
style="display:inline-flex;align-items:center;gap:6px;background:rgba(56,189,248,0.12);border:1px solid rgba(56,189,248,0.3);color:var(--blue);padding:3px 12px;border-radius:20px;font-size:12px;font-weight:600;margin-top:8px">
|
||||||
@@ -2571,7 +2571,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1><span class="app-title" data-i18n="app_main_heading">Administration de l’AP Wi‑Fi</span></h1>
|
<h1><span class="app-title" data-i18n="app_main_heading">Administration de l’AP Wi‑Fi</span></h1>
|
||||||
<div class="sub"><span class="app-short-title">AP Manageur</span> <span class="app-version"
|
<div class="sub"><span class="app-short-title">AP Manageur</span> <span class="app-version"
|
||||||
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:12px;margin-left:4px">V1.1 (Béta)</span>
|
style="font-weight:700;background:var(--panel2);padding:2px 8px;border-radius:6px;border:1px solid var(--line);color:var(--blue);font-size:12px;margin-left:4px">V1.1 (Bêta)</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
@@ -5577,7 +5577,7 @@
|
|||||||
<div style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line)">
|
<div style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line)">
|
||||||
<div class="label" data-i18n="adv_update_current_ver" style="font-size:11px">Version actuelle</div>
|
<div class="label" data-i18n="adv_update_current_ver" style="font-size:11px">Version actuelle</div>
|
||||||
<div id="advUpdateCurrentCommit" style="font-family:monospace;font-size:16px;font-weight:700;color:var(--text);margin-top:2px">—</div>
|
<div id="advUpdateCurrentCommit" style="font-family:monospace;font-size:16px;font-weight:700;color:var(--text);margin-top:2px">—</div>
|
||||||
<div class="muted" style="font-size:11px;margin-top:2px" id="advUpdateVersionTag"><span class="app-short-title">AP Manageur</span> <span class="app-version">V1.1 (Béta)</span></div>
|
<div class="muted" style="font-size:11px;margin-top:2px" id="advUpdateVersionTag"><span class="app-short-title">AP Manageur</span> <span class="app-version">V1.1 (Bêta)</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line)">
|
<div style="background:var(--panel2);padding:10px 12px;border-radius:8px;border:1px solid var(--line)">
|
||||||
<div class="label" data-i18n="adv_update_latest_ver" style="font-size:11px">Dernière version (Gitea)</div>
|
<div class="label" data-i18n="adv_update_latest_ver" style="font-size:11px">Dernière version (Gitea)</div>
|
||||||
@@ -7179,7 +7179,7 @@
|
|||||||
function $(id) { return document.getElementById(id); }
|
function $(id) { return document.getElementById(id); }
|
||||||
const API_URL = location.protocol === 'file:' ? 'http://127.0.0.1:8080' : '';
|
const API_URL = location.protocol === 'file:' ? 'http://127.0.0.1:8080' : '';
|
||||||
/* Version de l'application */
|
/* Version de l'application */
|
||||||
let APP_VERSION = "V1.1 (Béta)";
|
let APP_VERSION = "V1.1 (Bêta)";
|
||||||
const ICON_REFRESH_ARROW = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block;vertical-align:middle"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.9 1 6.7 2.4L21 8"/><polyline points="21 3 21 8 16 8"/></svg>';
|
const ICON_REFRESH_ARROW = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block;vertical-align:middle"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.9 1 6.7 2.4L21 8"/><polyline points="21 3 21 8 16 8"/></svg>';
|
||||||
const ICON_GEAR = '⚙️';
|
const ICON_GEAR = '⚙️';
|
||||||
const ICON_TABLET = '<svg width="1.15em" height="1.15em" viewBox="0 0 24 24" fill="none" style="display:inline-block;vertical-align:-0.18em;flex-shrink:0" aria-label="Tablette"><rect x="2.5" y="1.5" width="19" height="21" rx="2.5" fill="#1e293b" stroke="#64748b" stroke-width="1"/><rect x="4" y="3.2" width="16" height="15.6" rx="1.2" fill="#38bdf8"/><circle cx="12" cy="2.3" r="0.5" fill="#94a3b8"/><rect x="10" y="20" width="4" height="1.2" rx="0.6" fill="#94a3b8"/></svg>';
|
const ICON_TABLET = '<svg width="1.15em" height="1.15em" viewBox="0 0 24 24" fill="none" style="display:inline-block;vertical-align:-0.18em;flex-shrink:0" aria-label="Tablette"><rect x="2.5" y="1.5" width="19" height="21" rx="2.5" fill="#1e293b" stroke="#64748b" stroke-width="1"/><rect x="4" y="3.2" width="16" height="15.6" rx="1.2" fill="#38bdf8"/><circle cx="12" cy="2.3" r="0.5" fill="#94a3b8"/><rect x="10" y="20" width="4" height="1.2" rx="0.6" fill="#94a3b8"/></svg>';
|
||||||
|
|||||||
+1
-1
@@ -1035,7 +1035,7 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<div class="sub">
|
<div class="sub">
|
||||||
<span class="app-short-title">AP Manageur</span>
|
<span class="app-short-title">AP Manageur</span>
|
||||||
<span class="pill app-version" style="margin-left:6px;font-size:11px">V1.1 (Béta)</span>
|
<span class="pill app-version" style="margin-left:6px;font-size:11px">V1.1 (Bêta)</span>
|
||||||
<span class="pill" style="margin-left:4px;font-size:11px;color:var(--blue);border-color:var(--blue)"
|
<span class="pill" style="margin-left:4px;font-size:11px;color:var(--blue);border-color:var(--blue)"
|
||||||
data-i18n="app_badge_setup">Configuration initiale</span>
|
data-i18n="app_badge_setup">Configuration initiale</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "V1.1 (Béta)",
|
"version": "V1.1 (Bêta)",
|
||||||
"commit": "4ab701ee587f50a2679e3d12da32b116f389ba4d",
|
"commit": "da07838fda9e26d08ad293737c978a62d4ee30a8",
|
||||||
"build_date": "2026-11-22T21:53:11Z"
|
"build_date": "2026-11-22T22:22:21Z"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user