mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 08:49:01 +00:00
FS-4768 4768-again applied
This commit is contained in:
parent
8e892abdef
commit
1a3323a9d1
@ -4,7 +4,6 @@
|
|||||||
' David A. Horner http://dave.thehorners.com
|
' David A. Horner http://dave.thehorners.com
|
||||||
'----------------------------------------------
|
'----------------------------------------------
|
||||||
|
|
||||||
'On Error Resume Next
|
|
||||||
' **************
|
' **************
|
||||||
' Initialization
|
' Initialization
|
||||||
' **************
|
' **************
|
||||||
@ -36,9 +35,6 @@ If UseWgetEXE Then
|
|||||||
GetWgetEXE UtilsDir
|
GetWgetEXE UtilsDir
|
||||||
End If
|
End If
|
||||||
|
|
||||||
GetCompressionTools UtilsDir
|
|
||||||
|
|
||||||
|
|
||||||
If objArgs.Count >=3 Then
|
If objArgs.Count >=3 Then
|
||||||
Select Case objArgs(0)
|
Select Case objArgs(0)
|
||||||
Case "Get"
|
Case "Get"
|
||||||
@ -96,26 +92,34 @@ Sub WgetUnCompress(URL, DestFolder)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub GetCompressionTools(DestFolder)
|
Sub GetCompressionTools(DestFolder)
|
||||||
Dim oExec
|
|
||||||
Dim tries
|
Dim tries
|
||||||
|
Dim max_tries
|
||||||
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
|
|
||||||
tries = 0
|
tries = 0
|
||||||
While Not FSO.FileExists(DestFolder & "7za.exe") And tries < 2
|
max_tries = 10
|
||||||
WScript.Sleep(Int(10000*Rnd))
|
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
|
||||||
If Not FSO.FileExists(DestFolder & "7za.tag") And Not FSO.FileExists(DestFolder & "7za.exe") Then
|
If Not FSO.FileExists(DestFolder & "7za.exe") Then
|
||||||
Set MyFile = fso.CreateTextFile(DestFolder & "7za.tag", True)
|
On Error Resume Next
|
||||||
|
Set MyFile = FSO.CreateTextFile(DestFolder & "7za.tag", False)
|
||||||
|
If Err <> 0 Then Wscript.echo("Downloading 7za: " & DestFolder & "7za.tag - " & Err.Description) End If
|
||||||
|
On Error Goto 0
|
||||||
|
If Not IsEmpty(MyFile) Then
|
||||||
MyFile.WriteLine("This file marks a pending download for 7za.exe so we don't download it twice at the same time")
|
MyFile.WriteLine("This file marks a pending download for 7za.exe so we don't download it twice at the same time")
|
||||||
MyFile.Close
|
MyFile.Close
|
||||||
|
Wget ToolsBase & "7za.exe", DestFolder
|
||||||
Wget ToolsBase & "7za.exe", DestFolder
|
FSO.DeleteFile DestFolder & "7za.tag", true
|
||||||
|
Wscript.echo("Downloaded 7za.exe")
|
||||||
FSO.DeleteFile DestFolder & "7za.tag" ,true
|
|
||||||
Else
|
|
||||||
WScript.Sleep(5000)
|
|
||||||
tries = tries + 1
|
|
||||||
End If
|
End If
|
||||||
WEnd
|
WScript.Sleep(500)
|
||||||
|
End If
|
||||||
|
Do While FSO.FileExists(DestFolder & "7za.tag") And tries < max_tries
|
||||||
|
Wscript.echo("Waiting for 7za.exe to be downloaded")
|
||||||
|
WScript.Sleep(1000)
|
||||||
|
tries = tries + 1
|
||||||
|
Loop
|
||||||
|
If tries = max_tries Then
|
||||||
|
Wscript.echo("ERROR: Download of 7za.exe takes too much time")
|
||||||
|
Wscript.quit 99
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub GetWgetEXE(DestFolder)
|
Sub GetWgetEXE(DestFolder)
|
||||||
@ -130,10 +134,15 @@ Function Strip(Str)
|
|||||||
Set oRE = New Regexp
|
Set oRE = New Regexp
|
||||||
oRE.Pattern = "[\W_]"
|
oRE.Pattern = "[\W_]"
|
||||||
oRE.Global = True
|
oRE.Global = True
|
||||||
Strip=oRE.Replace(Str, "")
|
Strip = Right(oRE.Replace(Str, ""), 20)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Sub UnCompress(Archive, DestFolder)
|
Sub UnCompress(Archive, DestFolder)
|
||||||
|
Dim Fn
|
||||||
|
Dim batname
|
||||||
|
|
||||||
|
GetCompressionTools UtilsDir
|
||||||
|
|
||||||
batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat"
|
batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat"
|
||||||
wscript.echo("Extracting: " & Archive & " - using: " & batname)
|
wscript.echo("Extracting: " & Archive & " - using: " & batname)
|
||||||
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
|
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
|
||||||
@ -146,10 +155,7 @@ Sub UnCompress(Archive, DestFolder)
|
|||||||
wscript.echo("Ready extracting: " & Archive)
|
wscript.echo("Ready extracting: " & Archive)
|
||||||
Fn = Left(Archive, Len(Archive)-3)
|
Fn = Left(Archive, Len(Archive)-3)
|
||||||
If FSO.FileExists(Fn) Then
|
If FSO.FileExists(Fn) Then
|
||||||
WScript.Sleep(100)
|
Set MyFile = FSO.CreateTextFile(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 & Fn & quote & " -y -o" & quote & DestFolder & quote )
|
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )
|
||||||
MyFile.Close
|
MyFile.Close
|
||||||
Set oExec = WshShell.Exec(UtilsDir & batname)
|
Set oExec = WshShell.Exec(UtilsDir & batname)
|
||||||
@ -161,12 +167,9 @@ Sub UnCompress(Archive, DestFolder)
|
|||||||
wscript.echo("Deleting: " & Fn)
|
wscript.echo("Deleting: " & Fn)
|
||||||
FSO.DeleteFile Fn,true
|
FSO.DeleteFile Fn,true
|
||||||
End If
|
End If
|
||||||
Fn= Fn & tar
|
Fn = Fn & tar
|
||||||
If FSO.FileExists(Fn) Then
|
If FSO.FileExists(Fn) Then
|
||||||
WScript.Sleep(100)
|
Set MyFile = FSO.CreateTextFile(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 & Fn & quote & " -y -o" & quote & DestFolder & quote )
|
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )
|
||||||
MyFile.Close
|
MyFile.Close
|
||||||
Set oExec = WshShell.Exec(UtilsDir & batname)
|
Set oExec = WshShell.Exec(UtilsDir & batname)
|
||||||
@ -180,7 +183,7 @@ Sub UnCompress(Archive, DestFolder)
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
WScript.Sleep(500)
|
WScript.Sleep(500)
|
||||||
If FSO.FileExists(UtilsDir & batname)Then
|
If FSO.FileExists(UtilsDir & batname) Then
|
||||||
FSO.DeleteFile UtilsDir & batname, True
|
FSO.DeleteFile UtilsDir & batname, True
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
@ -192,8 +195,8 @@ Sub Wget(URL, DestFolder)
|
|||||||
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
|
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
|
||||||
|
|
||||||
If UseWgetEXE Then
|
If UseWgetEXE Then
|
||||||
Wscript.echo("Downloading (wget): " & URL)
|
Wscript.echo("wget: " & URL)
|
||||||
batname = "tmp" & CStr(Int(100000*Rnd)) & ".bat"
|
batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"
|
||||||
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
|
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
|
||||||
MyFile.WriteLine("@cd " & quote & DestFolder & quote)
|
MyFile.WriteLine("@cd " & quote & DestFolder & quote)
|
||||||
MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)
|
MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)
|
||||||
@ -204,7 +207,7 @@ Sub Wget(URL, DestFolder)
|
|||||||
Loop While Not OExec.StdOut.atEndOfStream
|
Loop While Not OExec.StdOut.atEndOfStream
|
||||||
|
|
||||||
Else
|
Else
|
||||||
Wscript.echo("Downloading (HTTP GET): " & URL)
|
Wscript.echo("XMLHTTP GET: " & URL)
|
||||||
|
|
||||||
xml.Open "GET", URL, False
|
xml.Open "GET", URL, False
|
||||||
xml.Send
|
xml.Send
|
||||||
@ -416,3 +419,4 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user