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):
|
||||
with open(p) as f:
|
||||
info = json.load(f)
|
||||
if 'localapiurl' not in info:
|
||||
info['localapiurl'] = info.get('apiurl')
|
||||
return info
|
||||
|
||||
def progressbar (i, num, label="", file=sys.stderr):
|
||||
|
@ -83,10 +83,10 @@ def main (args):
|
||||
if args.padid:
|
||||
padids = args.padid
|
||||
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)]
|
||||
else:
|
||||
padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
|
||||
padids = getjson(info['localapiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
|
||||
padids.sort()
|
||||
numpads = len(padids)
|
||||
# maxmsglen = 0
|
||||
@ -114,7 +114,7 @@ def main (args):
|
||||
if os.path.exists(metapath):
|
||||
with open(metapath) as 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:
|
||||
skip=True
|
||||
break
|
||||
@ -128,7 +128,7 @@ def main (args):
|
||||
})
|
||||
|
||||
if revisions == None:
|
||||
meta['revisions'] = getjson(info['apiurl']+'getRevisionsCount?'+urlencode(data))['data']['revisions']
|
||||
meta['revisions'] = getjson(info['localapiurl']+'getRevisionsCount?'+urlencode(data))['data']['revisions']
|
||||
else:
|
||||
meta['revisions' ] = revisions
|
||||
|
||||
@ -140,9 +140,9 @@ def main (args):
|
||||
# todo: load more metadata!
|
||||
meta['group'], meta['pad'] = splitpadname(padid)
|
||||
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['author_ids'] = getjson(info['apiurl']+'listAuthorsOfPad?'+urlencode(data))['data']['authorIDs']
|
||||
meta['author_ids'] = getjson(info['localapiurl']+'listAuthorsOfPad?'+urlencode(data))['data']['authorIDs']
|
||||
break
|
||||
except HTTPError as e:
|
||||
tries += 1
|
||||
@ -172,7 +172,7 @@ def main (args):
|
||||
pass
|
||||
|
||||
if args.all or args.text:
|
||||
text = getjson(info['apiurl']+'getText?'+urlencode(data))
|
||||
text = getjson(info['localapiurl']+'getText?'+urlencode(data))
|
||||
ver = {"type": "text"}
|
||||
versions.append(ver)
|
||||
ver["code"] = text["_code"]
|
||||
@ -213,7 +213,7 @@ def main (args):
|
||||
|
||||
if args.all or args.dhtml:
|
||||
data['startRev'] = "0"
|
||||
html = getjson(info['apiurl']+'createDiffHTML?'+urlencode(data))
|
||||
html = getjson(info['localapiurl']+'createDiffHTML?'+urlencode(data))
|
||||
ver = {"type": "diffhtml"}
|
||||
versions.append(ver)
|
||||
ver["code"] = html["_code"]
|
||||
@ -236,7 +236,7 @@ def main (args):
|
||||
|
||||
# Process text, html, dhtml, all options
|
||||
if args.all or args.html:
|
||||
html = getjson(info['apiurl']+'getHTML?'+urlencode(data))
|
||||
html = getjson(info['localapiurl']+'getHTML?'+urlencode(data))
|
||||
ver = {"type": "html"}
|
||||
versions.append(ver)
|
||||
ver["code"] = html["_code"]
|
||||
|
Loading…
Reference in New Issue
Block a user