libURLDownload to File Inquiry

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

libURLDownload to File Inquiry

Post by GSPearson » Fri Mar 20, 2015 11:32 pm

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.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: libURLDownload to File Inquiry

Post by Klaus » Sat Mar 21, 2015 12:06 am

Hi GSPearson,

is gApplicationPrefsDir defined as a global variable?
Did you check "the result" somewhere?


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: libURLDownload to File Inquiry

Post by FourthWorld » Sat Mar 21, 2015 12:15 am

Does UAC allow the program to write/modify files in C:/ProgramData/?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: libURLDownload to File Inquiry

Post by GSPearson » Sat Mar 21, 2015 12:28 am

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

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: libURLDownload to File Inquiry

Post by GSPearson » Sat Mar 21, 2015 12:30 am

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/?

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: libURLDownload to File Inquiry

Post by GSPearson » Sat Mar 21, 2015 12:38 am

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: libURLDownload to File Inquiry

Post by Simon » Sat Mar 21, 2015 1:13 am

Code: Select all

put the result into it
Oh no.... Never do that.
The "it" variable is changing all the time.
just use

Code: Select all

put the result
It may very well be empty.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: libURLDownload to File Inquiry

Post by GSPearson » Sat Mar 21, 2015 2:10 am

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:

Code: Select all

put the result into it
Oh no.... Never do that.
The "it" variable is changing all the time.
just use

Code: Select all

put the result
It may very well be empty.

Simon

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: libURLDownload to File Inquiry

Post by Simon » Sat Mar 21, 2015 2:22 am

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

Code: Select all

put pStatus
You will see the different messages sent.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: libURLDownload to File Inquiry

Post by GSPearson » Sat Mar 21, 2015 6:30 pm

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.

Post Reply

Return to “Internet”