Comparing Versions

Post

Posted
Rating:
#1 (In Topic #1395)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 Hi Everyone,

Just wanted to ask some advice
Does anyone know how I can get a application version without manually saving it to a text file?

What I want to do is save any new update to my central server and have a update app run once a day to check to see if the local version of the app is less then the one on the server if it is less then have the system wget the new file from my server and then rename the old one to .bak and move the new one to the location of the app and then start the app

I can reboot and restart my applications easily as I have a boot up script and this script does all the work.

Is it possible to access the version number from outside the app?

I.E My local version would be 6.0.1533 and the new one on the server would be 6.0.1599 so the system would download the file
and if the files are the other way wound the System would ignore the one on the server (example Server is 6.0.1533 and the Local one is 6.0.1599 (say I did the update to this manually)


I know this sound a bit random but I am hoping to automate the updates to my bug fixes on my Apps (The plan is so I don't have to keep connecting to customers machines at night and updating everything manually)

Any ideas or examples would be most welcomed.

Kind regards

Andy
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
 Hi Andy,
If you check the box in project properties for { Get from 'VERSION' file. }
It creates a .version file in the project folder.
I'm assuming that this gets copied into the installation package ?

Cheers - Quin.
I code therefore I am
Online now: No Back to the top

Post

Posted
Rating:
#3
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 I'm not sure if I have any installation packages as I am installing Gambas on the machine and then coping over my .gambas file so it will run

Ive not worked out how to get a install package to work yet lol

I am not going down the wrong line of though for this am I? Maybe someone else has already though of a solution for this (if so I would love to hear it)
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
You could add gb.args component then the arg -v would give version.

or add the arg yourself

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   If Args.All.Exist("-v") Then
  4.     Print Application.Version
  5.     Quit
  6.  
  7.  

or extract it from the .gambas executable .project file
<HIGHLIGHT highlight="shell">
eval "$(gba3 -x /path/to/MyProgram.gambas .project)"
echo $Version
</HIGHLIGHT>
Online now: No Back to the top

Post

Posted
Rating:
#5
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

BruceSteers said

or extract it from the .gambas executable .project file
<HIGHLIGHT highlight="shell">
eval "$(gba3 -x /path/to/MyProgram.gambas .project)"
echo $Version
</HIGHLIGHT>

This is what I am after but I can not work out how to get the version from the Shell with in my update software

It works fine if I use the command terminal and type the commands you have given

I get the version 6.0.1577 (and this is correct)

if you have a example of how I can call these functions from a update app I would be most greatful

Code

Private Sub GetVersionFromDownloadedFile()
    Dim ShellCommand As String = "eval $(gba3 -x RetailPoS.gambas .project)"
    Dim Result As String

    Shell ShellCommand To Result
    
    Shell result & "$Version > retail.ver"
End

I can not seem to get working

I was thinking if  I can get it to save to a txt file I can then get it to save to a veritable in the software so I can then do checks on the figures

below is my current tests I have done (i have changed the paths so they do not show my real server location)

Code

' Gambas class file

   LocalFile As String = "/path/to/RetailPoS/RetailPoS.gambas"
     NetFile As String = "http://webserver/update/RetailPoS/RetailPoS.gambas"
   TempFolder As String = "/algPoS/Update/"
      TempNet As String = TempFolder &/ "RetailPoS.gambas"

Public Sub Form_Open()
   Try Kill TempNet 'Remove any old downloads that may have been missed (ie if app crashed)
End

Public Sub Button1_Click()
   Label1.Caption = "Download file from server Please wait..."
   copyFileToLocalDrive
   GetVersionFromDownloadedFile
End

Private Sub copyFileToLocalDrive()
   Dim ShellCommand As String = "wget -q " & NetFile & " -P " & TempFolder
   Shell ShellCommand Wait
End

Private Sub GetVersionFromDownloadedFile()
    Dim ShellCommand As String = "eval $(gba3 -x RetailPoS.gambas .project)"
    Dim Result As String

    Shell ShellCommand To Result
    
    Shell result & "$Version > retail.ver"
End
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b

Online now: No Back to the top

Post

Posted
Rating:
#7
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

thatbruce said

Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b

Simple because I would forget to update the text file

I need this to be as idiot proof as I can make it so I don't break anything or customers break anything when systems update
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’
use -o to set full download path for wget

Code (gambas)

  1. Shell "wget -q " & NetFile & " -o " & TempNet
  2.  

also the eval command only runs the output for the .project file, like using source command.
within the output is a line like "Version=1.2.3" so it is like typing Version=1.2.3 in the terminal so it only sets the "$Version" variable but does not print anything, you need echo for that…

And echo must be with the same Shell command, another time you use Shell it will be a fresh process and the $Version variable is no longer there.

also you did not use full path for the project file just "gba3 -x RetailPoS.gambas" that probably will not do.

Code (gambas)

  1.  
  2. Private Sub GetVersionFromDownloadedFile()
  3.  
  4. ' use eval on gbx3 result and echo -n to print the $Version variable with no LF.
  5.     Shell "eval $(gba3 -x " & TempNet & "  .project | grep Version)\n echo -n $Version" Wait To Result
  6.  
  7. '   Shell result & "$Version > retail.ver"
  8.   ' maybe you mean something like this..
  9.   File.Save("./retail.ver", Result)
  10.  
  11.  
  12.  
Online now: No Back to the top

Post

Posted
Rating:
#9
Guru
BruceSteers is in the usergroup ‘Guru’

AndyGable said

thatbruce said

Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b

Simple because I would forget to update the text file

I need this to be as idiot proof as I can make it so I don't break anything or customers break anything when systems update

When you "Make executable" you can automatically run a command after.
It is set in the configure executable dialog…
Image

(Click to enlarge)

The text i have set the in the "Run command after" writes the version text "0.0.1" with no LF to a file called Version.txt in the project dir.

once that line is set the Version.txt file will be automatically renewed every time you "make executable"

The only thing to watch out for is the Version.txt file it saves will be in the project directory but NOT in the executable because the command is run "after" the executable is made. (only my IDE also has a "Run Before" option)
If you need the Version.txt file inside your executable then you'll have to "make executable" twice for the same version and the second time will add the updated Version.txt file.
Online now: No Back to the top

Post

Posted
Rating:
#10
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

BruceSteers said

AndyGable said

thatbruce said

Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b

Simple because I would forget to update the text file

I need this to be as idiot proof as I can make it so I don't break anything or customers break anything when systems update

When you "Make executable" you can automatically run a command after.
It is set in the configure executable dialog…
Untitled.png
The text i have set the in the "Run command after" writes the version text "0.0.1" with no LF to a file called Version.txt in the project dir.

once that line is set the Version.txt file will be automatically renewed every time you "make executable"

The only thing to watch out for is the Version.txt file it saves will be in the project directory but NOT in the executable because the command is run "after" the executable is made. (only my IDE also has a "Run Before" option)
If you need the Version.txt file inside your executable then you'll have to "make executable" twice for the same version and the second time will add the updated Version.txt file.

Thank for that BruceSteers I will try to use the txt file

Andy
Online now: No Back to the top
1 guest and 0 members have just viewed this.