FAQ
I am working my way (ok, jumping all over the place) through the O'Reilly
"Python programming on Win32" book and I built the following python script


import win32net
import win32netcon

def ReportServers():
resume = 0
serverTypes = win32netcon.SV_TYPE_ALL
while 1:
data, total, resume = win32net.NetServerEnum(None, 101,
serverTypes, resume)
for server in data:
print data
if resume == 0:
break

if __name__ == "__main__":
ReportServers()


I'm getting the following traceback.....

Traceback (most recent call last):
File "C:\Python22\Pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
exec codeObject in __main__.__dict__
File "C:\tmp\PyCom\ReportServers.py", line 15, in ?
ReportServers()
File "C:\tmp\PyCom\ReportServers.py", line 8, in ReportServers
data, total, resume = win32net.NetServerEnum(None, 1, serverTypes,
resume)
TypeError: The object can not be converted to a Unicode object

Which I don't understand, because it looks like the win32net code returns a
PyUnicode object which should handle it. Anyway, I'm running this on
Windows XP.

BTW, I've picked this stuff up to learn something about Win32 programming.
I'm a unix geek, but I'm an *unemployed* unix geek

-Jon

Search Discussions

  • Simon Brunning at Jan 21, 2002 at 11:03 am

    From: Jon Nials [SMTP:jnials at nials.org]

    I am working my way (ok, jumping all over the place) through the O'Reilly
    "Python programming on Win32" book and I built the following python script


    import win32net
    import win32netcon
    def ReportServers():
    resume = 0
    serverTypes = win32netcon.SV_TYPE_ALL
    while 1:
    data, total, resume = win32net.NetServerEnum(None, 101,
    serverTypes, resume)
    for server in data:
    print data
    if resume == 0:
    break

    if __name__ == "__main__":
    ReportServers()

    I'm getting the following traceback.....

    Traceback (most recent call last):
    File "C:\Python22\Pythonwin\pywin\framework\scriptutils.py", line 301,
    in
    RunScript
    exec codeObject in __main__.__dict__
    File "C:\tmp\PyCom\ReportServers.py", line 15, in ?
    ReportServers()
    File "C:\tmp\PyCom\ReportServers.py", line 8, in ReportServers
    data, total, resume = win32net.NetServerEnum(None, 1, serverTypes,
    resume)
    TypeError: The object can not be converted to a Unicode object
    Page 298, last paragraph - NetServerEnum(). The description of this function
    is missing the domain parameter. The correct signature is:

    entries, total, resume = win32net.NetServerEnum(server, level,
    serverTypes=win32netcon.SV_TYPE_ALL, domain=None, resume=0, len@96)

    So you want:

    def ReportServers():
    resume = 0
    serverTypes = win32netcon.SV_TYPE_ALL
    while 1:
    data, total, resume = win32net.NetServerEnum(None, 101, serverTypes,
    None, resume)
    for server in data:
    print data
    if resume == 0:
    break

    Cheers,
    Simon Brunning
    TriSystems Ltd.
    sbrunning at trisystems.co.uk




    -----------------------------------------------------------------------
    The information in this email is confidential and may be legally privileged.
    It is intended solely for the addressee. Access to this email by anyone else
    is unauthorised. If you are not the intended recipient, any disclosure,
    copying, distribution, or any action taken or omitted to be taken in
    reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
    accept liability for statements made which are clearly the senders own.
  • Jon R. Nials at Jan 21, 2002 at 3:13 pm
    Woot! That got it. Worked great. On to more Windows excitement. :)

    Thanks, Simon!

    -Jon
    ----- Original Message -----
    From: "Simon Brunning" <SBrunning at trisystems.co.uk>
    To: "'Jon Nials'" <jnials at nials.org>; <python-list at python.org>
    Sent: Monday, January 21, 2002 5:03 AM
    Subject: RE: win32net problem and question

    From: Jon Nials [SMTP:jnials at nials.org]

    I am working my way (ok, jumping all over the place) through the
    O'Reilly
    "Python programming on Win32" book and I built the following python
    script

    import win32net
    import win32netcon
    def ReportServers():
    resume = 0
    serverTypes = win32netcon.SV_TYPE_ALL
    while 1:
    data, total, resume = win32net.NetServerEnum(None, 101,
    serverTypes, resume)
    for server in data:
    print data
    if resume == 0:
    break

    if __name__ == "__main__":
    ReportServers()

    I'm getting the following traceback.....

    Traceback (most recent call last):
    File "C:\Python22\Pythonwin\pywin\framework\scriptutils.py", line 301,
    in
    RunScript
    exec codeObject in __main__.__dict__
    File "C:\tmp\PyCom\ReportServers.py", line 15, in ?
    ReportServers()
    File "C:\tmp\PyCom\ReportServers.py", line 8, in ReportServers
    data, total, resume = win32net.NetServerEnum(None, 1, serverTypes,
    resume)
    TypeError: The object can not be converted to a Unicode object
    Page 298, last paragraph - NetServerEnum(). The description of this function
    is missing the domain parameter. The correct signature is:

    entries, total, resume = win32net.NetServerEnum(server, level,
    serverTypes=win32netcon.SV_TYPE_ALL, domain=None, resume=0, len@96)

    So you want:

    def ReportServers():
    resume = 0
    serverTypes = win32netcon.SV_TYPE_ALL
    while 1:
    data, total, resume = win32net.NetServerEnum(None, 101,
    serverTypes,
    None, resume)
    for server in data:
    print data
    if resume == 0:
    break

    Cheers,
    Simon Brunning
    TriSystems Ltd.
    sbrunning at trisystems.co.uk




    -----------------------------------------------------------------------
    The information in this email is confidential and may be legally
    privileged.
    It is intended solely for the addressee. Access to this email by anyone else
    is unauthorised. If you are not the intended recipient, any disclosure,
    copying, distribution, or any action taken or omitted to be taken in
    reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
    accept liability for statements made which are clearly the senders own.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJan 21, '02 at 8:18a
activeJan 21, '02 at 3:13p
posts3
users2
websitepython.org

2 users in discussion

Jon R. Nials: 2 posts Simon Brunning: 1 post

People

Translate

site design / logo © 2022 Grokbase