Mailing List Archive

os.name
High,

someone working on a more specific version of os.name or better:
something inside of 'sys.builtin_module_names'.

It's because I need to differ between Win95, Win98 and WinNT....

Thanx,

Holger
os.name [ In reply to ]
Holger Jannsen <holger@phoenix-edv.netzservice.de> writes:
| someone working on a more specific version of os.name or better:
| something inside of 'sys.builtin_module_names'.
|
| It's because I need to differ between Win95, Win98 and WinNT....

Not clear, missing parts of speech, however, os.uname()... Windows
behavior unknown.

Donn Cave, University Computing Services, University of Washington
donn@u.washington.edu
os.name [ In reply to ]
on both my 95 and 98 boxes:

>>> os.name
'nt'
>>> os.environ('OS')
Traceback (innermost last):
File "<pyshell#8>", line 1, in ?
os.environ('OS')
AttributeError: no __call__ method defined

--

Emile van Sebille
emile@fenx.com
-------------------


Gordon McMillan <gmcm@hypernet.com> wrote in message
news:1278785134-25350540@hypernet.com...
> Donn Cave writes:
>
> > Holger Jannsen <holger@phoenix-edv.netzservice.de> writes:
>
> > | It's because I need to differ between Win95, Win98 and WinNT....
> >
> > Not clear, missing parts of speech, however, os.uname()... Windows
> > behavior unknown.
>
> Windows gives an AttributeError.
>
> os.environ['OS'] gives "Windows_NT" on my NT box. Maybe some Win9xers
> could try it on theirs...
>
> - Gordon
>
>
os.name [ In reply to ]
On Fri, 30 Jul 1999, Emile van Sebille wrote:
> >>> os.environ('OS')
> Traceback (innermost last):
> File "<pyshell#8>", line 1, in ?
> os.environ('OS')
> AttributeError: no __call__ method defined

os.environ is a dictionary:

>>> os.environ['OS']

> --
>
> Emile van Sebille
> emile@fenx.com
> -------------------

Oleg.
----
Oleg Broytmann Netskate/Inter.Net.Ru phd@emerald.netskate.ru
Programmers don't die, they just GOSUB without RETURN.
os.name [ In reply to ]
Emile van Sebille <emile@fenx.com> wrote:
> >>> os.name
> 'nt'
> >>> os.environ('OS')
> Traceback (innermost last):
> File "<pyshell#8>", line 1, in ?
> os.environ('OS')
> AttributeError: no __call__ method defined

Gordon asked you to try os.environ['OS'],
not os.environ('OS') ;-)

</F>
os.name [ In reply to ]
Donn Cave writes:

> Holger Jannsen <holger@phoenix-edv.netzservice.de> writes:

> | It's because I need to differ between Win95, Win98 and WinNT....
>
> Not clear, missing parts of speech, however, os.uname()... Windows
> behavior unknown.

Windows gives an AttributeError.

os.environ['OS'] gives "Windows_NT" on my NT box. Maybe some Win9xers
could try it on theirs...

- Gordon
os.name [ In reply to ]
<oops...>

Well, now both 95 and 98 say:

>>> import os
>>> os.environ['OS']
Traceback (innermost last):
File "<pyshell#1>", line 1, in ?
os.environ['OS']
File "D:\Program Files\Python\Lib\os.py", line 247, in __getitem__
return self.data[string.upper(key)]
KeyError: OS
>>>

I've-got-to-get-a-bigger-monitor-for-1600x1200-ly yr's

--

Emile van Sebille
emile@fenx.com
-------------------


Fredrik Lundh <fredrik@pythonware.com> wrote in message
news:001e01beda8e$2111d2e0$f29b12c2@secret.pythonware.com...
> Emile van Sebille <emile@fenx.com> wrote:
> > >>> os.name
> > 'nt'
> > >>> os.environ('OS')
> > Traceback (innermost last):
> > File "<pyshell#8>", line 1, in ?
> > os.environ('OS')
> > AttributeError: no __call__ method defined
>
> Gordon asked you to try os.environ['OS'],
> not os.environ('OS') ;-)
>
> </F>
>
os.name [ In reply to ]
By the way, in windows at a command prompt:

95,98: net config
nt: net config [server|workstation]

gives a line that starts : Software version

I thought I'd key in it a script real quick, but I don't have
enough time now to wrap it up. Maybe it will get you started.


def getwinver():
import os
winver = None
test = os.system('net config > xxconfig.net')
if test == 0:
f = open('xxconfig.net', 'r')
config = f.readlines()
f.close()
for line in config:
print line
if line[:16] == "Software version":
winver = line
else:
pass # test value is error code
return winver



--

Emile van Sebille
emile@fenx.com
-------------------


