mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-22 07:11:55 +00:00
Outdated scripts moved from loser repo
This commit is contained in:
parent
541236391e
commit
160009d5ba
109
scripts/old_or_unused/check-refs.awk
Normal file
109
scripts/old_or_unused/check-refs.awk
Normal file
@ -0,0 +1,109 @@
|
||||
#!/bin/awk
|
||||
# Checks that *ref in .svx files link to valid surveyscans folders
|
||||
# Assumes that svx-refs has been generated.
|
||||
# usage:
|
||||
# cd /loser/
|
||||
# ./check-refs.sh
|
||||
#
|
||||
# 2020-04-05 Philip Sargent
|
||||
#
|
||||
# Does not check whether move than one svx file points at the same wallet (might be real)
|
||||
# Does not check whether more than one wallet json points to the same svx file (an error)
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s } # remove leading whitespace
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s } # remove trailing whitespace
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
BEGIN {
|
||||
walltag = "[1-2][0-9][0-9][0-9]#X?[0-9][0-9]"
|
||||
ss ="/home/expo/expofiles/surveyscans/"
|
||||
ssurl ="expofiles/surveyscans/"
|
||||
svxurl ="survexfile/"
|
||||
}
|
||||
$2 ~ walltag {
|
||||
svxfile = $1
|
||||
urlsvxfile = svxurl svxfile
|
||||
year = substr($2,0,4)
|
||||
wallet = $2
|
||||
walldir = year "/" wallet
|
||||
path = ss year "/" wallet
|
||||
json = path "/contents.json"
|
||||
urljson = ssurl year "/" year "%23" substr(wallet,6,length(wallet)) "/contents.json"
|
||||
#printf("%s :: ", wallet)
|
||||
included =""
|
||||
if ($NF ~ "INCLUDE") {
|
||||
included = "(*includes " $(NF-1) " )"
|
||||
}
|
||||
|
||||
if (system("test -d " path)!=0) {
|
||||
printf("Missing WALLET %s <a href=\"%s\">%s</a>\n", walldir, urlsvxfile, svxfile) > "svx-refs.tmp"
|
||||
print "mkdir ", path > "svx-refs.tmp"
|
||||
} else if (system("test -f " json)!=0) {
|
||||
print "Missing JSON ", walldir, $1 > "svx-refs.tmp"
|
||||
print "cp -p " ss "template.json ", json > "svx-refs.tmp"
|
||||
} else if (system("test -s " json)!=0) {
|
||||
print "Zerolength JSON ", walldir, $1 > "svx-refs.tmp"
|
||||
# copy an empty template into it
|
||||
print "cp -p " ss "template.json ", json > "svx-refs.tmp"
|
||||
} else if (system("grep \"survex file\" " json ">> grep.txt")!=0 ) {
|
||||
print "CORRUPT json - missing survex file line",walldir, $1 > "svx-refs.tmp"
|
||||
} else {
|
||||
# Now scan the content.json file and look for the reference to the svx file
|
||||
i=0
|
||||
jline[0]=""
|
||||
for (k in jline ) delete jline[k]
|
||||
while (getline line <json > 0) {
|
||||
n=gsub(/\"/,"",line) # " syntax colouring bad in VS code for awk
|
||||
i += 1
|
||||
jline[i]=line
|
||||
result="working"
|
||||
if (line ~ /survex file/) {
|
||||
result="survexline"
|
||||
n = split(line,arr,":")
|
||||
jsonsvx = trim(arr[n])
|
||||
n=gsub(/,$/,"",jsonsvx) # if it is the last field then no comma
|
||||
urljsonsvx = svxurl jsonsvx
|
||||
#printf("[%s] {%s} ",jsonsvx, urljsonsvx)
|
||||
if (jsonsvx == "") {
|
||||
print "UNSET json ", walldir, $1 > "svx-refs.tmp"
|
||||
printf("sed -i '/survex file/ s;\"\";\"%s\";' %s\n",svxfile, json) > "svx-refs.tmp"
|
||||
printf("%s :: ", wallet)
|
||||
printf("UNSET - json field blank\nsvx :%s:\n",svxfile)
|
||||
result="unset"
|
||||
#break # behaves like next not break
|
||||
} else if (jsonsvx == svxfile ) {
|
||||
printf("<a href=\"%s\">%s</a> :: ", urljson,wallet) > "ok.tmp"
|
||||
printf("OK - svx filenames match - <a href='%s'>%s</a>\n",urljsonsvx,jsonsvx) > "ok.tmp"
|
||||
result="ok"
|
||||
#break # behaves like next not break
|
||||
} else {
|
||||
printf("%s :: ", wallet)
|
||||
printf("MISMATCH <a href='%s'>%s</a> <-svx <a href=\"%s\">%s</a> %s\nMISMATCH <a href=\"%s\">%s</a> json-> <a href='%s'>%s</a>\n",urljson,wallet,urlsvxfile,svxfile,included,urljson,wallet,urljsonsvx,jsonsvx) > "svx-refs.tmp"
|
||||
result="mismatch"
|
||||
#break # behaves like next not break
|
||||
}
|
||||
if (result =="survexline") {
|
||||
printf("%s + FAILTOSET ", wallet)
|
||||
} else {
|
||||
# printf("%s + SET =%s= ", wallet, result)
|
||||
}
|
||||
} else {
|
||||
# This wasn't the right line, read the next one..
|
||||
}
|
||||
} # end of look going through a json file, result should be ok, mismatch or unset
|
||||
if (result=="working") {
|
||||
# as expected if there are lines after the survex line in the json file
|
||||
} else if (result=="survexline") {
|
||||
# the last line in the json was the survex line but failed to set to ok, mismatch or unset
|
||||
printf("%s :: FAILTOSET %s\n", wallet, jsonsvx)
|
||||
#system("cat " json)
|
||||
#for (i in jline ) printf("%s %s\n",i,jline[i])
|
||||
} else {
|
||||
printf("%s :: BIZARRE\n", wallet)
|
||||
#printf("%s :: BIZZARE should not get here\n", wallet) > "svx-refs.tmp"
|
||||
#system("cat " json)
|
||||
#for (i in jline ) printf("%s %s\n",i,jline[i])
|
||||
}
|
||||
} # end of test for missing or empty path or json file
|
||||
} # end of test for matching a wallet tag
|
||||
END {
|
||||
|
||||
}
|
27
scripts/old_or_unused/check-refs.sh
Normal file
27
scripts/old_or_unused/check-refs.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Checks that *ref in .svx files link to valid surveyscans folders
|
||||
# Assumes that svx-refs has been generated.
|
||||
# usage:
|
||||
# cd /loser/
|
||||
# ./check-refs.sh
|
||||
#
|
||||
# 2020-04-06 Philip Sargent
|
||||
#
|
||||
# To make this run in a cron job on the server, we need to do:
|
||||
# 1. make the paths correct for the server in chk-refs.sh
|
||||
#
|
||||
# 2020-04-13
|
||||
#
|
||||
awk -f check-refs.awk svx-refs
|
||||
sort < ok.tmp > svx-refs.ok
|
||||
rm ok.tmp
|
||||
sort < svx-refs.tmp > svx-refs.err
|
||||
rm svx-refs.tmp
|
||||
echo "<html><head><meta name="keywords" content="NOEDIT"></head><body><pre>" >../expoweb/svx-refs.err.html
|
||||
cat svx-refs.err >>../expoweb/svx-refs.err.html
|
||||
echo "</pre><div id="menu"><ul id="links"> </ul></div></body></html>" >>../expoweb/svx-refs.err.html
|
||||
echo "<html><head><meta name="keywords" content="NOEDIT"></head><body><pre>" >../expoweb/svx-refs.ok.html
|
||||
cat svx-refs.ok >>../expoweb/svx-refs.ok.html
|
||||
echo "</pre><div id="menu"><ul id="links"> </ul></div></body></html>" >>../expoweb/svx-refs.ok.html
|
||||
|
||||
if test -s svx-refs.err ; then true ; else rm svx-refs.err ; fi
|
66
scripts/old_or_unused/check-svx.sh
Normal file
66
scripts/old_or_unused/check-svx.sh
Normal file
@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
echo preparing table of svx *ref links to wallets
|
||||
# Checks that *ref in .svx files link to valid surveyscans folders
|
||||
# Just prepares the data as a table, does no error checking itself.
|
||||
# The validation checking is done by check-refs.sh & check-refs.awk
|
||||
# 2020-04-05 Philip Sargent
|
||||
#
|
||||
# usage:
|
||||
# cd /loser/
|
||||
# ./check-svx.sh
|
||||
#
|
||||
# To make this run in a cron job on the server, we need to do:
|
||||
# 1. make the paths correct for the server in chk-refs.sh
|
||||
# 2020-04-13
|
||||
#
|
||||
# Many formats used in svx files for *ref statements:
|
||||
# ; ref.:
|
||||
# ;ref.:
|
||||
# ; Ref.:
|
||||
# ; Ref.
|
||||
# ; Referenz.:
|
||||
# ;Referenz.:
|
||||
# ; ref:
|
||||
# ; ref
|
||||
# *Ref
|
||||
# *ref
|
||||
# *ref
|
||||
# *include galatica ; ref
|
||||
# *ref 2040#31 ; (additonal comment....)
|
||||
#
|
||||
find . -name "*.svx" -type f -print0 | xargs -0 -n 1 awk '
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s } # remove leading whitespace
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s } # remove trailing whitespace
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
BEGIN {
|
||||
reftag = "^([ ]*[;]|[*])[ ]?[Rr]ef(erenz)?[.]?[ ]?[:]?"
|
||||
spctag = "[1-2][0-9][0-9][0-9] #X?[0-9][0-9]"
|
||||
walltag = "[1-2][0-9][0-9][0-9]#X?[0-9][0-9]"
|
||||
inctag = "\\*include .*;[ ]*ref"
|
||||
}
|
||||
$0 ~ reftag {
|
||||
gsub(reftag,"") # remove the *ref tag
|
||||
$0=trim($0)
|
||||
wallet=match($0,spctag) # matches 2014 #03
|
||||
if (wallet != 0) {
|
||||
$0=substr($0,0,wallet+3) substr($0,wallet+5,length($0)) # makes 2014#03
|
||||
}
|
||||
wallet=match($0,walltag) # matches 2014#X03
|
||||
if (wallet != 0) { # insert a space after the wallet code
|
||||
$0=substr($0,0,wallet+RLENGTH-1) " " substr($0,wallet+RLENGTH,length($0))
|
||||
}
|
||||
|
||||
svxfile=ARGV[1]
|
||||
print substr(svxfile,3,length(svxfile)), $0 # chop off the "./"
|
||||
}
|
||||
$0 ~ inctag { #Also references from *include statements:
|
||||
$0=trim($0)
|
||||
svxfile=ARGV[1]
|
||||
svxfile = substr(svxfile,3,length(svxfile)) # chop off the "./"
|
||||
wallet = $5
|
||||
refsvxfile = $2
|
||||
printf("%s %s %s INCLUDE\n",svxfile, wallet, refsvxfile)
|
||||
}
|
||||
END {
|
||||
}
|
||||
' > svx-refs
|
Loading…
Reference in New Issue
Block a user