fgaddon utilities
aircraft_updates.py - list updated aircraft in fgaddon between two date points. Useful for release notes. find_md5file.py - identify identical files based on md5sum. Useful for finding license infringement.
This commit is contained in:
parent
b86121be85
commit
0472d9483c
2 changed files with 95 additions and 0 deletions
70
fgaddon/aircraft_updates.py
Normal file
70
fgaddon/aircraft_updates.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Script to summarize changes to fgaddon Aircraft based on svn activity.
|
||||||
|
#
|
||||||
|
# Primarily intended to provide a list of aircraft that have been significantly
|
||||||
|
# updated since the last release for the change log.
|
||||||
|
|
||||||
|
import os, sys
|
||||||
|
import os.path
|
||||||
|
import re
|
||||||
|
from collections import defaultdict
|
||||||
|
import subprocess
|
||||||
|
import math
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
extensions = ["*", "ac", "xml", "png", "jpg"]
|
||||||
|
|
||||||
|
if (len(sys.argv) != 4):
|
||||||
|
print("Summarize fgaddon/Aircraft changes in a given branch between two dates.")
|
||||||
|
print("")
|
||||||
|
print("Usage: " + sys.argv[0] + " <branch> <from> <to>")
|
||||||
|
print(" <branch>\tSVN branch to check (e.g trunk, branches/release-2020.3")
|
||||||
|
print(" <from> \tStart date (e.g. 2020-04-27)")
|
||||||
|
print(" <to> \tEnd date (e.g. 2020-10-11")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
branch = sys.argv[1]
|
||||||
|
from_date = sys.argv[2]
|
||||||
|
to_date = sys.argv[3]
|
||||||
|
|
||||||
|
# Create a format string listing changes to all the file types above
|
||||||
|
tableformat = "{:<25}{:>4}"
|
||||||
|
for ext in extensions:
|
||||||
|
tableformat = tableformat + "{:>5}"
|
||||||
|
|
||||||
|
# Check an individual aircraft for changes since date and output them
|
||||||
|
def check_aircraft(aircraft):
|
||||||
|
# This command lists all the changed files since date for a given aircraft
|
||||||
|
svn_log = "svn log https://svn.code.sf.net/p/flightgear/fgaddon/" + branch + "/Aircraft/" + aircraft + " -r {" + from_date + "}:{" + to_date + "} -v -q"
|
||||||
|
process = subprocess.Popen(shlex.split(svn_log), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
|
stdout, stderr = process.communicate()
|
||||||
|
|
||||||
|
# Now collect some data
|
||||||
|
count = []
|
||||||
|
for ext in extensions:
|
||||||
|
regexp = " [AM] .*\." + ext + "$"
|
||||||
|
count.append(len(re.findall(regexp, stdout, flags=re.MULTILINE)))
|
||||||
|
|
||||||
|
# Find completely new aircraft.
|
||||||
|
regexp = " A /.*/Aircraft/" + aircraft + "$"
|
||||||
|
new_aircraft = ""
|
||||||
|
if (re.findall(regexp, stdout, flags=re.MULTILINE)):
|
||||||
|
new_aircraft = "NEW"
|
||||||
|
|
||||||
|
# Only output if we have more than 100 changes or it's a new aircraft
|
||||||
|
if ((count[0] > 100) or (new_aircraft == "NEW")):
|
||||||
|
print(tableformat.format(aircraft, new_aircraft, count[0], count[1], count[2], count[3], count[4]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
svn_list = "svn list https://svn.code.sf.net/p/flightgear/fgaddon/" + branch + "/Aircraft/"
|
||||||
|
process = subprocess.Popen(shlex.split(svn_list), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
|
stdout, stderr = process.communicate()
|
||||||
|
|
||||||
|
print(tableformat.format("Aircraft", "New?", extensions[0], extensions[1], extensions[2], extensions[3], extensions[4]))
|
||||||
|
|
||||||
|
aircraft_list = re.split("/\n", stdout)
|
||||||
|
for ac in aircraft_list:
|
||||||
|
check_aircraft(ac)
|
25
fgaddon/find_md5file.py
Normal file
25
fgaddon/find_md5file.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os, sys, re, fnmatch
|
||||||
|
import hashlib, glob
|
||||||
|
|
||||||
|
|
||||||
|
def md5(fname):
|
||||||
|
hash_md5 = hashlib.md5()
|
||||||
|
with open(fname, "rb") as f:
|
||||||
|
for chunk in iter(lambda: f.read(4096), b""):
|
||||||
|
hash_md5.update(chunk)
|
||||||
|
return hash_md5.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
filepath = sys.argv[1]
|
||||||
|
searchpath = sys.argv[2]
|
||||||
|
|
||||||
|
digest = md5(filepath)
|
||||||
|
print("Checking for " + digest)
|
||||||
|
|
||||||
|
wavfiles = glob.glob(searchpath + "/**/*.wav", recursive=True)
|
||||||
|
|
||||||
|
for f in wavfiles:
|
||||||
|
if (md5(f) == digest):
|
||||||
|
print(f)
|
Loading…
Add table
Reference in a new issue