Fredrik Lundh <fredrik@pythonware.com> wrote in message
news:001e01beda8e$2111d2e0$f29b12c2@secret.pythonware.com...
> Emile van Sebille <emile@fenx.com> wrote:
> > >>> os.name
> > 'nt'
> > >>> os.environ('OS')
> > Traceback (innermost last):
> > File "<pyshell#8>", line 1, in ?
> > os.environ('OS')
> > AttributeError: no __call__ method defined
>
> Gordon asked you to try os.environ['OS'],
> not os.environ('OS') ;-)
>
> </F>
>
os.name [ In reply to ]
emile@fenx.com (Emile van Sebille) wrote in
<Ggto3.4361$VL2.467372@news.direcpc.com>:

>By the way, in windows at a command prompt:
>
>95,98: net config
>nt: net config [server|workstation]
>
>gives a line that starts : Software version

Wouldn't "ver" be easier?

--
Felix Pütsch
os.name [ In reply to ]
It sure would. Any idea how you would get the result back into python
without having the dos command windows flash up on the screen?

but-the-you-wouldn't-have-the-fun-of-parsing-the-file-ly yr's

--

Emile van Sebille
emile@fenx.com
-------------------


Felix Puetsch <puetsch@gmx.de> wrote in message
news:7nuac5$3rs$1@chief.death.de...
> emile@fenx.com (Emile van Sebille) wrote in
> <Ggto3.4361$VL2.467372@news.direcpc.com>:
>
> >By the way, in windows at a command prompt:
> >
> >95,98: net config
> >nt: net config [server|workstation]
> >
> >gives a line that starts : Software version
>
> Wouldn't "ver" be easier?
>
> --
> Felix Pütsch
os.name [ In reply to ]
Emile van Sebille wrote:
>
> It sure would. Any idea how you would get the result back into python
> without having the dos command windows flash up on the screen?
On Windows NT I use win32pipe:
i,o,e=win32pipe.popen3('ver')
ret=o.readlines()
>
> but-the-you-wouldn't-have-the-fun-of-parsing-the-file-ly yr's
>
> --
>
> Emile van Sebille
> emile@fenx.com
> -------------------
>
> Felix Puetsch <puetsch@gmx.de> wrote in message
> news:7nuac5$3rs$1@chief.death.de...
> > emile@fenx.com (Emile van Sebille) wrote in
> > <Ggto3.4361$VL2.467372@news.direcpc.com>:
> >
> > >By the way, in windows at a command prompt:
> > >
> > >95,98: net config
> > >nt: net config [server|workstation]
> > >
> > >gives a line that starts : Software version
> >
> > Wouldn't "ver" be easier?
> >
> > --
> > Felix Pütsch
>
> --
Arpad Kiss
os.name [ In reply to ]
Thank you,

that'll have to do it.

Ciao,
Holger

Arpad Kiss schrieb:
>
> Emile van Sebille wrote:
> >
> > It sure would. Any idea how you would get the result back into python
> > without having the dos command windows flash up on the screen?
> On Windows NT I use win32pipe:
> i,o,e=win32pipe.popen3('ver')
> ret=o.readlines()
> >
> > but-the-you-wouldn't-have-the-fun-of-parsing-the-file-ly yr's
> >
> > --
> >
> > Emile van Sebille
> > emile@fenx.com
> > -------------------
> >
> > Felix Puetsch <puetsch@gmx.de> wrote in message
> > news:7nuac5$3rs$1@chief.death.de...
> > > emile@fenx.com (Emile van Sebille) wrote in
> > > <Ggto3.4361$VL2.467372@news.direcpc.com>:
> > >
> > > >By the way, in windows at a command prompt:
> > > >
> > > >95,98: net config
> > > >nt: net config [server|workstation]
> > > >
> > > >gives a line that starts : Software version
> > >
> > > Wouldn't "ver" be easier?
> > >
> > > --
> > > Felix Pütsch
> >
> > --
> Arpad Kiss
os.name [ In reply to ]
High Arpard,

thanx for help but I got probs with that popen3 under Win95:
'o.readlines()' doesn't return anymore. To find out I checked
it line per line:

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import win32pipe
>>> i,o,e=win32pipe.popen3('ver', 'b')
>>> o.readline()
'\015\012'
>>> o.readline()
'Windows 95. [Version 4.00.1111]\015\012'
>>> o.readline()
'\015\012'
>>> o.readline()

Don't know why, but it never;-) returns.
Perhaps it may be a bug in win32pipe, that it doesn't return
becourse readline couldn't find CarriageReturn/EOF?

I took win32pipe.popen('ver','r') for a better solution.
That works fine.

greetings,
Holger



Arpad Kiss wrote:
>
> Emile van Sebille wrote:
> >
> > It sure would. Any idea how you would get the result back into python
> > without having the dos command windows flash up on the screen?
> On Windows NT I use win32pipe:
> i,o,e=win32pipe.popen3('ver')
> ret=o.readlines()
> >
> >...