[Script] Update Project64Url in upload_beta.vbs

This commit is contained in:
zilmar 2017-07-12 20:17:08 +10:00
parent 264a6ede5b
commit 6aba2ae793
1 changed files with 64 additions and 65 deletions

View File

@ -1,19 +1,19 @@
if WScript.Arguments.Count < 3 then if WScript.Arguments.Count < 3 then
ShowUsage() ShowUsage()
ElseIf StrComp("--create",WScript.Arguments(0)) = 0 Then ElseIf StrComp("--create",WScript.Arguments(0)) = 0 Then
if WScript.Arguments.Count < 4 then if WScript.Arguments.Count < 4 then
ShowUsage() ShowUsage()
else else
CreateUploadTarget() CreateUploadTarget()
end if end if
ElseIf StrComp("--files",WScript.Arguments(0)) = 0 Then ElseIf StrComp("--files",WScript.Arguments(0)) = 0 Then
if WScript.Arguments.Count < 4 then if WScript.Arguments.Count < 4 then
ShowUsage() ShowUsage()
else else
UploadFiles() UploadFiles()
end if end if
Else Else
ShowUsage() ShowUsage()
End if End if
sub ShowUsage() sub ShowUsage()
@ -24,12 +24,12 @@ sub ShowUsage()
end sub end sub
function Project64Url() function Project64Url()
Project64Url = "http://www.local.pj64-emu.com" Project64Url = "http://www.pj64-emu.com"
End Function End Function
sub CreateUploadTarget() sub CreateUploadTarget()
dim BuildUrl dim BuildUrl
BuildUrl = WScript.Arguments(2) BuildUrl = WScript.Arguments(2)
Dim objHTTP Dim objHTTP
Set objHTTP = CreateObject("MSXML2.XMLHTTP") Set objHTTP = CreateObject("MSXML2.XMLHTTP")
@ -39,21 +39,21 @@ sub CreateUploadTarget()
WScript.StdOut.WriteLine "failed to get job timestamp (" & BuildUrl & "buildTimestamp)" WScript.StdOut.WriteLine "failed to get job timestamp (" & BuildUrl & "buildTimestamp)"
WScript.Quit 1 WScript.Quit 1
end if end if
dim d dim d
SetLocale 1033 SetLocale 1033
build_date=CDate(objHTTP.responseText) build_date=CDate(objHTTP.responseText)
Set objHTTP = CreateObject("MSXML2.XMLHTTP") Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.open "GET", BuildUrl & "api/xml?wrapper=changes", False objHTTP.open "GET", BuildUrl & "api/xml?wrapper=changes", False
objHTTP.send objHTTP.send
if (objHTTP.status <> 200) then if (objHTTP.status <> 200) then
WScript.StdOut.WriteLine "failed to get job details (" & BuildUrl & "api/xml?wrapper=changes)" WScript.StdOut.WriteLine "failed to get job details (" & BuildUrl & "api/xml?wrapper=changes)"
WScript.Quit 1 WScript.Quit 1
end if end if
Dim xmlDoc Dim xmlDoc
Set xmlDoc = objHTTP.responseXML Set xmlDoc = objHTTP.responseXML
Set objLst = xmlDoc.getElementsByTagName("freeStyleBuild") Set objLst = xmlDoc.getElementsByTagName("freeStyleBuild")
@ -90,43 +90,42 @@ sub CreateUploadTarget()
ProductDescription = "No code changes" ProductDescription = "No code changes"
end if end if
Dim url Dim url
url = Project64Url() + "/index.php" url = Project64Url() + "/index.php"
dim data dim data
data = "option=com_betafile" data = "option=com_betafile"
data = data & "&task=CreateProduct" data = data & "&task=CreateProduct"
data = data & "&password="&WScript.Arguments(1) data = data & "&password="&WScript.Arguments(1)
data = data & "&jform[product_name]="&WScript.Arguments(3) data = data & "&jform[product_name]="&WScript.Arguments(3)
data = data & "&jform[product_desc]="&ProductDescription data = data & "&jform[product_desc]="&ProductDescription
data = data & "&jform[product_date]="&Year(build_date) & "-" & Month(build_date) & "-" & Day(build_date) data = data & "&jform[product_date]="&Year(build_date) & "-" & Month(build_date) & "-" & Day(build_date)
Set objHTTP = CreateObject("Microsoft.XMLHTTP") Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.open "POST", url, False objHTTP.open "POST", url, False
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.send data objHTTP.send data
if objHTTP.Status <> 200 then if objHTTP.Status <> 200 then
WScript.StdOut.WriteLine "Create beta file failed" WScript.StdOut.WriteLine "Create beta file failed"
WScript.StdOut.WriteLine "status: " & objHTTP.Status WScript.StdOut.WriteLine "status: " & objHTTP.Status
WScript.StdOut.WriteLine objHTTP.responseText WScript.StdOut.WriteLine objHTTP.responseText
WScript.Quit 1 WScript.Quit 1
end if end if
WScript.StdOut.WriteLine objHTTP.responseText
Set objHTTP = Nothing Set objHTTP = Nothing
end sub end sub
sub UploadFiles() sub UploadFiles()
DirToUpload = WScript.Arguments(2) DirToUpload = WScript.Arguments(2)
WScript.StdOut.WriteLine "UploadDirectory start - " & DirToUpload WScript.StdOut.WriteLine "UploadDirectory start - " & DirToUpload
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(DirToUpload) Set objFolder = objFSO.GetFolder(DirToUpload)
Set colFiles = objFolder.Files Set colFiles = objFolder.Files
For Each objFile in colFiles For Each objFile in colFiles
UploadFile DirToUpload & "\" & objFile.Name UploadFile DirToUpload & "\" & objFile.Name
Next Next
WScript.StdOut.WriteLine "UploadDirectory Finished" WScript.StdOut.WriteLine "UploadDirectory Finished"
end sub end sub
@ -157,23 +156,23 @@ sub UploadFile(FileToUpload)
WScript.Quit 1 WScript.Quit 1
end if end if
Dim url Dim url
url = Project64Url() + "/index.php" url = Project64Url() + "/index.php"
dim fileContents dim fileContents
fileContents = ReadBinaryFile(FileToUpload) fileContents = ReadBinaryFile(FileToUpload)
dim PreFormData, PostFormData dim PreFormData, PostFormData
PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""option""" & vbCrLf & vbCrLf & "com_betafile"& vbCrLf PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""option""" & vbCrLf & vbCrLf & "com_betafile"& vbCrLf
PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""task""" & vbCrLf & vbCrLf & "AddFile"& vbCrLf PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""task""" & vbCrLf & vbCrLf & "AddFile"& vbCrLf
PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""password""" & vbCrLf & vbCrLf & WScript.Arguments(1) & vbCrLf PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""password""" & vbCrLf & vbCrLf & WScript.Arguments(1) & vbCrLf
PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""jform[product_name]""" & vbCrLf & vbCrLf & WScript.Arguments(3) & vbCrLf PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""jform[product_name]""" & vbCrLf & vbCrLf & WScript.Arguments(3) & vbCrLf
PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""jform[add_file]""; filename=""" & fileName & """" & vbCrLf PreFormData = PreFormData & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""jform[add_file]""; filename=""" & fileName & """" & vbCrLf
PreFormData = PreFormData & "Content-Type: application/zip" & vbCrLf & vbCrLf PreFormData = PreFormData & "Content-Type: application/zip" & vbCrLf & vbCrLf
PostFormData = vbCrLf & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""upload""" & vbCrLf & vbCrLf & "Upload" & vbCrLf PostFormData = vbCrLf & "--AaB03x" & vbCrLf & "Content-Disposition: form-data; name=""upload""" & vbCrLf & vbCrLf & "Upload" & vbCrLf
PostFormData = PostFormData & vbCrLf & vbCrLf & "--AaB03x--"& vbCrLf PostFormData = PostFormData & vbCrLf & vbCrLf & "--AaB03x--"& vbCrLf
Dim DataToPOSTStream Dim DataToPOSTStream
Set DataToPOSTStream = CreateObject("ADODB.Stream") Set DataToPOSTStream = CreateObject("ADODB.Stream")
DataToPOSTStream.type=adTypeBinary DataToPOSTStream.type=adTypeBinary
@ -188,19 +187,19 @@ sub UploadFile(FileToUpload)
Dim DataToPOST Dim DataToPOST
DataToPOST = DataToPOSTStream.Read DataToPOST = DataToPOSTStream.Read
Set objHTTP = CreateObject("Microsoft.XMLHTTP") Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.open "POST", url, False objHTTP.open "POST", url, False
objHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=AaB03x" objHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=AaB03x"
objHTTP.setRequestHeader "Content-Length", Len(fileContents) objHTTP.setRequestHeader "Content-Length", Len(fileContents)
objHTTP.send DataToPOST objHTTP.send DataToPOST
if objHTTP.Status <> 200 then if objHTTP.Status <> 200 then
WScript.StdOut.WriteLine "Failed to upload file" WScript.StdOut.WriteLine "Failed to upload file"
WScript.StdOut.WriteLine "status: " & objHTTP.Status WScript.StdOut.WriteLine "status: " & objHTTP.Status
WScript.StdOut.WriteLine objHTTP.responseText WScript.StdOut.WriteLine objHTTP.responseText
WScript.Quit 1 WScript.Quit 1
end if end if
WScript.StdOut.WriteLine "UploadFile Finished" WScript.StdOut.WriteLine "UploadFile Finished"
end sub end sub