Dienstag, 2. Juli 2013

=== Obtain versions of firefox in linux using python and bash ===

The following code will get you the versions of both: The firefox version currently installed and the one available for update on the server:

01 #!/usr/bin/env python
02 
03 import os
04 
05 # we look and store the local version of firefox in this function
06 def firefox_get_version_string(inputString):
07     firefox_version_string = os.popen(inputString).read()
08 
09 # short name for firefox version number
10     fvn = " "
11
12     for i in firefox_version_string:
13         if i.isalpha() != True and i != "-" :
14            fvn = fvn + i
15
16     return fvn.strip()
17
18
19 firefox_version_remote = (firefox_get_version_string("curl -s -l ftp.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-i686/de/|awk -F "".tar.bz2"" {'print $1'}"))
20 firefox_version_local = (firefox_get_version_string("firefox -v"))
21
22 if firefox_version_remote == firefox_version_local:
23     print("++++++++++++++++++++++++++++++++++++++++++")
24     print("This is a Testphase for autoupdate firefox")
25     print("version is up to date")
26 else:
27     print("++++++++++++++++++++++++++++++++++++++++++")
28     print("This is a Testphase for autoupdate firefox")
29     print("version differs. There might be a newer version available on the remote server")
30     print("consider implementing all of it.")
31     print("for now update must be done manually")

try it and enyjoy. oh and i am using python 2.7.3 by the way.

Keine Kommentare:

Kommentar veröffentlichen

Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.