[IronPython] platform.system() == "cli"

Oren Held oren at held.org.il
Fri Jan 9 00:02:15 CET 2009


On Friday 09 January 2009 00:28:49 Curt Hagenlocher wrote:
> On Thu, Jan 8, 2009 at 2:01 PM, Oren Held <oren at held.org.il> wrote:
> > In my code, I have a section which is not cross platform, thus I'm
> > checking the OS name to call the matching OS-specific calls.
> >
> > In all Unices, using platform.system() returned the OS name just fine. Is
> > there a better way for getting the OS name on both CPython & IronPython?
>
> IronPython is different enough from CPython on Win32 that it seems odd
> to me for something to work under both, but to fail on IronPython
> under Mono.
>
> If you don't care about supporting Mono, you could say
>     sys.platform in ('win32', 'cli').
> If Mono support matters, then I don't know any straightforward way to
> do this.  I think you could check for a platform of 'cli' and then
> look at System.Environment.OSVersion.

Thanks for your reply.

Just to clarify: my script messes with system configurations. For example, if 
it's Solaris, I read the /etc/mnttab file, if it's Linux, I read the /etc/mtab 
file. On windows, I might ask the registry or read some other file. This is a 
the case in which the OS name DOES matter, while the Python implementation 
doesn't.

 - Oren



More information about the Ironpython-users mailing list