Skip to content

Commit 85c3435

Browse files
committed
add some debugging output to the generator
1 parent e0369f4 commit 85c3435

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

generate_index.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def getfile(url):
2727
return requests.get(url, headers={'Authorization': f'token {token}'})
2828

2929

30-
def getPluginJson(plugin, shortUrls):
30+
def getPluginJson(plugin, shortUrls, debug=False):
31+
if debug:
32+
print(f"Processing plugin: {plugin['name']}")
3133
if "site" in plugin:
3234
pluginsJson = getfile(plugin["site"]).json()
3335
for plugin in pluginsJson:
@@ -133,11 +135,13 @@ def getPluginJson(plugin, shortUrls):
133135
else:
134136
pluginjson = f"{projectUrl}/contents/plugin.json?ref={plugin['tag']}"
135137
try:
138+
if debug:
139+
print(f"Getting plugin.json from {pluginjson}")
136140
content = getfile(pluginjson).json()['content']
137141
try:
138142
data = json.loads(base64.b64decode(content))
139143
except:
140-
print(f"\n\nInvalid json when parsing {pluginjson}.\n")
144+
print(f"\n\nInvalid json when parsing {pluginjson}\n")
141145
raise
142146
if ('longdescription' in data and len(data['longdescription']) < 100) or ('longdescription' not in data):
143147
try:
@@ -239,6 +243,8 @@ def getPluginJson(plugin, shortUrls):
239243
# Native plugins require this version to not produce error logs.
240244
if view_only and data["minimumBinaryNinjaVersion"] < 6135:
241245
data["minimumBinaryNinjaVersion"] = 6135
246+
if debug:
247+
print(f"Finished processing plugin: {plugin['name']}")
242248
return data
243249

244250

@@ -249,6 +255,8 @@ def main():
249255
parser.add_argument("-r", "--readmeskip", action="store_true", default=False,
250256
help="Skip generating a README.md")
251257
parser.add_argument("-l", "--listing", action="store", default="listing.json")
258+
parser.add_argument("-d", "--debug", action="store_true", default=False,
259+
help="Debugging output")
252260
parser.add_argument("token")
253261
args = parser.parse_args(sys.argv[1:])
254262
global token
@@ -270,7 +278,7 @@ def main():
270278
listing = json.load(open(args.listing, "r", encoding="utf-8"))
271279
for i, plugin in enumerate(listing):
272280
printProgressBar(i, len(listing), prefix="Collecting Plugin JSON files:")
273-
jsonData = getPluginJson(plugin, shortUrls)
281+
jsonData = getPluginJson(plugin, shortUrls, debug=args.debug)
274282
if jsonData is not None:
275283
allPlugins[plugin["name"]] = jsonData
276284
printProgressBar(len(listing), len(listing), prefix="Collecting Plugin JSON files:")

0 commit comments

Comments
 (0)