Hi
In typically windows environments I have used:
if 'Windows' in os.environ['OS']...
to prove it, but now I need to properly support different environments.
To do so I must accurately determine what system the python instance is
running on (linux, win, mac, etc).
Is there a best practises way to do this?
TIA
Ian 7 23732
On Dec 13, 6:32 pm, "Ian F. Hood" <IanFH...@gmail.comwrote:
Hi
In typically windows environments I have used:
if 'Windows' in os.environ['OS']...
to prove it, but now I need to properly support different environments.
To do so I must accurately determine what system the python instance is
running on (linux, win, mac, etc).
Is there a best practises way to do this?
TIA
Ian
I would do this:
--------------------
if os.name == ''posix':
linuxStuff()
elif os.name == 'nt':
windowsStuff()
elif os.name == 'os2': ...
-------------------
os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
-N
Ian F. Hood wrote:
Hi
In typically windows environments I have used:
if 'Windows' in os.environ['OS']...
to prove it, but now I need to properly support different environments.
To do so I must accurately determine what system the python instance is
running on (linux, win, mac, etc).
Is there a best practises way to do this?
TIA
Ian
The more significant question is "why" do you want to do this? Are you
writing an asset management tool? Do you just want to tell the user
what operating system they are using? The reason may lead to a
different solution.
I am integrating with an existing cross-platform system that provides
different shell scripts and/or batch files for each environment. Normally
the selection is performed manually but my utility needs to automate this.
To select the correct utility I need to know what platform my code is
running on.
"Paul Watson" <pw*****@redlinepy.comwrote in message
news:4u*************@mid.individual.net...
Ian F. Hood wrote:
>Hi In typically windows environments I have used: if 'Windows' in os.environ['OS']... to prove it, but now I need to properly support different environments. To do so I must accurately determine what system the python instance is running on (linux, win, mac, etc). Is there a best practises way to do this? TIA Ian
The more significant question is "why" do you want to do this? Are you
writing an asset management tool? Do you just want to tell the user
what operating system they are using? The reason may lead to a
different solution.
-- http://mail.python.org/mailman/listinfo/python-list
excellent, ty
<na******@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
>
On Dec 13, 6:32 pm, "Ian F. Hood" <IanFH...@gmail.comwrote:
>Hi In typically windows environments I have used: if 'Windows' in os.environ['OS']... to prove it, but now I need to properly support different environments. To do so I must accurately determine what system the python instance is running on (linux, win, mac, etc). Is there a best practises way to do this? TIA Ian
I would do this:
--------------------
if os.name == ''posix':
linuxStuff()
elif os.name == 'nt':
windowsStuff()
elif os.name == 'os2': ...
-------------------
os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
-N
-- http://mail.python.org/mailman/listinfo/python-list
On 2006-12-13 19:28:14 -0500, na******@gmail.com said:
>
On Dec 13, 6:32 pm, "Ian F. Hood" <IanFH...@gmail.comwrote:
>Hi In typically windows environments I have used: if 'Windows' in os.environ['OS']... to prove it, but now I need to properly support different environments. To do so I must accurately determine what system the python instance is running on (linux, win, mac, etc). Is there a best practises way to do this? TIA Ian
I would do this:
--------------------
if os.name == ''posix':
linuxStuff()
elif os.name == 'nt':
windowsStuff()
elif os.name == 'os2': ...
-------------------
os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
-N
Bearing in mind, of course, that Mac will return "posix", too. And
Cygwin might. Erg.
Best,
James
also try:
sys.platform
if sys.platform == "darwin":
macStuff()
elif sys.platform == "win32":
linuxStuff()
James Cunningham wrote:
On 2006-12-13 19:28:14 -0500, na******@gmail.com said:
On Dec 13, 6:32 pm, "Ian F. Hood" <IanFH...@gmail.comwrote:
Hi
In typically windows environments I have used:
if 'Windows' in os.environ['OS']...
to prove it, but now I need to properly support different environments.
To do so I must accurately determine what system the python instance is
running on (linux, win, mac, etc).
Is there a best practises way to do this?
TIA
Ian
I would do this:
--------------------
if os.name == ''posix':
linuxStuff()
elif os.name == 'nt':
windowsStuff()
elif os.name == 'os2': ...
-------------------
os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
-N
Bearing in mind, of course, that Mac will return "posix", too. And
Cygwin might. Erg.
Best,
James
eeps! typo.
if sys.platform == "darwin":
macStuff()
elif sys.platform == "win32":
winStuff()
Not sure what the string is on linux. Just fire up the interpreter and
try it.
Prateek
Prateek wrote:
also try:
sys.platform
if sys.platform == "darwin":
macStuff()
elif sys.platform == "win32":
linuxStuff()
James Cunningham wrote:
On 2006-12-13 19:28:14 -0500, na******@gmail.com said:
>
>
On Dec 13, 6:32 pm, "Ian F. Hood" <IanFH...@gmail.comwrote:
>Hi
>In typically windows environments I have used:
>if 'Windows' in os.environ['OS']...
>to prove it, but now I need to properly support different environments.
>To do so I must accurately determine what system the python instance is
>running on (linux, win, mac, etc).
>Is there a best practises way to do this?
>TIA
>Ian
>
I would do this:
--------------------
if os.name == ''posix':
linuxStuff()
elif os.name == 'nt':
windowsStuff()
elif os.name == 'os2': ...
-------------------
os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
>
-N
Bearing in mind, of course, that Mac will return "posix", too. And
Cygwin might. Erg.
Best,
James
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lucpustjens |
last post by:
Hello,
I want te determine the client operating system, because I need to kno
the default cookie directory. If there is a way to determine the cooki
directory directly, than it is also good.
...
|
by: Kevin A |
last post by:
Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)
Thanks,
Kevin
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |