Browse Source

Add more reasoning

main
Luke Murphy 4 years ago
parent
commit
cdd255c5bb
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 18
      etherpump/commands/pull.py

18
etherpump/commands/pull.py

@ -215,6 +215,7 @@ async def handle_pad(args, padid, data, info, session):
revisions = response["data"]["revisions"] revisions = response["data"]["revisions"]
if meta["revisions"] == revisions and not args.force: if meta["revisions"] == revisions and not args.force:
skip = True skip = True
reason = "No new revisions, we already have the latest local copy"
break break
meta["padid"] = padid meta["padid"] = padid
@ -234,6 +235,7 @@ async def handle_pad(args, padid, data, info, session):
if (meta["revisions"] == 0) and (not args.zerorevs): if (meta["revisions"] == 0) and (not args.zerorevs):
skip = True skip = True
reason = "0 revisions, this pad was never edited"
break break
# todo: load more metadata! # todo: load more metadata!
@ -261,6 +263,7 @@ async def handle_pad(args, padid, data, info, session):
file=sys.stderr, file=sys.stderr,
) )
skip = True skip = True
reason = "PANIC, couldn't download the pad contents"
break break
else: else:
await trio.sleep(1) await trio.sleep(1)
@ -272,10 +275,11 @@ async def handle_pad(args, padid, data, info, session):
file=sys.stderr, file=sys.stderr,
) )
skip = True skip = True
reason = "PANIC, couldn't download the pad contents"
break break
if skip: if skip:
print("[ ] {} (skipped)".format(padid)) print("[ ] {} (skipped, reason: {})".format(padid, reason))
return return
if args.output: if args.output:
@ -286,7 +290,7 @@ async def handle_pad(args, padid, data, info, session):
path = trio.Path(os.path.split(metapath)[0]) path = trio.Path(os.path.split(metapath)[0])
await path.mkdir() await path.mkdir()
except OSError: except OSError:
pass print("PANIC: unable to create {}".format(str(path)))
if args.all or args.text: if args.all or args.text:
url = info["localapiurl"] + "getText?" + urlencode(data) url = info["localapiurl"] + "getText?" + urlencode(data)
@ -310,7 +314,11 @@ async def handle_pad(args, padid, data, info, session):
p + ".meta.json", p + ".meta.json",
) )
) )
print("[ ] {} (no publish)".format(padid)) print(
"[ ] {} (deleted, reason: explicit __NOPUBLISH__)".format(
padid
)
)
return return
########################################## ##########################################
@ -325,7 +333,7 @@ async def handle_pad(args, padid, data, info, session):
p + ".meta.json", p + ".meta.json",
) )
) )
print("[ ] {} (publish opt out)".format(padid)) print("[ ] {} (deleted, reason: publish opt-out)".format(padid))
return return
ver["path"] = p + raw_ext ver["path"] = p + raw_ext
@ -443,7 +451,7 @@ async def handle_pad(args, padid, data, info, session):
async with await trio.open_file(metapath, "w") as f: async with await trio.open_file(metapath, "w") as f:
await f.write(json.dumps(meta)) await f.write(json.dumps(meta))
print("[x] {}".format(padid)) print("[x] {} (saved)".format(padid))
async def handle_pads(args): async def handle_pads(args):

Loading…
Cancel
Save