473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

How to get the version of a file

Does anyone know how to get the version of an application on OS X (i.e.
the version string that appears in the "Version" field in the "Get Info"
window for an application)?

I'm running OS 10.4.11, python 2.5.
Jun 27 '08 #1
3 1900
you need appscript "that allows you to control scriptable Mac OS X
applications from Python"
http://pypi.python.org/pypi/appscript/0.18.1
Jun 27 '08 #2
I'm not clear on how to use this to read the version resource.
Specially, I need to get the version of Palm Conduit, which is, I guess,
a "carbonized" shared library... or something.

?
ma***********@gmail.com wrote:
you need appscript "that allows you to control scriptable Mac OS X
applications from Python"
http://pypi.python.org/pypi/appscript/0.18.1
Jun 27 '08 #3
Hello J,
Does anyone know how to get the version of an application on OS X (i.e.
the version string that appears in the "Version" field in the "Get Info"
window for an application)?

I'm running OS 10.4.11, python 2.5.
#!/usr/bin/env python

from xml.etree.cElementTree import iterparse
from os.path import isfile

def get_version(app):
info_file = "/Applications/%s.app/Contents/Info.plist" % app
if not isfile(info_file):
raise KeyError("No version file found")

get = 0
for event, element in iterparse(open(info_file)):
if get:
return element.text

if (element.tag == "key") and (element.text ==
"CFBundleVersion"):
get = 1

raise KeyError("Can't find CFBundleVersion key")

if __name__ == "__main__":
from sys import argv

print get_version(argv[1])

HTH,
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Terence Shek | last post by:
Is there a way to set the application binding policy so that it always binds to the latest version of an assembly? I'm hoping there is a way to avoid updating the application's binding...
2
by: j.b.messina | last post by:
This has not yet been published by Microsoft. It will be published within the next few weeks, mainly because I asked them to. I felt this was information badly needed, and I think this is the...
1
by: Paul | last post by:
Hi, Does anyone know how to check a version of a file in C++? Any WIN32 API that does this? Please advice, thanks! -P
6
by: D. Yates | last post by:
Hi, I got bit by the fact that applications using library files that are NOT strongly named will use older versions of the library without generating an error, so........ Is there a way to...
5
by: Laurence | last post by:
In VS.2005 using VB.NET There are two versions on every project, The Assembly Version and the File Version. Why are there two different versions? As far as I can tell, there is not need for...
0
by: ev951 | last post by:
I am not that familiar with XML or XSL and I am trying to sort application version number strings in an XML file that my team uses for application installations on our Linux servers. I have tried...
0
by: Grant_Sutty | last post by:
Hi The only file information I need to access for a bunch of files (dlls & exe) on several remote servers is "file version number". Using the code below, I appear to be able to access all...
6
by: Zytan | last post by:
In the Assembly Information, you can set the assembly version and the file version. What is the difference between the two? The documentation is not exactly helpful in this area. I had the...
5
by: jroozee | last post by:
I am developing in VS '03. I have all of the current framework versions installed on my PC, 1.1, 2.0, and 3.0. How can I make sure the code I am developing in is using the 3.0 framework version?...
4
by: Bob Altman | last post by:
Hi all, I have a C++/CLI project (VS 2005) that produces a DLL that exports C bindings. Internally, this DLL contains routines compiled with /clr. I notice that my DLL doesn't have a version...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.