ur Posted November 20, 2016 Share Posted November 20, 2016 There is a build machine in the network where it will automatically download the code from source repository and compile using visual studio and compresses the complete code in a zip file. I have added a line at the end of the build script(written in python on that machine) to copy that zip file to my ESX Virtual machine. Where I kept a AutoIT exe to wait for the zip file, once it is copied then I will extract the contents and find only the dll files in the extracted folder and do the Install creation using Installshield silently and copy the created setup files to anther machine. I wrote the script till the setup files creation. But now the problem is, when the zip file is copying through network, the autoit script is detecting it even the copy is still in progress and trying to extract the zip file and failing. Even when I am checking whether the file in use is not working. Any suggestion on how to check whether the copy is completed.? Link to comment Share on other sites More sharing options...
InunoTaishou Posted November 20, 2016 Share Posted November 20, 2016 FileGetSize to compare the size from thee network and the file on the machine. When they match the file is copied completely and can be extracted. Link to comment Share on other sites More sharing options...
ur Posted November 20, 2016 Author Share Posted November 20, 2016 14 minutes ago, InunoTaishou said: FileGetSize to compare the size from thee network and the file on the machine. When they match the file is copied completely and can be extracted. We can't access the server machine shared folders as they are restricted, only our machines can e accessed through server machine, so I am copying the file from there itself to my machine. Is there anyway to check in our machine itself instead of accessing the server machine? Link to comment Share on other sites More sharing options...
InunoTaishou Posted November 20, 2016 Share Posted November 20, 2016 How is your machine going to know everything is copied when it doesn't know big the file is supposed to be? You could try adding another some more code on the machine sending the file to send to your machine that it's done when it's done copying. Open a TCP connection and send a finished value when it's done copying? You could try _WinAPI_FileInUse It might return true if the file is being recognized as still downloading. Link to comment Share on other sites More sharing options...
Bowmore Posted November 20, 2016 Share Posted November 20, 2016 (edited) One method that I have used, is to check the file size or modified time in a loop and when the value has not changed for a certain period of time, it should then be safe to assume that the download has completed. Edited November 20, 2016 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
ur Posted November 22, 2016 Author Share Posted November 22, 2016 On 11/20/2016 at 9:57 PM, Bowmore said: One method that I have used, is to check the file size or modified time in a loop and when the value has not changed for a certain period of time, it should then be safe to assume that the download has completed. Thanks Bowmore,I will try this approach. If possible, can you please share that part of your code. Link to comment Share on other sites More sharing options...
Skysnake Posted November 22, 2016 Share Posted November 22, 2016 How about this? You python script copies first the zip file, and then a 'token.txt' file... Your AutoIt script waits not for the zip, but instead for the txt file. Logically, the txt can only be created/copied AFTER the zip file... When the AutoIt script finds the txt, it now knows the zip must exist, deletes the txt (as a cleanup for the next cycle) and proceeds to process the zip... This way everything will only start once the zip has been copied in full, without having the check Windows process etc. -Skysnake Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
Bowmore Posted November 22, 2016 Share Posted November 22, 2016 This is the sort of thing I have used . expandcollapse popup#include <FileConstants.au3> Global $sFilepath = "P:\Users\Roy Kirby\Pictures\Africa 2002\01\2002-05_slide_02.tif" ; $stablefor and $iTmeout values are in seconds ; use values appropriate for the time the file is expected to take to download or copy If CheckFileIsStable($sFilepath, 30, 300) Then MsgBox(0, "CheckFile", $sFilepath & " - has been stable for at least 30 seconds so it has probably finished copying") Else MsgBox(0, "CheckFile", $sFilepath & " - has not been stable for at least 30 seconds in the last 5 minutes so it has probably stil copying") EndIf Func CheckFileIsStable($sFilepath, $stablefor = 60, $iTmeout = 1800) Local $sPrevFileTime = "A" Local $sFileTime = "" Local $iPrevFileaize = -1 Local $iFilesize = 0 Local $bFileIsStable = False Local $iTimeoutTimer = TimerInit() Do $iFilesize = FileGetSize($sFilepath) If @error = 0 Then $sFileTime = FileGetTime($sFilepath, $FT_MODIFIED, $FT_STRING) If @error = 0 Then If ($sPrevFileTime = $sFileTime) And ($iPrevFileaize = $iFilesize) Then ; File has not changed since last check $bFileIsStable = True Else $sPrevFileTime = $sFileTime $iPrevFileaize = $iFilesize Sleep($stablefor * 1000) EndIf EndIf EndIf Until $bFileIsStable Or TimerDiff($iTimeoutTimer) > ($iTmeout * 1000) Return $bFileIsStable EndFunc ;==>CheckFileIsStable "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now