sync: auto-sync from GURU-5070 at 2026-06-26 04:18:21
Author: Mike Swanson Machine: GURU-5070 Timestamp: 2026-06-26 04:18:21
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
import os, json, urllib.request, urllib.error, time
|
|
||||||
TOKEN=os.environ["GT"]; USER="bt@tedards.net"; BASE="https://graph.microsoft.com/v1.0"
|
|
||||||
def g(url):
|
|
||||||
for _ in range(6):
|
|
||||||
req=urllib.request.Request(url, headers={"Authorization":"Bearer "+TOKEN})
|
|
||||||
try:
|
|
||||||
with urllib.request.urlopen(req,timeout=60) as r: return json.loads(r.read())
|
|
||||||
except urllib.error.HTTPError as e:
|
|
||||||
if e.code in (429,503,504,500): time.sleep(int(e.headers.get("Retry-After","8"))); continue
|
|
||||||
raise
|
|
||||||
raise RuntimeError(url)
|
|
||||||
# BFS all folders
|
|
||||||
hits=[]; names={}
|
|
||||||
def walk(url, path):
|
|
||||||
while url:
|
|
||||||
d=g(url)
|
|
||||||
for f in d["value"]:
|
|
||||||
nm=f.get("displayName","?"); fid=f["id"]; tot=f.get("totalItemCount",0); ch=f.get("childFolderCount",0)
|
|
||||||
full=path+"/"+nm
|
|
||||||
names[fid]=full
|
|
||||||
low=nm.lower()
|
|
||||||
if "9000" in low or "duplicat" in low or "06-26" in low or "06/26" in low:
|
|
||||||
hits.append((full, tot, ch, fid))
|
|
||||||
if ch>0:
|
|
||||||
walk(BASE+"/users/%s/mailFolders/%s/childFolders?$top=100&$select=id,displayName,totalItemCount,childFolderCount"%(USER,fid), full)
|
|
||||||
url=d.get("@odata.nextLink")
|
|
||||||
walk(BASE+"/users/%s/mailFolders?$top=100&$select=id,displayName,totalItemCount,childFolderCount"%USER, "")
|
|
||||||
print(json.dumps([{"path":h[0],"total":h[1],"children":h[2],"id":h[3]} for h in hits], indent=2))
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@ backups/
|
|||||||
|
|
||||||
# Session scratch (one-off dedup/EWS tooling — never commit)
|
# Session scratch (one-off dedup/EWS tooling — never commit)
|
||||||
.dup*
|
.dup*
|
||||||
|
.find*
|
||||||
.ews_*.xml
|
.ews_*.xml
|
||||||
.x.json
|
.x.json
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user