Page 1 of 1
libURLDownload to File Inquiry
Posted: Fri Mar 20, 2015 11:32 pm
by GSPearson
In my application I have libURLDownloadToFile working as in my splash stack it downloads a zip file from my website, extracts it and checks to make sure it is the latest version. If it is not, then it downloads the latest version and runs it.
Now as I have been updating this application, I am trying to complete a user's request by downloading data from the FCC which is in zip format. When I enter the following code and run the application it skips over the callback message function and goes directly to the break point. Within the callback message function, I have a breakpoint command so I can try to figure out why the contents of the archive is not being extracted in the program's data directory.
Code: Select all
libUrlSetStatusCallback "FCCLicenseDownloadStatus", the long name of me
libUrlDownloadToFile tFCCLicenseDataDownload, tFCCLicenseDataFilename, "ExtractFCCDownloadedArchive"
breakpoint
Then the Extract FCC Downloaded Archive is as follows:
Code: Select all
command ExtractFCCDownloadedArchive pURL, pStatus
local tList, tArchiveFileLoc
breakpoint
put gApplicationPrefsDir & slash & "l_mdsitfs.zip" into tArchiveFileLoc
put "Status: Extracting FCC Application Data Files from Online Resource" into fld "Status Msg Field" on card "Main Card" of stack "ViewsOnLearningEBSSplashApplication"
revZipOpenArchive tArchiveFileLoc, "read"
put RevZipEnumerateItems(tArchiveFileLoc) into tList
repeat for each line i in tList
if i = empty then
next repeat
end if
revZipExtractItemToFile tArchiveFileLoc, i, (gApplicationPrefsDir & slash & i)
end repeat
revZipCloseArchive tArchiveFileLoc
delete variable tList
delete variable i
delete variable tArchiveFileLoc
end ExtractFCCDownloadedArchive
gApplicationPrefsDir is set to C:/ProgramData/{ProgramName} which I do have the fcc archive just not the contents of this archive.
Any Ideas why this Extract Function is not being ran.
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 12:06 am
by Klaus
Hi GSPearson,
is gApplicationPrefsDir defined as a global variable?
Did you check "the result" somewhere?
Best
Klaus
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 12:15 am
by FourthWorld
Does UAC allow the program to write/modify files in C:/ProgramData/?
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 12:28 am
by GSPearson
Yes gApplicationPrefsDir is defined as I am using this variable all through the program as it is set to
Code: Select all
put specialfolderpath("Documents") & slash & "Livecode Projects" into tAppPrefDir
right after the libURLDownloadtofile I have a breakpoint and when I run the application it stops on the breakpoint after this command. When I update the custom property "Version Number" and upload a new zip file to the website, a different libURLDownlaodToFile is executed and in that one the callback message is ran which extracts the archive and places the files in the same directory that gApplicationPrefsDir is.
tFCCLicenseDataDownload has a value of
http://wireless.fcc.gov/uls/data/complete/l_mdsitfs.zip
tFCCLicenseDatafilename has a value of c:/Users/Graham/Documents/Livecode Projects/EBSLicenseMapPrefs/l_mdsitfs.zip
Which if I remove the l_mdsitfs.zip file and run the application a new one with the latest database from the FCC is stored in the directory.
Which from the dictionary it says: The callbackMessage is the name of a message to send after the download is finished. And in this one case, it is not calling this message handler and I am not sure why.
Klaus wrote:Hi GSPearson,
is gApplicationPrefsDir defined as a global variable?
Did you check "the result" somewhere?
Best
Klaus
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 12:30 am
by GSPearson
UAC does allow for files to be written to this directory as with my other libURLDownloadToFile that downloads the main program and extracts it this callback message gets executed. It is just this other one some 2500 lines later that does not get executed when the file is downloaded. Any not sure why.
FourthWorld wrote:Does UAC allow the program to write/modify files in C:/ProgramData/?
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 12:38 am
by GSPearson
In the present version of the code I have
Code: Select all
libUrlDownloadToFile tFCCLicenseDataDownload, tFCCLicenseDataFilename, "ExtractFCCDownloadedArchive"
put the result into it
breakpoint
And when I run the application the variable it is blank. So it is not showing me if their is an error. If I goto the Program's Data Directory, I see the zip file and I can click on it to see all 22 .dat files which I need to extract and import into SQL. Boy this has me pulling my hair out.
GSPearson wrote:In my application I have libURLDownloadToFile working as in my splash stack it downloads a zip file from my website, extracts it and checks to make sure it is the latest version. If it is not, then it downloads the latest version and runs it.
Now as I have been updating this application, I am trying to complete a user's request by downloading data from the FCC which is in zip format. When I enter the following code and run the application it skips over the callback message function and goes directly to the break point. Within the callback message function, I have a breakpoint command so I can try to figure out why the contents of the archive is not being extracted in the program's data directory.
Code: Select all
libUrlSetStatusCallback "FCCLicenseDownloadStatus", the long name of me
libUrlDownloadToFile tFCCLicenseDataDownload, tFCCLicenseDataFilename, "ExtractFCCDownloadedArchive"
breakpoint
Then the Extract FCC Downloaded Archive is as follows:
Code: Select all
command ExtractFCCDownloadedArchive pURL, pStatus
local tList, tArchiveFileLoc
breakpoint
put gApplicationPrefsDir & slash & "l_mdsitfs.zip" into tArchiveFileLoc
put "Status: Extracting FCC Application Data Files from Online Resource" into fld "Status Msg Field" on card "Main Card" of stack "ViewsOnLearningEBSSplashApplication"
revZipOpenArchive tArchiveFileLoc, "read"
put RevZipEnumerateItems(tArchiveFileLoc) into tList
repeat for each line i in tList
if i = empty then
next repeat
end if
revZipExtractItemToFile tArchiveFileLoc, i, (gApplicationPrefsDir & slash & i)
end repeat
revZipCloseArchive tArchiveFileLoc
delete variable tList
delete variable i
delete variable tArchiveFileLoc
end ExtractFCCDownloadedArchive
gApplicationPrefsDir is set to C:/ProgramData/{ProgramName} which I do have the fcc archive just not the contents of this archive.
Any Ideas why this Extract Function is not being ran.
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 1:13 am
by Simon
Oh no.... Never do that.
The "it" variable is changing all the time.
just use
It may very well be empty.
Simon
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 2:10 am
by GSPearson
Well I think I might know what is going on but not sure. If I have a windows explorer window open the execution of the script will hit the breakpoint before the file gets downloaded completely. So it will not run the call message handler like I would think it would
Any tricks, tips to not process the next line of the script until the libURLDownloadToFile is officially completed.
Simon wrote:
Oh no.... Never do that.
The "it" variable is changing all the time.
just use
It may very well be empty.
Simon
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 2:22 am
by Simon
Code: Select all
ExtractFCCDownloadedArchive pURL, pStatus
pStatus will contain "downloaded" when it is umm downloaded.
You should wait till then before you try the revzip stuff. For now just
You will see the different messages sent.
Simon
Re: libURLDownload to File Inquiry
Posted: Sat Mar 21, 2015 6:30 pm
by GSPearson
What would be some code to stop the execution of the following lines of code until the callback message has been completed. What I have found is if I remove the breakpoint the rest of the application is ran then I would see a answer box in the callback message a few minutes later and this information within the callback message would need to be completed before the application continues as it is inserting data into a database that the main application needs.