added outputpath
This commit is contained in:
parent
8b35430b43
commit
93b9273a40
12
etherdump
12
etherdump
@ -89,7 +89,7 @@ def get_template_env (tpath=None):
|
|||||||
# template = env.get_template('pad.html')
|
# template = env.get_template('pad.html')
|
||||||
# print template.render(the='variables', go='here').encode("utf-8")
|
# print template.render(the='variables', go='here').encode("utf-8")
|
||||||
|
|
||||||
def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=False, templates=None):
|
def dumpPads (padserver, padids, outputpath, pub_path, group_path, sleeptime=0.01, force=False, templates=None):
|
||||||
template_env = get_template_env(templates)
|
template_env = get_template_env(templates)
|
||||||
pad_template = template_env.get_template("pad.html")
|
pad_template = template_env.get_template("pad.html")
|
||||||
numpads = len(padids)
|
numpads = len(padids)
|
||||||
@ -104,13 +104,13 @@ def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=Fal
|
|||||||
os.mkdir(os.path.join(group_path, group_id))
|
os.mkdir(os.path.join(group_path, group_id))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
fp = os.path.join(group_path, group_id, pad_name)
|
fp = os.path.join(outputpath, group_path, group_id, pad_name)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.mkdir(pub_path)
|
os.mkdir(pub_path)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
fp = os.path.join(pub_path, pad_name)
|
fp = os.path.join(outputpath, pub_path, pad_name)
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print (u"Saving to {0}".format(fp).encode("utf-8"), file=sys.stderr)
|
print (u"Saving to {0}".format(fp).encode("utf-8"), file=sys.stderr)
|
||||||
@ -147,7 +147,7 @@ def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=Fal
|
|||||||
try:
|
try:
|
||||||
text = padserver.getPadText(padid)
|
text = padserver.getPadText(padid)
|
||||||
f.write(text.encode("utf-8"))
|
f.write(text.encode("utf-8"))
|
||||||
meta['text_path'] = textpath
|
meta['text_path'] = os.path.relpath(textpath, outputpath)
|
||||||
meta['text_length'] = len(text)
|
meta['text_length'] = len(text)
|
||||||
meta['text_length_human'] = humanize_bytes(meta['text_length'])
|
meta['text_length_human'] = humanize_bytes(meta['text_length'])
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=Fal
|
|||||||
|
|
||||||
with open(htmlpath, "w") as f:
|
with open(htmlpath, "w") as f:
|
||||||
html = padserver.getPadHTML(padid)
|
html = padserver.getPadHTML(padid)
|
||||||
meta['html_path'] = htmlpath
|
meta['html_path'] = os.path.relpath(htmlpath, outputpath)
|
||||||
meta['html_length'] = len(html)
|
meta['html_length'] = len(html)
|
||||||
if pad_template:
|
if pad_template:
|
||||||
t = html5lib.parse(html, treebuilder="etree", namespaceHTMLElements=False)
|
t = html5lib.parse(html, treebuilder="etree", namespaceHTMLElements=False)
|
||||||
@ -253,6 +253,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--apiurl', help='URL path to the API')
|
parser.add_argument('--apiurl', help='URL path to the API')
|
||||||
|
|
||||||
parser.add_argument('--verbose', action="store_true", default=False, help='debug mode, verbose output')
|
parser.add_argument('--verbose', action="store_true", default=False, help='debug mode, verbose output')
|
||||||
|
parser.add_argument('--outputpath', default=os.getcwd(), help='path for output, default is .')
|
||||||
parser.add_argument('--pubpath', default="pub", help='path to dump public pads')
|
parser.add_argument('--pubpath', default="pub", help='path to dump public pads')
|
||||||
parser.add_argument('--grouppath', default="priv", help='path to dump group pads')
|
parser.add_argument('--grouppath', default="priv", help='path to dump group pads')
|
||||||
parser.add_argument('--templates', default=os.path.join(os.getcwd(), "templates"), help='(addition) templates path, default: ./templates')
|
parser.add_argument('--templates', default=os.path.join(os.getcwd(), "templates"), help='(addition) templates path, default: ./templates')
|
||||||
@ -342,6 +343,7 @@ if __name__ == "__main__":
|
|||||||
dumpPads(
|
dumpPads(
|
||||||
padserver,
|
padserver,
|
||||||
padids,
|
padids,
|
||||||
|
args.outputpath,
|
||||||
args.pubpath,
|
args.pubpath,
|
||||||
args.grouppath,
|
args.grouppath,
|
||||||
force=args.force,
|
force=args.force,
|
||||||
|
Loading…
Reference in New Issue
Block a user