updated pull to use localapiurl when present
This commit is contained in:
parent
26f3d4af24
commit
59de1fa7ca
@ -86,6 +86,8 @@ def getjson (url, max_retry=3, retry_sleep_time=3):
|
|||||||
def loadpadinfo(p):
|
def loadpadinfo(p):
|
||||||
with open(p) as f:
|
with open(p) as f:
|
||||||
info = json.load(f)
|
info = json.load(f)
|
||||||
|
if 'localapiurl' not in info:
|
||||||
|
info['localapiurl'] = info.get('apiurl')
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def progressbar (i, num, label="", file=sys.stderr):
|
def progressbar (i, num, label="", file=sys.stderr):
|
||||||
|
@ -83,10 +83,10 @@ def main (args):
|
|||||||
if args.padid:
|
if args.padid:
|
||||||
padids = args.padid
|
padids = args.padid
|
||||||
elif args.glob:
|
elif args.glob:
|
||||||
padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
|
padids = getjson(info['localapiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
|
||||||
padids = [x for x in padids if fnmatch(x, args.glob)]
|
padids = [x for x in padids if fnmatch(x, args.glob)]
|
||||||
else:
|
else:
|
||||||
padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
|
padids = getjson(info['localapiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
|
||||||
padids.sort()
|
padids.sort()
|
||||||
numpads = len(padids)
|
numpads = len(padids)
|
||||||
# maxmsglen = 0
|
# maxmsglen = 0
|
||||||
@ -114,7 +114,7 @@ def main (args):
|
|||||||
if os.path.exists(metapath):
|
if os.path.exists(metapath):
|
||||||
with open(metapath) as f:
|
with open(metapath) as f:
|
||||||
meta.update(json.load(f))
|
meta.update(json.load(f))
|
||||||
revisions = getjson(info['apiurl']+'getRevisionsCount?'+urlencode(data))['data']['revisions']
|
revisions = getjson(info['localapiurl']+'getRevisionsCount?'+urlencode(data))['data']['revisions']
|
||||||
if meta['revisions'] == revisions and not args.force:
|
if meta['revisions'] == revisions and not args.force:
|
||||||
skip=True
|
skip=True
|
||||||
break
|
break
|
||||||
@ -128,7 +128,7 @@ def main (args):
|
|||||||
})
|
})
|
||||||
|
|
||||||
if revisions == None:
|
if revisions == None:
|
||||||
meta['revisions'] = getjson(info['apiurl']+'getRevisionsCount?'+urlencode(data))['data']['revisions']
|
meta['revisions'] = getjson(info['localapiurl']+'getRevisionsCount?'+urlencode(data))['data']['revisions']
|
||||||
else:
|
else:
|
||||||
meta['revisions' ] = revisions
|
meta['revisions' ] = revisions
|
||||||
|
|
||||||
@ -140,9 +140,9 @@ def main (args):
|
|||||||
# todo: load more metadata!
|
# todo: load more metadata!
|
||||||
meta['group'], meta['pad'] = splitpadname(padid)
|
meta['group'], meta['pad'] = splitpadname(padid)
|
||||||
meta['pathbase'] = p
|
meta['pathbase'] = p
|
||||||
meta['lastedited_raw'] = int(getjson(info['apiurl']+'getLastEdited?'+urlencode(data))['data']['lastEdited'])
|
meta['lastedited_raw'] = int(getjson(info['localapiurl']+'getLastEdited?'+urlencode(data))['data']['lastEdited'])
|
||||||
meta['lastedited_iso'] = datetime.fromtimestamp(int(meta['lastedited_raw'])/1000).isoformat()
|
meta['lastedited_iso'] = datetime.fromtimestamp(int(meta['lastedited_raw'])/1000).isoformat()
|
||||||
meta['author_ids'] = getjson(info['apiurl']+'listAuthorsOfPad?'+urlencode(data))['data']['authorIDs']
|
meta['author_ids'] = getjson(info['localapiurl']+'listAuthorsOfPad?'+urlencode(data))['data']['authorIDs']
|
||||||
break
|
break
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
tries += 1
|
tries += 1
|
||||||
@ -172,7 +172,7 @@ def main (args):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if args.all or args.text:
|
if args.all or args.text:
|
||||||
text = getjson(info['apiurl']+'getText?'+urlencode(data))
|
text = getjson(info['localapiurl']+'getText?'+urlencode(data))
|
||||||
ver = {"type": "text"}
|
ver = {"type": "text"}
|
||||||
versions.append(ver)
|
versions.append(ver)
|
||||||
ver["code"] = text["_code"]
|
ver["code"] = text["_code"]
|
||||||
@ -213,7 +213,7 @@ def main (args):
|
|||||||
|
|
||||||
if args.all or args.dhtml:
|
if args.all or args.dhtml:
|
||||||
data['startRev'] = "0"
|
data['startRev'] = "0"
|
||||||
html = getjson(info['apiurl']+'createDiffHTML?'+urlencode(data))
|
html = getjson(info['localapiurl']+'createDiffHTML?'+urlencode(data))
|
||||||
ver = {"type": "diffhtml"}
|
ver = {"type": "diffhtml"}
|
||||||
versions.append(ver)
|
versions.append(ver)
|
||||||
ver["code"] = html["_code"]
|
ver["code"] = html["_code"]
|
||||||
@ -236,7 +236,7 @@ def main (args):
|
|||||||
|
|
||||||
# Process text, html, dhtml, all options
|
# Process text, html, dhtml, all options
|
||||||
if args.all or args.html:
|
if args.all or args.html:
|
||||||
html = getjson(info['apiurl']+'getHTML?'+urlencode(data))
|
html = getjson(info['localapiurl']+'getHTML?'+urlencode(data))
|
||||||
ver = {"type": "html"}
|
ver = {"type": "html"}
|
||||||
versions.append(ver)
|
versions.append(ver)
|
||||||
ver["code"] = html["_code"]
|
ver["code"] = html["_code"]
|
||||||
|
Loading…
Reference in New Issue
Block a user