Get save/skip counting back
This commit is contained in:
parent
c1a7a74fda
commit
a87af2e9be
@ -26,6 +26,9 @@ todo...
|
|||||||
use/prefer public interfaces ? (export functions)
|
use/prefer public interfaces ? (export functions)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Note(decentral1se): simple globals counting
|
||||||
|
skipped, saved = 0, 0
|
||||||
|
|
||||||
|
|
||||||
async def try_deleting(files):
|
async def try_deleting(files):
|
||||||
for f in files:
|
for f in files:
|
||||||
@ -188,6 +191,8 @@ async def get_padids(args, info, data, session):
|
|||||||
|
|
||||||
|
|
||||||
async def handle_pad(args, padid, data, info, session):
|
async def handle_pad(args, padid, data, info, session):
|
||||||
|
global skipped, saved
|
||||||
|
|
||||||
raw_ext = ".raw.txt"
|
raw_ext = ".raw.txt"
|
||||||
if args.no_raw_ext:
|
if args.no_raw_ext:
|
||||||
raw_ext = ""
|
raw_ext = ""
|
||||||
@ -288,6 +293,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
|
|
||||||
if skip:
|
if skip:
|
||||||
print("[ ] {} (skipped, reason: {})".format(padid, reason))
|
print("[ ] {} (skipped, reason: {})".format(padid, reason))
|
||||||
|
skipped += 1
|
||||||
return
|
return
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
@ -329,7 +335,8 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
padid
|
padid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
skipped += 1
|
||||||
|
return False
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
## ENFORCE __PUBLISH__ MAGIC WORD
|
## ENFORCE __PUBLISH__ MAGIC WORD
|
||||||
@ -344,7 +351,8 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
print("[ ] {} (deleted, reason: publish opt-out)".format(padid))
|
print("[ ] {} (deleted, reason: publish opt-out)".format(padid))
|
||||||
return
|
skipped += 1
|
||||||
|
return False
|
||||||
|
|
||||||
ver["path"] = p + raw_ext
|
ver["path"] = p + raw_ext
|
||||||
ver["url"] = quote(ver["path"])
|
ver["url"] = quote(ver["path"])
|
||||||
@ -468,9 +476,13 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
await f.write(json.dumps(meta))
|
await f.write(json.dumps(meta))
|
||||||
|
|
||||||
print("[x] {} (saved)".format(padid))
|
print("[x] {} (saved)".format(padid))
|
||||||
|
saved += 1
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
async def handle_pads(args):
|
async def handle_pads(args):
|
||||||
|
global skipped, saved
|
||||||
|
|
||||||
session = asks.Session(connections=args.connection)
|
session = asks.Session(connections=args.connection)
|
||||||
info = loadpadinfo(args.padinfo)
|
info = loadpadinfo(args.padinfo)
|
||||||
data = {"apikey": info["apikey"]}
|
data = {"apikey": info["apikey"]}
|
||||||
@ -488,11 +500,12 @@ async def handle_pads(args):
|
|||||||
for padid in padids:
|
for padid in padids:
|
||||||
nursery.start_soon(handle_pad, args, padid, data, info, session)
|
nursery.start_soon(handle_pad, args, padid, data, info, session)
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
timeit = round(end - start, 2)
|
||||||
|
|
||||||
print("=" * 79)
|
print("=" * 79)
|
||||||
print(
|
print(
|
||||||
"Processed {} pads in {} seconds".format(
|
"Processed {} :: Skipped {} :: Saved {} :: Time {}s".format(
|
||||||
len(padids), round(end - start, 2)
|
len(padids), skipped, saved, timeit
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print("=" * 79)
|
print("=" * 79)
|
||||||
|
Loading…
Reference in New Issue
Block a user