Re: I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.
thx, "Ravi Teja" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > Does this require a ssh client or server? > > > > I use authpf to open up my PF firewall for internet use. Generally I just > > open up putty and make a connection to the FW ( which open the ports) and > > minize it till I am done. When I close putty authpf losses the ssh session > > heartbeat and will then instruct the FW to close the ports. I would love to > > write a simple client to do this form me instead of using putty. Do you > > think these mods would work for me on a windows platform? > > > > Thx > > Pexpect needs a POSIX system. However, you can use Cygwin. > > >From the website, "Pexpect does not currently work on the standard > Windows Python (see the pty requirement); however, it seems to work > fine using Cygwin." > -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading HowTo's in Windows platforms
Well, I guess you have sold me on this. I will wait till I have grown up to be a big and wise python (who is still employed) and all my growing (scripting) scares have healed properly or maybe even forgotten by my employers. Thx "Jezzz ... What could possible go wrong!" Signed, Mr. DoRight "Scott David Daniels" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jean-Paul Calderone wrote: > > On Sat, 01 Jul 2006 16:36:02 GMT, LittlePython <[EMAIL PROTECTED]> > > wrote: > >> I am looking for some good beginner how-to links and maybe some simple > >> example scripts that perform threading on windows platforms. Hopefully > >> authors who don't mind doing "a little spoon feeding" would be great > >> as I am a "baby python" who is very green with threading > > > > Threaded programming is extremely difficult. Most good newbie > > introductions to it consist of warnings not to use it. > > Just to expand on this reply -- even experts avoid threading unless > necessary. The real reason that everyone hates threading is that > wrong programs can run correctly, and errors cannot be reproduced. > Apparently, threaded programs have a "demo detector" that makes them > go wrong in the presence of anything more than a single vice president > (or major customer). > > So, the standard Python advice is to have each thread completely > independent (sharing no data), and communicating only with instances > of queue.Queue. That keeps the "demo detector" in check, because > you then have individually predictable (and hopefully testable) > parts with a logable communication pattern. You still may have > trouble (to which the best reply is, "See, we told you so."). > > --Scott David Daniels > [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading HowTo's in Windows platforms
Thx "Paul Rubin" <http://[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "LittlePython" <[EMAIL PROTECTED]> writes: > > I am looking for some good beginner how-to links and maybe some simple > > example scripts that perform threading on windows platforms. Hopefully > > authors who don't mind doing "a little spoon feeding" would be great as I am > > a "baby python" who is very green with threading.. > > Why don't you look in the Python Cookbook, either the paper edition > (O'Reilly) or the online one (aspn.activestate.com). -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading HowTo's in Windows platforms
I want to access the mailbox move methods and thread unto 4 moves at once. Currently I am access one move at a time via com but I would like to go a little deeper and start researching threading and the code that is behind the com. My use involves hundreds if not thousands of mailboxes over a short period of time(weeks or maybe a month or so). I could replicate threading I guess by launching multiply scripts on different modes but the logistics to this approach is error pronded for a user prospective. "Jean-Paul Calderone" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sat, 01 Jul 2006 16:36:02 GMT, LittlePython <[EMAIL PROTECTED]> wrote: > >I am looking for some good beginner how-to links and maybe some simple > >example scripts that perform threading on windows platforms. Hopefully > >authors who don't mind doing "a little spoon feeding" would be great as I am > >a "baby python" who is very green with threading.. > > Threaded programming is extremely difficult. Most good newbie introductions > to it consist of warnings not to use it. > > Do you have a particular application in mind? Perhaps someone can suggest > a more specific, simpler solution. > > Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.
Does this require a ssh client or server? I use authpf to open up my PF firewall for internet use. Generally I just open up putty and make a connection to the FW ( which open the ports) and minize it till I am done. When I close putty authpf losses the ssh session heartbeat and will then instruct the FW to close the ports. I would love to write a simple client to do this form me instead of using putty. Do you think these mods would work for me on a windows platform? Thx "Ravi Teja" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > gavino wrote: > > This seems easy but I have been asking tcl and python IRC chat all day > > and no one gave an answer. > > I have 100 servers which need a new backup server added to a text file, > > and then the backup agent restarted. > > If I have a list of the servers, all with same root password, and the > > connection is ssh. > > How do I connect to the server, cat the line to the config file, stop > > adn start the agent, and then do same to next server in list and > > iterate through the 100 servers. > > What script would allow this? > > Try pxssh from pexpect. Look at the sample in the page. > http://pexpect.sourceforge.net/pxssh.html > It will allow you to automate ssh interactions. > -- http://mail.python.org/mailman/listinfo/python-list
Threading HowTo's in Windows platforms
I am looking for some good beginner how-to links and maybe some simple example scripts that perform threading on windows platforms. Hopefully authors who don't mind doing "a little spoon feeding" would be great as I am a "baby python" who is very green with threading.. Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting binary sid's to a hex string
Thx Roger, I have been off line for a few days. I am sorry not to reply earlier. I will try this, but I am not sure what "buffer" does ( I am a newbie to python). "Roger Upole" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > You can use the binascii module to convert the raw > bytes of the sid to hex. > > binascii.b2a_hex(buffer(MySid)) > > Roger > > "LittlePython" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >I am trying to create a hexstring of a NT4 user account sid which I can in > > turn use to query an exchange 55 database. I believe I need to convert a > > binary sid to a hex string. ADsSID com object will do this for me however it > > is a little slow. Can anybody point me in the right direction to converting > > a PySID to a hexstring. > > Thx > > > > import win32netcon > > import win32net > > import win32security > > def report(): > >resume = 0 > >while 1: > >filter = win32netcon.FILTER_NORMAL_ACCOUNT > >data, total, resume = win32net.NetUserEnum('nt4pridc1', 20, filter, > > resume) > >for user in data: > > MySid, string, int = win32security.LookupAccountName('nt4pridc1', > > user['name']) > > sString = win32security.ConvertSidToStringSid(MySid) > > print MySid > > print sString > >if resume ==0: > >break > > > > report() > > ## sString prints = S-1-5-21-357043131-537017027-1947940980-1289 > > ## MySid prints = PySID:S-1-5-21-357043131-537017027-1947940980-1289 > > ## I need this , I believe this is a hex string of the SID > > ## 010500051500BB0B4815C33A022074381B740905 > > > > > > > > > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== > http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups > ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Converting binary sid's to a hex string
I am trying to create a hexstring of a NT4 user account sid which I can in turn use to query an exchange 55 database. I believe I need to convert a binary sid to a hex string. ADsSID com object will do this for me however it is a little slow. Can anybody point me in the right direction to converting a PySID to a hexstring. Thx import win32netcon import win32net import win32security def report(): resume = 0 while 1: filter = win32netcon.FILTER_NORMAL_ACCOUNT data, total, resume = win32net.NetUserEnum('nt4pridc1', 20, filter, resume) for user in data: MySid, string, int = win32security.LookupAccountName('nt4pridc1', user['name']) sString = win32security.ConvertSidToStringSid(MySid) print MySid print sString if resume ==0: break report() ## sString prints = S-1-5-21-357043131-537017027-1947940980-1289 ## MySid prints = PySID:S-1-5-21-357043131-537017027-1947940980-1289 ## I need this , I believe this is a hex string of the SID ## 010500051500BB0B4815C33A022074381B740905 -- http://mail.python.org/mailman/listinfo/python-list
Try/Except for ADSI GetObject
I am a little confused on why I can not detect an object that does not exist with a try and except. If I understand ADSI correctly from what I have read you do not create these objects but rather get them. They already exist. I believe if I do the equivalent in VB I would generate an error when I try to get an object that does not exist (can not find). What have I done wrong? I have included the function below that works in ever respect but detecting incorrect NT Domain Names (objects that do not exist) . Any tips, insight or comments would be welcome by this newbie. Thx def CheckNT4(header, all): adsi = win32com.client.Dispatch('ADsNameSpaces') try: nt = adsi.GetObject('', "WinNT://"+ frm.NTName) #->I need some type of try/except to detect incorrect NT Domain Names except: print "Domain name failed" # this does not detect a problem nt.Filter = ['user'] try: oSID = win32com.client.Dispatch('ADsSid') except: MyUsers = [ eauser for eauser in all if eauser[GetPostion(header, 'STATUS')] is ''] for ea in MyUsers: ea[GetPostion(header, 'STATUS')] = 'FailNT' ea[GetPostion(header, 'COMMENT')] ='Can not find ADsSid' MyUsers = [ eauser for eauser in all if eauser[GetPostion(header, 'STATUS')] is ''] intcnt = 0 for user in nt: for ea in MyUsers: if string.upper(user.Name) == string.upper(ea[GetPostion(header, 'OLDNTLOGON')]): frm.MyProgress.Update ( intcnt, 'Found NT user and SID : ' + user.Name ) intcnt = intcnt+ 1 if user.AccountDisabled: ea[GetPostion(header, 'STATUS')] = 'FailNT' ea[GetPostion(header, 'COMMENT')] ='Disabled' else: if ea[GetPostion(header, 'COMMENT')] is not '': ea[GetPostion(header, 'COMMENT')] = '' oSID.SetAs (5, "WinNT://"+ frm.NTName + '/' + user.Name) ea[GetPostion(header, 'STATUS')] = 'PassNT' ea[GetPostion(header, 'Nt4Sid')] = oSID.GetAs(1) for user in [ eauser for eauser in all if eauser[GetPostion(header, 'STATUS')] is '']: user[GetPostion(header, 'STATUS')] = 'FailNT' user[GetPostion(header, 'COMMENT')] = 'NoNt4Account' -- http://mail.python.org/mailman/listinfo/python-list
Re: Using a package like PyInstaller
Thx for the tip ... I'll give it a go "James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > "Im 99.999% confident that this will not happen from the .exe file > > generated by pyinstaller (unless you specify--see link above)." > > > > Well I guess that's about as close as any one can get in this business. I > > have been trying to introduce py into our environment, and have opened a few > > eyes, however I have been given one restriction. I can not install anything, > > leave behind anything or alter anything on a systems .. period, > > > You can always hard-code external resources. For example, first write a > script that makes a module out of one or several jpegs (assuming jpeg > extension is consitently 'jpg': > > import binascii > > def append_to_jpeg_module(modulename, jpegs): >myjpegs = open('%s.py' % modulename, 'wa') >for jpegname in jpegs: > afile = open('%s.jpg' % jpegname, 'rb') > ajpeg = afile.read() > afile.close() > jpegascii = binascii.b2a_base64(ajpeg) > print jpegascii > myjpegs.write('%s = """%s"""\n\n' % (jpegname, jpegascii)) >myjpegs.close() > > append_to_jpeg_module('myjpegs', ['logo_sm']) > > #heres how you use it > append_to_jpeg_module('myjpegs', ['coolpik1', 'coolpik2', 'anotherpik']) > > Now, in your file that needs the jpegs, you can pretend these strings > are files with the cStringIO module, e.g. (pretending 'modulename' above > is 'myjpegs'): > > import binascii > import myjpegs > import cStringIO > > def get_jpeg_as_opened_file(jpegname, module): >jpegascii = module.__dict__[jpegname] >jpegbin = binascii.a2b_base64(jpegascii) >return cStringIO.StringIO(jpegbin) > > # getting that pik > get_jpeg_as_opened_file('coolpik1', myjpegs) > > > And your company can go on making widgets feeling secure in the fact > that you have not required any extra entries in their file allocation > tables. > > James > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Using a package like PyInstaller
"Im 99.999% confident that this will not happen from the .exe file generated by pyinstaller (unless you specify--see link above)." Well I guess that's about as close as any one can get in this business. I have been trying to introduce py into our environment, and have opened a few eyes, however I have been given one restriction. I can not install anything, leave behind anything or alter anything on a systems .. period, and as the saying goes "To error is human but to forgive is not company policy!" thx for your comments! "James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > That is very close to what I have being doing, however I was unable to > > enclose a bmp or another file for that matter in the exe. I used both DATA > > and BINARY key words with no luck. I checked what was in the package and > > there were there. I guess for some reason it could not locate then when > > executed. I used snap 274 if I remember correctly. > > You can include files with innosetup under the [FILES] section. The docs > show how. You can then code absolute paths to these resources in your > code according to the results of 'sys.platform'. If you use the > "--onedir" option, then you may want to look here: > > http://pyinstaller.hpcf.upr.edu/docs/Manual_v1.1.html#accessing-data-files > > > > I am worrying that > > when the py script is run I am leaving behind files. That the components of > > my stand-alone exe is somehow coming out of the exe (PyInstaller) and being > > installed. > > Im 99.999% confident that this will not happen from the .exe file > generated by pyinstaller (unless you specify--see link above). > > However, innosetup will put files in the 'Program Files' directory or > wherever you specify. This would be similar to just about every other > application out there for windows. > > James > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Using a package like PyInstaller
That is very close to what I have being doing, however I was unable to enclose a bmp or another file for that matter in the exe. I used both DATA and BINARY key words with no luck. I checked what was in the package and there were there. I guess for some reason it could not locate then when executed. I used snap 274 if I remember correctly. I am not too sure I am explaining my question correctly though. I have not problem creating and distributing my python/wxpython scripts in exe (stand-a-lone) except for what I have described above. I am worrying that when the py script is run I am leaving behind files. That the components of my stand-alone exe is somehow coming out of the exe (PyInstaller) and being installed. My setup exe is not what's is bothering me although I do like the your suggestion and have just been tinkering with it. It is cool stuff and much better then what I have been using. Thx "James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > Thx for the tip. > > > > I am referring more to the use of PyInstaller or py2exe. Packages that > > create exe files that basically have your py script and a small py > > interpreter all rolled up into one. This way py does not need to be > > installed on a system to execute a py script. I am being advised that python > > is installed onto systems (windows) it should not be on. I am new to python > > and these types of packages and am not too sure how dumb a question this > > really is.. but can these packages bleed out files, dll, exe ect. to systems > > they are run on? > > They don't have to "bleed" anything. Everything, including the python > interpreter, and 3rd party libraries can be included in a single > executable. Here is an example script for pyinstaller that rolls > evertyhing into one file (this is what I use to roll up my passerby > program at passerby.souceforge.net): > > > setenv TEMP temp > > set pythonexe='c:/Python23-Enthought/python' > set pbydir='z:/Code/pby/current/' > > rm *.pyc > > rm -rf ./temp/ ./passerby/ > mkdir temp > > $pythonexe Configure.py > $pythonexe Makespec.py --onefile --tk --noconsole \ > --icon $pbydir/../icons/passerby.ico \ >$pbydir/passerby.py passerby/passerby.spec > $pythonexe Build.py passerby/passerby.spec > > > You can control installation with innosetup. > > James > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Using a package like PyInstaller
Thx for the tip. I am referring more to the use of PyInstaller or py2exe. Packages that create exe files that basically have your py script and a small py interpreter all rolled up into one. This way py does not need to be installed on a system to execute a py script. I am being advised that python is installed onto systems (windows) it should not be on. I am new to python and these types of packages and am not too sure how dumb a question this really is.. but can these packages bleed out files, dll, exe ect. to systems they are run on? "James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > Is it possible when using packages like PyInstaller to create an .exe for > > distribution that parts of the package can bleed out and be left on a system > > when the .exe is executed? > > > > Thx > > > > > > Look at innosetup. > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Using a package like PyInstaller
Is it possible when using packages like PyInstaller to create an .exe for distribution that parts of the package can bleed out and be left on a system when the .exe is executed? Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Seaching Active Directory via ADO
With help I have been able to put together a little example. It illustrates several different ways.. import win32com.client c = win32com.client.Dispatch("ADODB.Connection") c.Open("Provider=ADSDSOObject") ##Check if connected to AD if bool(c.state): print "Connected to AD" ## This uses sql dialect with no command object ##rs,rc=c.Execute(""" ##SELECT adspath, title, name ##From 'LDAP://DC=AD,DC=LOCAL' ##where objectCategory='Person' and objectClass='user' and name='*' ##""") ##This uses ADSI dialect with not command object ##rs,rc=c.Execute(""" ##;\ ##(&(objectCategory=Person)(objectClass=user)(name=*));\ ##name,adspath,title;\ ##subtree ##""") ##Command com with properties in sql dialect ##comm = win32com.client.Dispatch("ADODB.Command") ##comm.ActiveConnection = c ##comm.Properties('Page size').value=1000 ##comm.CommandText = ("""\ ##SELECT adspath, title, name \ ##From 'LDAP://DC=AD,DC=LOCAL' \ ##where objectCategory='Person' and objectClass='user' and name='*'\ ##""") ##rs,rc=comm.Execute() ##Command com with properties in ADSI dialect ##ADS_SCOPE_SUBTREE = 2 ##ADS_SCOPE_ONELEVEL = 1 ##ADS_SCOPE_BASE = 0 ##comm = win32com.client.Dispatch("ADODB.Command") ##comm.ActiveConnection = c ##comm.Properties('Page size').value=1000 ##comm.Properties('searchscope').value=ADS_SCOPE_SUBTREE ##comm.CommandText = (""";\ ##(&(objectCategory=Person)(objectClass=user)(name=*));\ ##name,adspath,title;""") ##rs,rc=comm.Execute() ##Connect using recordset object in ADSI Dialect ##rs = win32com.client.Dispatch("ADODB.recordset") ##rs.ActiveConnection = c ##rs.source = (""";\ ##(&(objectCategory=Person)(objectClass=user)(name=*));\ ##name,adspath,title;\ ##subtree""") ##rs.Open() ##Connect using recordset object in sql Dialect ##rs = win32com.client.Dispatch("ADODB.recordset") ##rs.ActiveConnection = c ##rs.source = ("""\ ##SELECT adspath, title, name \ ##From 'LDAP://DC=AD,DC=LOCAL' \ ##where objectCategory='Person' and objectClass='user' and name='*'\ ##""") ##rs.Open() ##while not rs.EOF: ##for f in rs.Fields: ##print f.Name, f.Value ##rs.MoveNext() c.close c = None -- http://mail.python.org/mailman/listinfo/python-list
Re: Seaching Active Directory via ADO
I notice there is no adodb.command. This is not required? Thx for the example! "Roger Upole" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Here's a short example that uses ADO to search for a > user by wildcard. > > import win32com.client > c = win32com.client.Dispatch("ADODB.Connection") > c.Open("Provider=ADSDSOObject") > > rs,rc=c.Execute(""" > SELECT adspath, title, name > From 'LDAP://DC=yourdomain, DC=COM' > where objectClass='user' and name='Roger*' > """) > > while not rs.EOF: > for f in rs.Fields: > print f.Name, f.Value > rs.MoveNext() > > hth > Roger > > "LittlePython" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Thanks but I was looking more for ADO com object than ADSI or ldap. > > For some strange reason it is very hard to locate any working scripts that > > use ADO to connect and search AD. Is there an issue with ADO and python > > when connecting to AD? > > I have try to build one myself with no luck. I think my problem is with > > adodb.command calls. > > > > Thanks for your response. > > > > "alex23" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Heya, > > > > > > There are a couple of examples on the O'Reilly site. These two are > > > taken from 'Active Directory Cookbook', the first uses a COM object > > > while the second uses a native LDAP module: > > > > > > > > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx > > t > > > > > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t > > xt > > > > > > This might give you a start. > > > > > > - alex23 > > > > > > > > > > > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups > = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Seaching Active Directory via ADO
Thanks but I was looking more for ADO com object than ADSI or ldap. For some strange reason it is very hard to locate any working scripts that use ADO to connect and search AD. Is there an issue with ADO and python when connecting to AD? I have try to build one myself with no luck. I think my problem is with adodb.command calls. Thanks for your response. "alex23" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Heya, > > There are a couple of examples on the O'Reilly site. These two are > taken from 'Active Directory Cookbook', the first uses a COM object > while the second uses a native LDAP module: > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx t > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t xt > > This might give you a start. > > - alex23 > -- http://mail.python.org/mailman/listinfo/python-list
Re: Seaching Active Directory via ADO
To be more clear, something like this example but in python. I have tryed to convert something very simular to this but have failed. -- SCRIPT CONFIGURATION -- strBase= ">;" strFilter = ";" strAttrs = ";" strScope = "" ' -- END CONFIGURATION - set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" set objComm = CreateObject("ADODB.Command") objComm.ActiveConnection = objConn objComm.Properties("Page Size") = 1000 objComm.CommandText = strBase & strFilter & strAttrs & strScope set objRS = objComm.Execute objRS.MoveFirst while Not objRS.EOF Wscript.Echo objRS.Fields(0).Value objRS.MoveNext wend "LittlePython" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I am have trouble finding a simple working example of using ADO to search > Active Directory. I am hoping someone could point me to a generic working > script that connects to AD and pulls up a recordset to help me get started > into the right direction in learning ADO, ADSI on Python. > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Seaching Active Directory via ADO
Never mind , I know what's wrong ... need to use the right account. It works great and is a great example .. thx "LittlePython" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do you know what this may mean? > > C:\Documents and Settings\Administrator\Desktop\pytest>ADOSeach.py > Traceback (most recent call last): > File "C:\Documents and Settings\Administrator\Desktop\pytest\ADOSeach.py", > lin > e 6, in ? > rs,rc=c.Execute(""" > File "", line 3, in Execute > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 258, > in > _ApplyTypes_ > result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, > argTypes > ) + args) > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Provider', > 'Tabl > e does not exist.', None, 1240640, -2147217865), None) > > C:\Documents and Settings\Administrator\Desktop\pytest> > "Roger Upole" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > You could also accomplish the same thing using the > > Command object, but this way is usually more concise > > for plain Sql. > > > > Roger > > > > "LittlePython" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I notice there is no adodb.command. This is not required? > > > Thx for the example! > > > "Roger Upole" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > Here's a short example that uses ADO to search for a > > > > user by wildcard. > > > > > > > > import win32com.client > > > > c = win32com.client.Dispatch("ADODB.Connection") > > > > c.Open("Provider=ADSDSOObject") > > > > > > > > rs,rc=c.Execute(""" > > > > SELECT adspath, title, name > > > > From 'LDAP://DC=yourdomain, DC=COM' > > > > where objectClass='user' and name='Roger*' > > > > """) > > > > > > > > while not rs.EOF: > > > > for f in rs.Fields: > > > > print f.Name, f.Value > > > > rs.MoveNext() > > > > > > > > hth > > > > Roger > > > > > > > > "LittlePython" <[EMAIL PROTECTED]> wrote in message > > > > news:[EMAIL PROTECTED] > > > > > Thanks but I was looking more for ADO com object than ADSI or ldap. > > > > > For some strange reason it is very hard to locate any working > scripts > > > that > > > > > use ADO to connect and search AD. Is there an issue with ADO and > > python > > > > > when connecting to AD? > > > > > I have try to build one myself with no luck. I think my problem is > > with > > > > > adodb.command calls. > > > > > > > > > > Thanks for your response. > > > > > > > > > > "alex23" <[EMAIL PROTECTED]> wrote in message > > > > > news:[EMAIL PROTECTED] > > > > > > Heya, > > > > > > > > > > > > There are a couple of examples on the O'Reilly site. These two are > > > > > > taken from 'Active Directory Cookbook', the first uses a COM > object > > > > > > while the second uses a native LDAP module: > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx > > > > > t > > > > > > > > > > > > > > > > > > > > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t > > > > > xt > > > > > > > > > > > > This might give you a start. > > > > > > > > > > > > - alex23 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet > > > News== > > > > http://www.newsfeeds.com The #1 Newsgroup Service in the World! > 120,000+ > > > Newsgroups > > > > = East and West-Coast Server Farms - Total Privacy via Encryption > > > = > > > > > > > > > > > > > > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet > News== > > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ > Newsgroups > > = East and West-Coast Server Farms - Total Privacy via Encryption > = > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Seaching Active Directory via ADO
Do you know what this may mean? C:\Documents and Settings\Administrator\Desktop\pytest>ADOSeach.py Traceback (most recent call last): File "C:\Documents and Settings\Administrator\Desktop\pytest\ADOSeach.py", lin e 6, in ? rs,rc=c.Execute(""" File "", line 3, in Execute File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 258, in _ApplyTypes_ result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes ) + args) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Provider', 'Tabl e does not exist.', None, 1240640, -2147217865), None) C:\Documents and Settings\Administrator\Desktop\pytest> "Roger Upole" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > You could also accomplish the same thing using the > Command object, but this way is usually more concise > for plain Sql. > > Roger > > "LittlePython" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I notice there is no adodb.command. This is not required? > > Thx for the example! > > "Roger Upole" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Here's a short example that uses ADO to search for a > > > user by wildcard. > > > > > > import win32com.client > > > c = win32com.client.Dispatch("ADODB.Connection") > > > c.Open("Provider=ADSDSOObject") > > > > > > rs,rc=c.Execute(""" > > > SELECT adspath, title, name > > > From 'LDAP://DC=yourdomain, DC=COM' > > > where objectClass='user' and name='Roger*' > > > """) > > > > > > while not rs.EOF: > > > for f in rs.Fields: > > > print f.Name, f.Value > > > rs.MoveNext() > > > > > > hth > > > Roger > > > > > > "LittlePython" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > Thanks but I was looking more for ADO com object than ADSI or ldap. > > > > For some strange reason it is very hard to locate any working scripts > > that > > > > use ADO to connect and search AD. Is there an issue with ADO and > python > > > > when connecting to AD? > > > > I have try to build one myself with no luck. I think my problem is > with > > > > adodb.command calls. > > > > > > > > Thanks for your response. > > > > > > > > "alex23" <[EMAIL PROTECTED]> wrote in message > > > > news:[EMAIL PROTECTED] > > > > > Heya, > > > > > > > > > > There are a couple of examples on the O'Reilly site. These two are > > > > > taken from 'Active Directory Cookbook', the first uses a COM object > > > > > while the second uses a native LDAP module: > > > > > > > > > > > > > > > > > > > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx > > > > t > > > > > > > > > > > > > > > http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t > > > > xt > > > > > > > > > > This might give you a start. > > > > > > > > > > - alex23 > > > > > > > > > > > > > > > > > > > > > > > > > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet > > News== > > > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ > > Newsgroups > > > = East and West-Coast Server Farms - Total Privacy via Encryption > > = > > > > > > > > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups > = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Seaching Active Directory via ADO
I am have trouble finding a simple working example of using ADO to search Active Directory. I am hoping someone could point me to a generic working script that connects to AD and pulls up a recordset to help me get started into the right direction in learning ADO, ADSI on Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to cat None
Thx , I will give this a try. <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Seems that what you want to do is to create a string in the form of : > > "55Init=Init\n55First=first\n55Last=Last\n55Alias=None" > > for each dictionary. If that is the case, may be you can try this : > > "\n".join("%s=%s" % x for x in user1.iteritems()) > > Note that you cannot control the ordering of the keys when iterating a > dict which may or may not be a concern for you. > > LittlePython wrote: > > I found out the hard way that I can not cat None. I get an error. Is there a > > simple way to cat None without doing some kind of equation ( if this then > > that). Is there a isNone() somewhere. I am not too sure I know what None > > really means. > > > > I include an example to show what I am talking about in case I am alittle > > confused. > > > > > > > > > > from easygui import * > > import string > > > > msgbox('Starting Program') > > > > thisfile = fileopenbox(msg='Choose the correct File', title='Matrix Input > > File') > > input = file(thisfile,'r') > > > > header = string.split(string.strip(input.readline()),',') > > header.extend(['55FirstName', > > '55Intial','55LastName','55Alias',]) > > > > all = input.readlines() > > input.close > > input = None > > matrix = {} > > for user in all: > > user1 = string.split(string.strip(user),',') > > user1.extend(['None']*4)<-I would like to > > None or better NULL this instead of string it > > user1 = dict(zip(header,user1)) > > matrix[user1['OldNTLogon']] = user1 > > > > mychoice = choicebox(choices=matrix.keys()) > > user1 = matrix[mychoice] > > > > alltogether = '' > > > > for KeyName in user1.keys(): > > if alltogether == '': > > alltogether = KeyName + '=' + ' ' + user1.get(KeyName) + '\n' > > else: > > alltogether = alltogether + KeyName + '=' + user1.get(KeyName) + > > '\n' <--- error 'can not cat None with a str' or something like that > > > > msgbox(alltogether,'User Matrix for '+ mychoice ) > > > > msgbox('The End') > -- http://mail.python.org/mailman/listinfo/python-list
How to cat None
I found out the hard way that I can not cat None. I get an error. Is there a simple way to cat None without doing some kind of equation ( if this then that). Is there a isNone() somewhere. I am not too sure I know what None really means. I include an example to show what I am talking about in case I am alittle confused. from easygui import * import string msgbox('Starting Program') thisfile = fileopenbox(msg='Choose the correct File', title='Matrix Input File') input = file(thisfile,'r') header = string.split(string.strip(input.readline()),',') header.extend(['55FirstName', '55Intial','55LastName','55Alias',]) all = input.readlines() input.close input = None matrix = {} for user in all: user1 = string.split(string.strip(user),',') user1.extend(['None']*4)<-I would like to None or better NULL this instead of string it user1 = dict(zip(header,user1)) matrix[user1['OldNTLogon']] = user1 mychoice = choicebox(choices=matrix.keys()) user1 = matrix[mychoice] alltogether = '' for KeyName in user1.keys(): if alltogether == '': alltogether = KeyName + '=' + ' ' + user1.get(KeyName) + '\n' else: alltogether = alltogether + KeyName + '=' + user1.get(KeyName) + '\n' <--- error 'can not cat None with a str' or something like that msgbox(alltogether,'User Matrix for '+ mychoice ) msgbox('The End') -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
I have no idea what top-posting or bottom-posting is? "Felipe Almeida Lessa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Em Qua, 2006-02-15 às 00:30 +, LittlePython escreveu: > > I really do not wish to limit myself to MS. My bread and butter is MS but I > > am a BSD fan at heart. I wanted to learn something I can use in both. > > Please start by not top-posting ;-). Also, see > http://www.mono-project.com/VisualBasic.NET_support . > > -- > "Quem excele em empregar a força militar subjulga os exércitos dos > outros povos sem travar batalha, toma cidades fortificadas dos outros > povos sem as atacar e destrói os estados dos outros povos sem lutas > prolongadas. Deve lutar sob o Céu com o propósito primordial da > 'preservação'. Desse modo suas armas não se embotarão, e os ganhos > poderão ser preservados. Essa é a estratégia para planejar ofensivas." > > -- Sun Tzu, em "A arte da guerra" > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivilant to msgbox()
I am glad you did remind me of WScript.Shell ... I have to keep in mind that most if not all of what I have been using in VBS is avail to me. Thx "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > I am no VB programmer just dabble in vbscripting abit. The only one I am > > aware of is the popup as self closing. I never thought of using com. > Ok, so my remarks about COM were not for you. > > > > Do you know of any thing for a busy box in the same vain as easygui > No, I don't, but it doesn't mean, that there is none considering myriads > of various available COM components. My idea was to make you aware, that > you can use your VB compiler for creating any ActiveX/COM components for > usage with Python the way I have described, but as you write it seems > not to be an option for you. > > So I have to admit, that EasyGUI is in your case apparently > >>> exactly what you was looking for ... > > :-) > > Claudio > > > > > > "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>LittlePython wrote: > >> > >>>That is exactly what I was look for .. thx > >> > >>Surprised to hear that. > >> > >>As VisualBasic programmer I would expect you to have experience with > >>ActiveX on Windows, where the best way to go with Python is to reuse all > >>the ActiveX components and their known user interfaces (i.e. constants > >>to use as parameter and constants for interpretation of return values) > >>directly from within Python. > >> > >>A message box goes e.g. this way: > >> > >> >>> import win32com.client > >> >>> axWshShell = win32com.client.Dispatch("WScript.Shell") > >> >>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself > >>after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1) > >> > >>By the way: is there a ready for direct use timed self closing Ok/Cancel > >>message box in any of the proposed GUI packages? > >> > >>Claudio > >> > >>> > >>>"Kent Johnson" <[EMAIL PROTECTED]> wrote in message > >>>news:[EMAIL PROTECTED] > >>> > >>> > >>>>LittlePython wrote: > >>>> > >>>> > >>>>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I > >>>>>would like to call this instead of print (to the screen) . I would like > >>>>>to write a simple script that is not an event drive gui but calls input > >>>>>boxes, message boxes, or maybe even a file open browser box as well? > >>>> > >>>>Take a look at EasyGUI: > >>>>http://www.ferg.org/easygui/ > >>>> > >>>>Kent > >>> > >>> > >>> > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
I really do not wish to limit myself to MS. My bread and butter is MS but I am a BSD fan at heart. I wanted to learn something I can use in both. I thought about Perl first but I feel the learning curve is to steep (to get it right), it seems easier to make a mistake in Perl and not catch it. Python just feels right and fits me better. ... Well what do I know ... you make you pick and take your chances. <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > LittlePython wrote: > > I am very new to python. I have been studying it for only a month or so. I > > have been using vbscript for about 2-3 yrs and only recently been using it > > rather heavily the past 9 months or so. I am new very new to oop. My main > > use will be administrative scripting into the win3k, XP, AD domain, > > 55exchange and 2003exchange environments. I like to incorp wxpython (GUI) > > into my scripts instead of HTA's that I have been using with VBS. I am also > > finding myself being tasked with jobs that are outside the scope of VBS. > > Well that's a lot to learn and I have a feeling that to many I am just > > another member of "The Ministry of STUPID Questions" > > > Out of curiosity, why python ? The new VB.Net seems to be a very > interesting one language wise and given that you have a VB experience, > it seems to be a natural one to try. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivilant to msgbox()
I am no VB programmer just dabble in vbscripting abit. The only one I am aware of is the popup as self closing. I never thought of using com. Do you know of any thing for a busy box in the same vain as easygui "Claudio Grondi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > That is exactly what I was look for .. thx > Surprised to hear that. > > As VisualBasic programmer I would expect you to have experience with > ActiveX on Windows, where the best way to go with Python is to reuse all > the ActiveX components and their known user interfaces (i.e. constants > to use as parameter and constants for interpretation of return values) > directly from within Python. > > A message box goes e.g. this way: > > >>> import win32com.client > >>> axWshShell = win32com.client.Dispatch("WScript.Shell") > >>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself > after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1) > > By the way: is there a ready for direct use timed self closing Ok/Cancel > message box in any of the proposed GUI packages? > > Claudio > > > > > > "Kent Johnson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>LittlePython wrote: > >> > >>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I > >>>would like to call this instead of print (to the screen) . I would like > >>>to write a simple script that is not an event drive gui but calls input > >>>boxes, message boxes, or maybe even a file open browser box as well? > >> > >>Take a look at EasyGUI: > >>http://www.ferg.org/easygui/ > >> > >>Kent > > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivilant to msgbox()
That is exactly what I was look for .. thx "Kent Johnson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython wrote: > > Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I > > would like to call this instead of print (to the screen) . I would like > > to write a simple script that is not an event drive gui but calls input > > boxes, message boxes, or maybe even a file open browser box as well? > > Take a look at EasyGUI: > http://www.ferg.org/easygui/ > > Kent -- http://mail.python.org/mailman/listinfo/python-list
Python equivilant to msgbox()
Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I would like to call this instead of print (to the screen) . I would like to write a simple script that is not an event drive gui but calls input boxes, message boxes, or maybe even a file open browser box as well? -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
I am very new to python. I have been studying it for only a month or so. I have been using vbscript for about 2-3 yrs and only recently been using it rather heavily the past 9 months or so. I am new very new to oop. My main use will be administrative scripting into the win3k, XP, AD domain, 55exchange and 2003exchange environments. I like to incorp wxpython (GUI) into my scripts instead of HTA's that I have been using with VBS. I am also finding myself being tasked with jobs that are outside the scope of VBS. Well that's a lot to learn and I have a feeling that to many I am just another member of "The Ministry of STUPID Questions" "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython a écrit : > > Is this a good place to post python questions from newbie's, or would you > > suggest another board? > > Well, depends on how newbie you are, both to Python and to programming, > but yes, this is at least a good place to start. You may find that most > other newsgroups are probably not the best places to post > python-specific questions anyway !-) > > We usually don't eat newbies for lunch so, in the worst case, you might > be redirected to the python-tutor mailing-list (for ubernewbies) or the > Fine Manual (that you are of course actively reading right now, isn't it > ?) when appropriate. > > > Thx > > You're welcome. > > Another question ?-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
"Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > LittlePython a écrit : > > Is this a good place to post python questions from newbie's, or would you > > suggest another board? > > Well, depends on how newbie you are, both to Python and to programming, > but yes, this is at least a good place to start. You may find that most > other newsgroups are probably not the best places to post > python-specific questions anyway !-) > > We usually don't eat newbies for lunch so, in the worst case, you might > be redirected to the python-tutor mailing-list (for ubernewbies) or the > Fine Manual (that you are of course actively reading right now, isn't it > ?) when appropriate. > > > Thx > > You're welcome. > > Another question ?-) -- http://mail.python.org/mailman/listinfo/python-list
Newbie
Is this a good place to post python questions from newbie's, or would you suggest another board? Thx -- http://mail.python.org/mailman/listinfo/python-list