Jump to content

Can I download a "config file" from Git at run-time?


Recommended Posts

Hello LV gurus,

 

I'm getting ready to write a utility that will allow me to "download a file from Git" at run-time. Disclaimer: I have not used Git much.. anyhow, I'm hoping I can leverage from any work done on this front.

 

By the way, when I say "I'll write a utility" I'm thinking of C# or Python as the programming languages I would use. If in C# I can easily output a DLL and such would have a LabVIEW wrapper. If in Python, I'll try to create an executable with parameters, then I'll put a LabVIEW wrapper around it. I have written several utilities this way, therefore, I am certain this approach will work.... Someone could ask though: "is your approach the right one"? let's just assume it is :-) but, I'm open to ideas if you feel like sharing.

 

Details:

My test program -written in LabVIEW- uses two types of configuration files (.ini, .csv). 

The CSV files I use have a version hardcoded in it   e.g.   version, 14.9.29.01    (year.month.day.rev)

Additionally, I have a table (SQL database) that keeps the "RELEASED file version-repository version relationship". E.g.   14.9.30.01, 123

At run time, my LV program gets the local file version (LocalFileVer = 14.9.29.01) and also retrieves both, the file version, and the repository version    ReleasedFileVer=14.9.30.01, RepoVer=123 from the database.

IF my "LocalFileVer"  DOES not match the "ReleasedFileVer" I would like to download file ver "123" from Git.

 

Has anyone done something similar to what I have tried to describe here? if yes, would you mind sharing? I'm looking specifically to download files from Git though, and not other version control apps.

 

By the way, I have been able to do what is described above for SVN. Unfortunately I don't have access to the source code... At the time I was doing contract work on a machine that was not "mine". Anyhow, at the time I used C# to write the utility. 

 

I look forward to any comments.

Cheers!

 

Link to comment

Hello LV gurus,

 

I'm getting ready to write a utility that will allow me to "download a file from Git" at run-time. Disclaimer: I have not used Git much.. anyhow, I'm hoping I can leverage from any work done on this front.

 

By the way, when I say "I'll write a utility" I'm thinking of C# or Python as the programming languages I would use. If in C# I can easily output a DLL and such would have a LabVIEW wrapper. If in Python, I'll try to create an executable with parameters, then I'll put a LabVIEW wrapper around it. I have written several utilities this way, therefore, I am certain this approach will work.... Someone could ask though: "is your approach the right one"? let's just assume it is :-) but, I'm open to ideas if you feel like sharing.

 

Details:

My test program -written in LabVIEW- uses two types of configuration files (.ini, .csv). 

The CSV files I use have a version hardcoded in it   e.g.   version, 14.9.29.01    (year.month.day.rev)

Additionally, I have a table (SQL database) that keeps the "RELEASED file version-repository version relationship". E.g.   14.9.30.01, 123

At run time, my LV program gets the local file version (LocalFileVer = 14.9.29.01) and also retrieves both, the file version, and the repository version    ReleasedFileVer=14.9.30.01, RepoVer=123 from the database.

IF my "LocalFileVer"  DOES not match the "ReleasedFileVer" I would like to download file ver "123" from Git.

 

Has anyone done something similar to what I have tried to describe here? if yes, would you mind sharing? I'm looking specifically to download files from Git though, and not other version control apps.

 

By the way, I have been able to do what is described above for SVN. Unfortunately I don't have access to the source code... At the time I was doing contract work on a machine that was not "mine". Anyhow, at the time I used C# to write the utility. 

 

I look forward to any comments.

Cheers!

 

 

The easiest is most likely to use the command line tool of whatever GIT client you install. I do the same for SubVersion calling svn.exe with

 

svn status --show-updates --verbose

 

Parsing the return string is some work but easily doable in a generic manner that will work well. I'm absolutely sure that GIT works the same and this will give you a very flexible and easy to do interface without any need to go .Net, etc. Most of the tools you would otherwise integrate take the command line approach too in the end.

Link to comment

This is kind of a tricky area with GIT source control.  There are a lot of factors it depends on.  GIT source control doesn't work the same as SVN and its hard to pull down a single file like you can in SVN without locally cloning the entire repository. which you can do with git clone/pull and then remove all the files except the one you want.

 

Where would this file be "hosted"? Would it be on GitHub/Bitbuck, or some remote computer?  If stored on GitHub/Bitbucket i believe you can provide a download link for individual files from their webpage, however this feature is not native to remote git repositories in general.  You would then have to download this file using whatever method you prefer.

 

A quick search came up with these threads that might be of some help to you.   

 

http://stackoverflow.com/questions/7106012/download-a-single-folder-or-directory-from-a-github-repo  & 

 

http://stackoverflow.com/questions/3642143/get-a-single-file-from-a-remote-git-repository

 

http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export

 

If you have a local copy of the full repository it appears you can parse the contents of a single file from the command line by using git show HEAD:$path_to_file

I don't think this will work well for non text based files but should be fine for your config files.  

 

As far as method, if you only need to perform commands with the command line, then i might recommend using the "System Exec.vi" within labview.  I have used this a lot to perform functions that require parsing STOUT from the command line.

 

However, Python/C# obviously give you other capabilities for grabbing and parsing the file if needed.  

Edited by odoylerules
Link to comment

My first comment is, Oh my! there is so much to learn about Git! And by the way, the file is hosted in GitHub. I was able to download a file from GitHub using python. I did not get around to creating the LabVIEW wrapper for it just yet.

 

LabVIEW gurus, the following is about to go off on a tangent (hold-on to your seats): If you are interested in the topic of "downloading files from an online repository" and have experience, desire, energy and vision send me a note. I'm thinking of a "why not?" type of scenario... I'd like to create a toolkit for this purpose but don't have the time to do it by myself, therefore, I'm willing to work with someone on this. Further, if there was a way to market such toolkit and get some royalties for it, why not?

 

Warm regards,

Cheers!

Edited by nitulandia
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.