FS-4768 rest of garmts changes mostly cosmetic

This commit is contained in:
Jeff Lenk 2013-01-04 14:10:51 -06:00
parent dd25e7ea36
commit 40cbc5c0e5
1 changed files with 126 additions and 117 deletions

View File

@ -47,7 +47,7 @@ If objArgs.Count >=3 Then
WgetUnCompress objArgs(1), Showpath(objArgs(2))
Case "GetUnzipSounds"
WgetSounds objArgs(1), objArgs(2), Showpath(objArgs(3)), objArgs(4)
Case "Version"
Case "Version"
'CreateVersion(tmpFolder, VersionDir, includebase, includedest)
CreateVersion Showpath(objArgs(1)), Showpath(objArgs(2)), objArgs(3), objArgs(4)
End Select
@ -59,28 +59,28 @@ End If
' *******************
Sub WgetSounds(PrimaryName, Freq, DestFolder, VersionFile)
BaseURL = "http://files.freeswitch.org/freeswitch-sounds"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(VersionFile,1)
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.Readline
if Len(strLine) > 2 then
versionPos = InstrRev(strLine, " ", -1, 1)
name = Left(strLine, versionPos-1)
if name = PrimaryName Then
version = Right(strLine, Len(strLine) - versionPos)
Wscript.Echo "Sound name: " & name & " Version " & version
URL = BaseURL & "-" & name & "-" & Freq &"-" & version & ".tar.gz"
Wscript.Echo "URL: " & URL
WgetUnCompress URL, Showpath(DestFolder)
End If
End if
Loop
BaseURL = "http://files.freeswitch.org/freeswitch-sounds"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(VersionFile,1)
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.Readline
if Len(strLine) > 2 then
versionPos = InstrRev(strLine, " ", -1, 1)
name = Left(strLine, versionPos-1)
if name = PrimaryName Then
version = Right(strLine, Len(strLine) - versionPos)
Wscript.Echo "Sound name: " & name & " Version " & version
URL = BaseURL & "-" & name & "-" & Freq &"-" & version & ".tar.gz"
Wscript.Echo "URL: " & URL
WgetUnCompress URL, Showpath(DestFolder)
End If
End if
Loop
End Sub
Sub WgetUnCompress(URL, DestFolder)
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
StartPos = InstrRev(URL, "/", -1, 1)
StartPos = InstrRev(URL, "/", -1, 1)
strlength = Len(URL)
filename=Right(URL,strlength-StartPos)
NameEnd = InstrRev(filename, ".",-1, 1)
@ -91,7 +91,7 @@ Sub WgetUnCompress(URL, DestFolder)
If fileext = "zip" Then
UnCompress Destfolder & filename, DestFolder & filebase
Else
UnCompress Destfolder & filename, DestFolder
UnCompress Destfolder & filename, DestFolder
End If
End Sub
@ -121,21 +121,21 @@ End Sub
Sub GetWgetEXE(DestFolder)
Dim oExec
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
If Not FSO.FileExists(DestFolder & "wget.exe") Then
If Not FSO.FileExists(DestFolder & "wget.exe") Then
Slow_Wget ToolsBase & "wget.exe", DestFolder
End If
End If
End Sub
Function Strip(Str)
Set oRE = New Regexp
oRE.Pattern = "[\W_]"
oRE.Global = True
Strip=oRE.Replace(Str, "")
End Function
Function Strip(Str)
Set oRE = New Regexp
oRE.Pattern = "[\W_]"
oRE.Global = True
Strip=oRE.Replace(Str, "")
End Function
Sub UnCompress(Archive, DestFolder)
batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat"
wscript.echo("Extracting: " & Archive & " - using: " & batname)
batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat"
wscript.echo("Extracting: " & Archive & " - using: " & batname)
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Archive & quote & " -y -o" & quote & DestFolder & quote )
MyFile.Close
@ -143,77 +143,87 @@ Sub UnCompress(Archive, DestFolder)
Do
WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream
If FSO.FileExists(Left(Archive, Len(Archive)-3))Then
wscript.echo("Ready extracting: " & Archive)
Fn = Left(Archive, Len(Archive)-3)
If FSO.FileExists(Fn) Then
WScript.Sleep(100)
FSO.DeleteFile UtilsDir & batname, True
wscript.echo("Processing: " & Fn & " - deleting " & batname)
FSO.DeleteFile UtilsDir & batname, True
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Left(Archive, Len(Archive)-3) & quote & " -y -o" & quote & DestFolder & quote )
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )
MyFile.Close
Set oExec = WshShell.Exec(UtilsDir & batname)
Do
WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream
wscript.echo("Ready extracting: " & Fn)
WScript.Sleep(500)
FSO.DeleteFile Left(Archive, Len(Archive)-3) ,true
wscript.echo("Deleting: " & Fn)
FSO.DeleteFile Fn,true
End If
If FSO.FileExists(Left(Archive, Len(Archive)-3) & "tar")Then
Fn= Fn & tar
If FSO.FileExists(Fn) Then
WScript.Sleep(100)
FSO.DeleteFile UtilsDir & batname, True
wscript.echo("Processing: " & Fn & " - deleting " & batname)
FSO.DeleteFile UtilsDir & batname, True
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Left(Archive, Len(Archive)-3) & "tar" & quote & " -y -o" & quote & DestFolder & quote )
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )
MyFile.Close
Set oExec = WshShell.Exec(UtilsDir & batname)
Do
WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream
wscript.echo("Ready extracting: " & Fn )
WScript.Sleep(500)
FSO.DeleteFile Left(Archive, Len(Archive)-3) & "tar",true
wscript.echo("Deleting: " & Fn)
FSO.DeleteFile Fn,true
End If
WScript.Sleep(500)
If FSO.FileExists(UtilsDir & batname)Then
If FSO.FileExists(UtilsDir & batname)Then
FSO.DeleteFile UtilsDir & batname, True
End If
End Sub
Sub Wget(URL, DestFolder)
StartPos = InstrRev(URL, "/", -1, 1)
StartPos = InstrRev(URL, "/", -1, 1)
strlength = Len(URL)
filename=Right(URL,strlength-StartPos)
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
Wscript.echo("Downloading: " & URL)
If UseWgetEXE Then
batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@cd " & quote & DestFolder & quote)
MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)
MyFile.Close
Set oExec = WshShell.Exec(UtilsDir & batname)
Do
WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream
If UseWgetEXE Then
Wscript.echo("Downloading (wget): " & URL)
batname = "tmp" & CStr(Int(100000*Rnd)) & ".bat"
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@cd " & quote & DestFolder & quote)
MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)
MyFile.Close
Set oExec = WshShell.Exec(UtilsDir & batname)
Do
WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream
Else
xml.Open "GET", URL, False
xml.Send
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
Else
Wscript.echo("Downloading (HTTP GET): " & URL)
oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody
oStream.savetofile DestFolder & filename, adSaveCreateOverWrite
oStream.close
End If
xml.Open "GET", URL, False
xml.Send
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody
oStream.savetofile DestFolder & filename, adSaveCreateOverWrite
oStream.close
End If
End Sub
Sub Slow_Wget(URL, DestFolder)
StartPos = InstrRev(URL, "/", -1, 1)
StartPos = InstrRev(URL, "/", -1, 1)
strlength = Len(URL)
filename=Right(URL,strlength-StartPos)
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
@ -221,13 +231,13 @@ Sub Slow_Wget(URL, DestFolder)
Wscript.echo("Downloading: " & URL)
xml.Open "GET", URL, False
xml.Send
const ForReading = 1 , ForWriting = 2 , ForAppending = 8
Set MyFile = fso.OpenTextFile(DestFolder & filename ,ForWriting, True)
For i = 1 to lenb(xml.responseBody)
MyFile.write Chr(Ascb(midb(xml.responseBody,i,1)))
Next
MyFile.Close()
const ForReading = 1 , ForWriting = 2 , ForAppending = 8
Set MyFile = fso.OpenTextFile(DestFolder & filename ,ForWriting, True)
For i = 1 to lenb(xml.responseBody)
MyFile.write Chr(Ascb(midb(xml.responseBody,i,1)))
Next
MyFile.Close()
End Sub
@ -239,36 +249,36 @@ End Function
Function FindVersionStringInConfigure(strConfigFile, strVersionString)
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "[^#]AC_SUBST\(" & strVersionString & ".*\[([^\[]*)\]"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strConfigFile, 1)
strSearchString = objFile.ReadAll
objFile.Close
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "[^#]AC_SUBST\(" & strVersionString & ".*\[([^\[]*)\]"
Set colMatches = objRegEx.Execute(strSearchString)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strConfigFile, 1)
strSearchString = objFile.ReadAll
objFile.Close
strResult = ""
If colMatches.Count > 0 Then
For Each strMatch in colMatches
strResult = objRegEx.Replace(strMatch.Value, "$1")
Next
End If
Set colMatches = objRegEx.Execute(strSearchString)
strResult = ""
If colMatches.Count > 0 Then
For Each strMatch in colMatches
strResult = objRegEx.Replace(strMatch.Value, "$1")
Next
End If
FindVersionStringInConfigure = strResult
End Function
Sub FindReplaceInFile(FileName, sFind, sReplace)
Const OpenAsASCII = 0 ' Opens the file as ASCII (TristateFalse)
Const OpenAsUnicode = -1 ' Opens the file as Unicode (TristateTrue)
Const OpenAsDefault = -2 ' Opens the file using the system default
Const OverwriteIfExist = -1
Const FailIfNotExist = 0
Const ForReading = 1
Const OpenAsASCII = 0 ' Opens the file as ASCII (TristateFalse)
Const OpenAsUnicode = -1 ' Opens the file as Unicode (TristateTrue)
Const OpenAsDefault = -2 ' Opens the file using the system default
Const OverwriteIfExist = -1
Const FailIfNotExist = 0
Const ForReading = 1
Set fOrgFile = FSO.OpenTextFile(FileName, ForReading, FailIfNotExist, OpenAsASCII)
sText = fOrgFile.ReadAll
fOrgFile.Close
@ -279,33 +289,32 @@ Sub FindReplaceInFile(FileName, sFind, sReplace)
End Sub
Function ExecAndGetResult(tmpFolder, VersionDir, execStr)
Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpExec.Bat", True)
MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote)
MyFile.WriteLine("@" & execStr)
MyFile.Close
Set oExec = WshShell.Exec("cmd /C " & quote & tmpFolder & "tmpExec.Bat" & quote)
ExecAndGetResult = Trim(OExec.StdOut.ReadLine())
Do
Loop While Not OExec.StdOut.atEndOfStream
FSO.DeleteFile(tmpFolder & "tmpExec.Bat")
End Function
Function ExecAndGetExitCode(tmpFolder, VersionDir, execStr)
Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpExec.Bat", True)
MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote)
MyFile.WriteLine("@" & execStr)
MyFile.WriteLine("@exit %ERRORLEVEL%")
MyFile.Close
ExecAndGetExitCode = WshShell.Run("cmd /C " & quote & tmpFolder & "tmpExec.Bat" & quote, 0, True)
FSO.DeleteFile(tmpFolder & "tmpExec.Bat")
End Function
@ -320,28 +329,28 @@ End Function
Function GetTimeUTC()
iOffset = WshShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
If IsNumeric(iOffset) Then
GetTimeUTC = DateAdd("n", iOffset, Now())
Else
GetTimeUTC = Now()
End If
iOffset = WshShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
If IsNumeric(iOffset) Then
GetTimeUTC = DateAdd("n", iOffset, Now())
Else
GetTimeUTC = Now()
End If
End Function
Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
Dim oExec
strVerMajor = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MAJOR")
strVerMinor = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MINOR")
strVerMicro = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MICRO")
strVerRev = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_REVISION")
strVerHuman = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_REVISION_HUMAN")
'Set version to the one reported by configure.in
If strVerRev <> "" Then
VERSION = strVerRev
VERSION = strVerRev
End If
Dim sLastFile
@ -392,12 +401,12 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
End If
sLastFile.Close
End If
If VERSION & " " & strVerHuman <> sLastVersion Then
Set MyFile = fso.CreateTextFile(tmpFolder & "lastversion", True)
MyFile.WriteLine(VERSION & " " & strVerHuman)
MyFile.Close
FSO.CopyFile includebase, includedest, true
FindReplaceInFile includedest, "@SWITCH_VERSION_REVISION@", VERSION
FindReplaceInFile includedest, "@SWITCH_VERSION_MAJOR@", strVerMajor
@ -405,5 +414,5 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
FindReplaceInFile includedest, "@SWITCH_VERSION_MICRO@", strVerMicro
FindReplaceInFile includedest, "@SWITCH_VERSION_REVISION_HUMAN@", strVerHuman
End If
End Sub