Re: Create a list of dates for same day of week in a year
> Thoughts or examples? > dateutil.rrule is what you may use e.g. In [38]: from dateutil import rrule In [39]: from datetime import date In [40]: end = date(2017, 12, 31) In [41]: rr = rrule.rrule(rrule.WEEKLY, byweekday=[0, 2], until=end) In [42]: days = list(rr) In [43]: len(days) Out[43]: 53 In [44]: days[:5], days[-5:] Out[44]: ([datetime.datetime(2017, 6, 28, 23, 58, 11), datetime.datetime(2017, 7, 3, 23, 58, 11), datetime.datetime(2017, 7, 5, 23, 58, 11), datetime.datetime(2017, 7, 10, 23, 58, 11), datetime.datetime(2017, 7, 12, 23, 58, 11)], [datetime.datetime(2017, 12, 13, 23, 58, 11), datetime.datetime(2017, 12, 18, 23, 58, 11), datetime.datetime(2017, 12, 20, 23, 58, 11), datetime.datetime(2017, 12, 25, 23, 58, 11), datetime.datetime(2017, 12, 27, 23, 58, 11)]) In [45]: -- https://mail.python.org/mailman/listinfo/python-list
Re: [wanted] python-ldap for Python 2.3 / Win32
I did try to build it using my current setup but it failed with some linking errors. Oh well. Google gods were nicer to me. Here is a couple alternative links. Maybe they will work for you. http://web.archive.org/web/20081101060042/http://www.agescibs.org/mauro/ http://old.zope.org/Members/volkerw/LdapWin32/ Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Deploying on Windows servers : advice sought a module
At my work place I still use py2exe but I do not rely on its automatic discovery and packaging. The setup.py lists all the dependencies explicitly in packages and includes parameters. These end up in library.zip. Then the source file paths with the actual business logic are gathered with os.walk and passed in as data_files parameter. Finally the actual service executable is generated from the very minimal script. This executable is registered only once and as long as you do not move it to a different directory Windows will find it and start it up for you. The service script that gets used by py2exe is truly minimal. It just changes working directory to where the executable sits, adds current directory to the sys.path and loads the main script. The main script would be copied by setup.py into the current working directory. When there is a new release I update the files with business logic and restart the service. When I want to update the dependent libraries I regenerate library.zip, copy it over and again restart the service. The trick is to let the files from the current directory to be imported first. To achieve it you should avoid putting your business logic files into your library.zip. py2exe will do it if you let it to. Depending on situation I go to into dirty tricks like selectively commenting out import statements before running py2exe or even post-processing library.zip and deleting the business logic files from the archive. With a little bit of care you can make it work but I admit my approach is not very clean. Oh another trick I have learned. If your service does not start because let's say an import has failed look into Event Viewer/Application. There should be an entry with a nice traceback listing what went wrong. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Making Line Graphs
Standard answer in such a case is matplotlib http://matplotlib.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Unix-head needs to Windows-ize his Python script
On Oct 20, 11:38 am, gb345 gb...@invalid.com wrote: I have a handy Python script, which takes a few command-line arguments, and accepts a few options. I developed it on Unix, with very much of a Unix-mindset. Some Windows-using colleagues have asked me to make the script easy to use under Windows 7. I.e.: no command-line. Therefore, I want to adapt my script, with the minimum amount of work, so that it can have a double-clickable icon that brings up a small GUI to accept command-line options (including a couple of file-selectors for input and output files). I am Windows-illiterate, so I really would like to keep this as barebones as possible. Where should I look to learn more about how to do this? Thx! --G (P.S. in case it matters, it's OK to assume that Python will be installed on the Windows system; IOW, the script need not bring with it a Python interpreter and libraries.) Teach them Windows key - Run - cmd or very useful Open Command Window Here right click option. http://www.downloadsquad.com/2009/02/09/windows-7-tip-elevated-command-prompt-anywhere/ Failing that you may try EasyDialogs http://www.doughellmann.com/PyMOTW/EasyDialogs/index.html The build in module is Mac only. The Windows version is available here. http://www.averdevelopment.com/python/EasyDialogs.html Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe and msvcp90.dll
On Apr 14, 10:19 pm, Alex Hall mehg...@gmail.com wrote: Hi all, I am still fighting with py2exe; I keep getting error: msvcp90.dll: no such file or directory right after it says it is searching for required dlls. I have followed the py2exe tutorial, though, and I am not sure why it is not finding the dlls, which are in both c:\windows\system32 and in mainFolder/dlls, where mainFolder is the main folder of my project, containing setup.py. Here is my setup file: from distutils.core import setup import py2exe from glob import glob data_files=[(Microsoft.VC90.CRT, glob(r'c:\arm\dlls\*.*'))] setup(data_files=data_files, console=['main.pyw']) Of course, the location to glob is hard-coded. Also, I do not intend this to have any console. Can I just omit the console argument? I leave it in for now since the tutorial seems to indicate that such a file is necessary, but I do not want to have one eventually. Thanks in advance, as always! Oh, the entire source is athttp://www.gateway2somewhere.com/sw/sw.zip as it usually is (and this time, I tested the link!). -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;http://www.facebook.com/mehgcap Did you see http://www.py2exe.org/index.cgi/Tutorial#Step52 ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Use python and Jython together? (newbie)
On Mar 13, 8:10 am, Christian Heimes li...@cheimes.de wrote: Karjer Jdfjdf wrote: I'm pretty new at programming and want some advice on mixing Jython and Python. I want to use Jython to access some Java libraries, but I want to keep developing in normal Python. Some modules I use a lot are not available in Jython. The bulk of my programming is in Python but I want to use Java 2D libraries for graphical presentation of data generated in normal Python. Is it possible that I generate data in Python and then pass it through to a Jython program to visualise the data. You can't mix Jython and Python in one program. But you can use other means to create bindings for Java code. JCC (http://pypi.python.org/pypi/JCC/2.5.1) is a very powerful code generator for CPython. I have not tried it myself but it seems to be possible. http://jpype.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAP 1.2 Python client ?
On Mar 3, 9:32 am, BlueBird p...@freehackers.org wrote: Hi, I am looking for a SOAP 1.2 python client. To my surprise, it seems that this does not exist. Does anybody know about this ? The following clients seem to be both unmaintained and still supporting only SOAP 1.1 : - SUDS suds unmaintained? I beg to differ. - zsi - SOAPy cheers, Philippe -- http://mail.python.org/mailman/listinfo/python-list
Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?
On Dec 30, 10:05 am, kakarukeys kakaruk...@gmail.com wrote: I tried on a fresh XP on VM. I moved all dlls in C:\WINDOWS\WinSxS which are in the file handles shown by Process Explorer including the 3 CRT dlls to the my dist folder and the two subfolders suggested byhttp://wiki.wxpython.org/py2exe. It didn't work out. My app couldn't start. Windows XP gave a cryptic error asking me to reinstall the app. After installing vcredist_x86.exe, my app starts fine. There isn't a choice here. You HAVE TO bundle vcredist_x86.exe with your installer and convince your customers that it is necessary to increase the file size by 2MB. If anyone figure out how to do ashttp://wiki.wxpython.org/py2exe, or on a Python compiled with a free GNU compiler, avoiding all these BS. I will pay him/her $10. I have a method that does not involve installing the runtime and still works on a virgin machine. The target machines are locked desktops and installing anything on them equals to a 2 month long approval process. The Preventer of IT strikes again :) But anyway, the method involves editing python26.dll in order to remove dependency references and then dropping msvcr90.dll in the same directory as the py2exe produced executable. Here is dir /b: lib/ msvcr90.dll python26.dll -- tweaked UI.exe The method works with a program using wxPython. I have used Resource Hacker http://www.angusj.com/resourcehacker/ for actual editing. You have to find dependency section of the manifest and remove everything between dependentAssembly tags Before: dependency dependentAssembly assemblyIdentity type=win32 name=Microsoft.VC90.CRT version=9.0.21022.8 processorArchitecture=x86 publicKeyToken=1fc8b3b9a1e18e3b/assemblyIdentity /dependentAssembly /dependency After: dependency dependentAssembly /dependentAssembly /dependency Is the method elegant? Nope. Does it work? It does for me. Use it at your own risk etc. The regular disclaimers apply. The approach was gleaned from a thread at PIL mailing list. http://mail.python.org/pipermail/image-sig/2009-October/005916.html waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Python WSDL Support
On Jun 16, 12:24 pm, Chris chriss...@gmail.com wrote: Is there any modern support for WSDL? The only projects I could find are ZSI and SOAPpy, and both have been dead for several years. https://fedorahosted.org/suds/ is actively maintained -- http://mail.python.org/mailman/listinfo/python-list
Re: twisted and py2exe
On Oct 16, 11:47 am, Linnorm [EMAIL PROTECTED] wrote: I've written an app using twisted to create an ssh forwarding tunnel for our erp app. When I run it with the interpreter it works perfectly, but when I package it up with py2exe it looks like the tunnel never gets created. I don't get any exceptions during the build, but I do get the following: The following modules appear to be missing ['Crypto.PublicKey._fastmath', 'Crypto.Util.winrandom', 'FCNTL', 'IronPythonConsole', 'OpenSSL', 'System', 'System.Windows.Forms.Clipboard', 'clr', 'email.Generator', 'email.Iterators', 'email.Utils', 'gmpy', 'modes.editingmodes', 'pkg_resources', 'resource', 'startup'] These can be probably ignored. I've tried including all of these at the command line, but all that seems to do is increase the exe size. Also, this file (_zope_interface_coptimizations.pyd) appears on the Yup, you need this one. There should be more *.pyd files. Usually they end up in the same directory as the executable. I always specify zipfile = lib/library.zip parameter in my setup.py This way all the dll end up neatly copied into lib/ sub folder. list of libraries that may need to be distributed with the app. I verified that that it is in the library.zip file and I've also tried copying it to the app directory and C:\Windows\system32. Am I missing something? I've searched Google but can't find anything relevant. Look for message from your Twisted service in Event Viewer- Application If some of your imports fail that is where trace would end up. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a SOAP module that can do this...?
On Sep 11, 3:50 am, thebjorn [EMAIL PROTECTED] wrote: On Sep 10, 9:44 pm, Waldemar Osuch [EMAIL PROTECTED] wrote: On Sep 10, 1:23 pm, thebjorn [EMAIL PROTECTED] wrote: I've been trying to use SOAPpy and ZSI (with and without the use of wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic server(?) in front of some enterprise java bean) and not having much luck. I got them to send me an example of what the bytes on the wire are supposed to look like (attached below), and I got it to work by going lo-tech: If you are willing to go low tech you can tryhttp://effbot.org/downloads/#elementsoap But before you do that try:https://fedorahosted.org/suds It is actively maintained and holds a lot of promise. In my testing it knew how to connect to Sharepoint as well as WebLogic exposed services. Waldemar Thanks for the info Waldemar. I'm looking into suds now, but there's something I'm having trouble wrapping my head around (xml isn't my usual territory, so this is perhaps obvious to someone...) This is what suds tells me: print client suds ( version=0.2.9 ) service ( InboundLegacyDataService ) prefixes: ns0 = http://no/brreg/BReMS/WebService/services; methods (2): getInfo() submitMessage(xs:string cpaid, xs:string securityKey, xs:string message, ) types (4): submitMessage submitMessageResponse getInfo getInfoResponse The method I'm interested in is submitMessage and in particular the ``xs:string message`` parameter. I've been provided with three xsd files that I'm almost 100% sure defines the format of the xml in the message (it defines the JegerproveInn sub-structure), but it looks like that has to be wrapped in a SOAP:Envelope, including the ?xml.. declaration before being stuffed into the xs:string message parameter, before that in turn is wrapped in an env:Envelope... Am I on the right track? After you figure out how the message should look like, pass it with the rest of the parameters to the submitMessage. suds should take care of the rest. Like wrap everything into Envelope, send the request and parse response. If you have to build XML from python let me point you to very useful http://svn.effbot.python-hosting.com/stuff/sandbox/elementlib/builder.py or http://codespeak.net/lxml/api/lxml.builder.ElementMaker-class.html Another question: I'm assuming the xsd files can be used for more than documentation :-) I've found the w3schools Introduction to XML Schema which I'm starting to read right now, however I haven't been able to google up any Python-xsd thingy that looked promising (since I'm not sure what I'm looking for, this might not be a big surprise ;-) Is there such a thingy? python-xsd thingy you mention could be lxml library that is an implementation of ElementTree + number of very useful extensions. Most of the time XSD is used to validate XML documents. http://codespeak.net/lxml/validation.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a SOAP module that can do this...?
On Sep 10, 1:23 pm, thebjorn [EMAIL PROTECTED] wrote: I've been trying to use SOAPpy and ZSI (with and without the use of wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic server(?) in front of some enterprise java bean) and not having much luck. I got them to send me an example of what the bytes on the wire are supposed to look like (attached below), and I got it to work by going lo-tech: If you are willing to go low tech you can try http://effbot.org/downloads/#elementsoap But before you do that try: https://fedorahosted.org/suds It is actively maintained and holds a lot of promise. In my testing it knew how to connect to Sharepoint as well as WebLogic exposed services. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Sending e-mail
On Aug 28, 12:52 pm, [EMAIL PROTECTED] wrote: I work at a training center and I would like to use Python to generate a number of certificates and then e-mail them. The certificates are a problem for another day - right now I just want to figure out how to send an e-mail. I confess I don't know much about the protocol(s) for e-mail. In PHP using CodeIgniter, the same task was amazingly easy. I think this is a bit harder because I'm not executing code on a remote machine that has its own SMTP server. According to (http://www.devshed.com/c/a/Python/ Python-Email-Libraries-SMTP-and-Email-Parsing/), I need to use the SMTP object found in the smtplib module to initiate a connection to a server before I can send. I want to use Gmail, but on the following input it stalls and then raises smtplib.SMTPServerDisconnected: server = SMTP(smtp.gmail.com) I also pinged smtp.gmail.com and tried it with the dotted quad IP as a string. Am I on the right track? Is this a problem with gmail, or have I gotten an assumption wrong? Here's a thought: Could I use SMTPServer (http://docs.python.org/lib/ node620.html) to obviate the need to have anything to do with Gmail? What would be the limitations on that? Could I successfully do this and wrap the whole thing up in a black box? What modules would I need? Thanks. Gmail SMTP server needs authentication. I little googling found this example. I did not test it if it works but it could be starting point. http://codecomments.wordpress.com/2008/01/04/python-gmail-smtp-example/ -- http://mail.python.org/mailman/listinfo/python-list
Re: regex search loops instead of findall
On Aug 5, 12:06 pm, brad [EMAIL PROTECTED] wrote: Hi guys... I'm trying to make my Python regex code behave like my C++ regex code. In order to search large strings for *all* occurrences of the thing I'm searching for, I loop like this in C++: void number_search(const std::string portion, const boost::regex Numbers) { boost::smatch matches; std::string::const_iterator Start = portion.begin(); std::string::const_iterator End = portion.end(); while (boost::regex_search(Start, End, matches, Numbers)) { std::cout matches.str() std::endl; Start = matches[0].second; } } I cannot figure out how to do the same in Python. I've read several Py regex docs, but none of them go into examples of this, although search seems that it should be able to loop on position according to the docs. I've resorted to using find_all in python, but that has limitations (especially when searching for groups) and seems to be a lot less efficient than search. Any suggestions or example code I can look at? I've read these:http://www.amk.ca/python/howto/regexhttp://docs.python.org/lib/module-re.html Thanks. re.finditer may help. http://docs.python.org/lib/node46.html -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX XML Parse Python error message
On Jul 13, 3:00 pm, goldtech [EMAIL PROTECTED] wrote: I would be grateful for support with the code I cited. It's not long and fairly standard. I'm sure my error(s) would be glaring to more experienced coders. I appreciated the heads-up about other options but I would be grateful for help getting this code to run. Thanks Initialize self.coodinates in the __init__ or indent the print self.description, str(self.coordinates) one more level. You have to remember that endElement is being called on the end of every element. In your case it is called by /description but the parser did not see coordinates yet. In def characters you should be collecting the ch in a buffer. It may be called multiple times for the same element. Something like self.description += ch would do for starters. Also you do not need to convert self.coordinates to string before printing, it is already a string and even if it was not print would convert it for you. That's it for now :-) Others may spot more issues with your code or my response. On the positive side I really liked how you asked the question. There was a short runnable example and traceback. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: ISO dict = xml converter
On Jun 20, 6:37 am, kj [EMAIL PROTECTED] wrote: Hi. Does anyone know of a module that will take a suitable Python dictionary and return the corresponding XML structure? In Perl I use XML::Simple's handy XMLout function: use XML::Simple 'XMLout'; my %h = ( 'Foo' = +{ 'Bar' = +{ 'Baz' = [ { 'meenie' = 3 }, { 'meenie' = 7 } ], 'eenie' = 4, }, 'minie' = 1, 'moe' = 2, } ); print XMLout( \%h, KeepRoot = 1, KeyAttr = undef ); __END__ Foo minie=1 moe=2 Bar eenie=4 Baz meenie=3 / Baz meenie=7 / /Bar /Foo Is there a Python module that can do a similar conversion from a Python dict to an XML string? (FWIW, I'm familiar with xml.marshal.generic.dumps, but it does not produce an output anywhere similar to the one illustrated above.) What about - import lxml.etree as ET from lxml.builder import E h = E.Foo( dict(minie='1', moe='2'), E.Bar( dict(eenie='4'), E.Baz(meenie='3'), E.Baz(meenie='7'))) print ET.tostring(h, pretty_print=True) Foo moe=2 minie=1 Bar eenie=4 Baz meenie=3/ Baz meenie=7/ /Bar /Foo --- Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAP/ZSI post/get for Java Web App
On May 13, 1:02 pm, Jennifer Duerr [EMAIL PROTECTED] wrote: All, I need help concerning SOAP, Python and XML. I am very new to this, so dumbing it down for me will not offend me! I'm using Python and want to send a user-inputted string to an existing Java web app that will output results to XML. I need to capture elements of the XML and put the info into a table. (say I send a single/simple address string to this webservice/geocode, which then returns numerous possible matches with XY values and score values, and I want to capture that into a table) How do I go about doing this? I'm told I need to use SOAP. I discovered that the best module to use is ZSI (please correct me if I'm wrong). I have installed the necessary module. Examples I have seen are plenty and all so different, its not clear to me how to go about. I have been spinning my wheels for too long on this! Can someone provide some example code similar to what I need to do? Or any guidance would be appreciated. Thanks! It looks like you have three tasks here: - get data - parse it - store it SOAP could be the means to accomplish only the first one. If the service you use exposes the functionality using XML-RPC or some REST-ful methods I would try them first. If it does not, then you are stuck with SOAP. Using SOAP in Python is currently not as straightforward as it could be. You have chosen to use ZSI and that is fine choice. In documentation look for wsdl2py. Given a URL to a WSDL file it will generate stub class definition with methods corresponding to the SOAP service methods. In your code you would instantiate the class, call the method you want and grab the payload. Your first task is done. From what I understand the payload will be XML that will need to be parsed. For that you could use the excellent ElementTree If I were you I would investigate suds (https://fedorahosted.org/suds) It promises to be easier to use than ZSI. The README has the usage example. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem parsing SOAP envelope with ElementTree
Zvi wrote: Hi All, Can someone tell me why id the following not working? snip not working code What am I doing wrong? Here is working code. 8- from xml.etree import ElementTree as ET data = soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; soap:Body Get2Response xmlns=http://tempuri.org/; Get2Result![CDATA[?xml version='1.0' encoding='UTF-8'? Response Entity Name='Accounts' Current='00300571B42F1DEC8E9B6CDF19A59950' Instance Id='00300571B42F1DEC8E9B6CDF19A59950' Field Name='Status' Value='2'/ Field Name='Id' Value='MC4670'/ Field Name='Name' Value='ACDC Industries Inc'/ Field Name='City' Value='Milwaukee'/ Field Name='MainContact' Value=''/ Field Name='CreatedOn' Value='20070723051316.000 '/ /Instance /Entity /Response]] /Get2Result /Get2Response /soap:Body /soap:Envelope env = ET.fromstring(data) result = env.find('*//{http://tempuri.org/}Get2Result') response = ET.fromstring(result.text) for elm in response.getiterator(): print elm 8- In the future please paste complete examples. It helps me to help you. They were two things that I found to be wrong: - searching using wrong path. You missed *// in front of the tag - parsing only once. There are two xml sources here. The first parse got you the representation of the Envelope. You have to parse the Get2Result payload to get at the interesting part Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SOAP status
Jeff wrote: Twisted has SOAP support. yes but it is based on no longer actively maintained SOAPpy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SOAP status
Heikki Toivonen wrote: I have started researching the Python SOAP (and web services in general) options out there. Python 2.5 should be supported. I used Python for some web services stuff (demo quality) a few years back without major problems. However, it seems many of the libraries I remember from that time have become dormant or have been explicitly discontinued. A colleague also commented that he run into lots of problems trying to use Python for SOAP a year ago. What is your experience with Python SOAP, WSDL etc. libraries? What are the good, maintained options out there right now? How is standards compliance, how robust are the libraries, how do they interoperate with other libraries written in other languages (I am especially interested in interoperability with Java and PHP web services stacks). It seems like the top 3 candidates on my list are ZSI (http://pywebsvcs.sourceforge.net/), soaplib (http://trac.optio.webfactional.com/) and suds (http://trac.optio.webfactional.com/). If you have any experience in using these, I'd very much like to hear from you. There was quite a depressing post about ZSI's status at http://www.kunxi.org/archives/2008/01/pythonsoap-second-encounter/. I had good experience using soaplib as the server and Java client. For the client side I found elementsoap (http://effbot.org/downloads/) to be useful on a couple occasions. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert latex-based docs written with Python 2.5 to 2.6 framework
On Mar 26, 1:37 pm, Michael Ströder [EMAIL PROTECTED] wrote: HI! I had a look on how Doc/ is organized with Python 2.6. There are files with suffix .rst. Hmm... I'm maintaing existing docs for python-ldap which I might have to convert to the new concept in the long run. What's the recommended procedure for doing so? Any pointer? Ciao, Michael. I found the original python docs converter here: http://svn.python.org/projects/doctools/converter/ Unfortunately it is very specific to the Python docs :) I did try to run it on python-ldap .tex files and I was partially successful. It has produced a skeleton of the docs in the new format. After couple of hours of manual conversion I got far enough to actually see some results. Whatever I did is definitely not in finished state but it could be a start. Send me an off-line email if you are interested in what I have got so far. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does python behave so? (removing list items)
On Mar 26, 4:04 pm, Michał Bentkowski [EMAIL PROTECTED] wrote: Why does python create a reference here, not just copy the variable? j=range(0,6) k=j del j[0] j [1, 2, 3, 4, 5] k [1, 2, 3, 4, 5] Shouldn't k remain the same? http://www.effbot.org/zone/python-list.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: ZSI and attachments
On Mar 11, 8:59 am, Laszlo Nagy [EMAIL PROTECTED] wrote: Hi All, I wonder if the newest ZSI has support for attachments? Last time I checked (about a year ago) this feature was missing. I desperately need it. Alternatively, is there any other SOAP lib for python that can handle attachments? Does this help? http://trac.optio.webfactional.com/browser/soaplib/trunk/examples/binary.py -- http://mail.python.org/mailman/listinfo/python-list
Re: Another dumb scope question for a closure.
On Jan 9, 11:47 am, Steven W. Orr [EMAIL PROTECTED] wrote: So sorry because I know I'm doing something wrong. 574 cat c2.py #! /usr/local/bin/python2.4 def inc(jj): def dummy(): jj = jj + 1 return jj return dummy h = inc(33) print 'h() = ', h() 575 c2.py h() = Traceback (most recent call last): File ./c2.py, line 10, in ? print 'h() = ', h() File ./c2.py, line 5, in dummy jj = jj + 1 UnboundLocalError: local variable 'jj' referenced before assignment I could have sworn I was allowed to do this. How do I fix it? I have seen this approach on ActiveState Cookbook but can not find a reference to it right now. def inc(jj): ... def dummy(): ... dummy.jj += 1 ... return dummy.jj ... dummy.jj = jj ... return dummy ... h = inc(33) h() 34 h() 35 i = inc(12) i() 13 i() 14 Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Another dumb scope question for a closure.
On Jan 9, 3:52 pm, Waldemar Osuch [EMAIL PROTECTED] wrote: On Jan 9, 11:47 am, Steven W. Orr [EMAIL PROTECTED] wrote: So sorry because I know I'm doing something wrong. 574 cat c2.py #! /usr/local/bin/python2.4 def inc(jj): def dummy(): jj = jj + 1 return jj return dummy h = inc(33) print 'h() = ', h() 575 c2.py h() = Traceback (most recent call last): File ./c2.py, line 10, in ? print 'h() = ', h() File ./c2.py, line 5, in dummy jj = jj + 1 UnboundLocalError: local variable 'jj' referenced before assignment I could have sworn I was allowed to do this. How do I fix it? I have seen this approach on ActiveState Cookbook but can not find a reference to it right now. def inc(jj): ... def dummy(): ... dummy.jj += 1 ... return dummy.jj ... dummy.jj = jj ... return dummy ... h = inc(33) h() 34 h() 35 i = inc(12) i() 13 i() 14 Waldemar Here it is: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474122 -- http://mail.python.org/mailman/listinfo/python-list
Re: pdf library.
On Dec 29, 11:54 am, Shriphani [EMAIL PROTECTED] wrote: Hi, I am looking for a pdf library that will give me a list of pages where new chapters start. Can someone point me to such a module ? Regards, Shriphani P. pyPdf may help you with that: http://pybrary.net/pyPdf/ -- http://mail.python.org/mailman/listinfo/python-list
Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)
On Dec 18, 6:42 am, Ravi Kumar [EMAIL PROTECTED] wrote: In continuation of last mail [since pressing tab+space sent the mail :( ] Things on high priorities right now are: - How to integrate Python calling from .NET If I had to do something like this I would host a Python web server listening on some port and let .NET application talk to me using HTTP requests preferably or SOAP if I really had to. It could be a Paster or Cherrypy or Twisted based server. Google for instruction on how to package it using py2exe into a windows service. The service could be hosted on the same server as .NET or a separate box - Any suggestions for optimizations that would prevent overburden to application due to IronPython interpretation calling, if any, or does such things happen. - Pointers to good resources - Any step in such kind of situation, so to make it Enterprise Grade application components I do not have Enterprise Grade Seal of Approval but similar setup is running successfully at my workplace for the last 2 years. - your opinion with available PDF Libraries, that are best among. Also which library to use for Windows server platform (there is limitation on installing long chain libraries that include other deep dependencies too). A pure python PDF library would be good, but which one. http://pybrary.net/pyPdf/ -Which XML Library is pure python based. ElementTree -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate pdf file from an html page??
On Dec 16, 3:51 am, abhishek [EMAIL PROTECTED] wrote: Hi everyone, I am trying to generate a PDF printable format file from an html page. Is there a way to do this using python. If yes then which library and functions are required and if no then reasons why it cant be done. Thank you All You may want to investigate. http://pisa.spirito.de/ It worked for me in some simple conversions -- http://mail.python.org/mailman/listinfo/python-list
Re: Elementtree tag
On Dec 13, 7:52 pm, Sean DiZazzo [EMAIL PROTECTED] wrote: I have a another question... using elementtree, is there a proper way to get at the data '123456789' in this tag? 'id 123456789 /' I tried making it an element, but the only attribute that returns anything is the tag attribute. Does that section of a tag have any proper name that I'm missing? Or is it just bad XML style? It is not even legal xml. This may work. from xml.etree import ElementTree as ET elm = ET.fromstring('atag id=123456789 /') elm Element atag at 1ba2f80 elm.attrib {'id': '123456789'} -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice for editing xml file using ElementTree and wxPython
On Dec 8, 8:35 pm, Rick Muller [EMAIL PROTECTED] wrote: I'm a computational chemist who frequently dabbles in Python. A collaborator sent me a huge XML file that at one point was evidently modified by a now defunct java application. A sample of this file looks something like: group type=struct nameTest/name param type=string nameFile Name/name cTagfileName/cTag descName of the input file/desc valuewater/value /param param type=int nameNumber of Atoms/name cTagnatoms/cTag descNumber of atoms in the molecule/desc value3/value /param /group snip Seems like this is something that's probably pretty common, modifying a data structure using a gui, so I'm hoping that someone has thought about this and has some good advice about best practices here. The trick is to keep a reference to the actual ElementTree objects as you build your TreeCtrl. Ability to store arbitrary Python object in the TreeCtrl Item makes it easy. In an event handler modify the original element and you are done. Do not forget to save when closing. If the XML file is very large you may have performance issues since the whole parsed tree is kept in memory. Luckily the ElementTree representation is lean. A sample below shows the approach. It is very basic but I hope it conveys the idea. Please note that edits to the actual tags are ignored. --- import wx import xml.etree.cElementTree as ET class MainFrame(wx.Frame): def __init__(self, fpath): wx.Frame.__init__(self, None) self.fpath = fpath self.xml = ET.parse(fpath) self.tree = wx.TreeCtrl(self, style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS) root = self.fillmeup() self.tree.Expand(root) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEdit) def fillmeup(self): xml = self.xml.getroot() tree = self.tree root = tree.AddRoot(xml.tag) def add(parent, elem): for e in elem: item = tree.AppendItem(parent, e.tag, data=None) text = e.text.strip() if text: val = tree.AppendItem(item, text) tree.SetPyData(val, e) add(item, e) add(root, xml) return root def OnEdit(self, evt): elm = self.tree.GetPyData(evt.Item) if elm is not None: elm.text = evt.Label def OnClose(self, evt): self.xml.write(self.fpath) self.Destroy() if __name__=='__main__': app = wx.App(False) frame = MainFrame('sample.xml') frame.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Codec lookup fails for bad codec name, blowing up BeautifulSoup
This is a known bug. It's in the old tracker on SourceForge: [ python-Bugs-960874 ] codecs.lookup can raise exceptions other than LookupError but not in the new tracker. The new tracker has it too. http://bugs.python.org/issue960874 The resolution back in 2004 was Won't Fix, without a change to the documentation. Grrr. -- http://mail.python.org/mailman/listinfo/python-list
Re: Codec lookup fails for bad codec name, blowing up BeautifulSoup
On Nov 9, 4:15 pm, John Nagle [EMAIL PROTECTED] wrote: Waldemar Osuch wrote: This is a known bug. It's in the old tracker on SourceForge: [ python-Bugs-960874 ] codecs.lookup can raise exceptions other than LookupError but not in the new tracker. The new tracker has it too. http://bugs.python.org/issue960874 How did you find that? I put codecs.lookup into the tracker's search box, and it returned five hits, but not that one. John Nagle I have seen this explained on this list once: http://bugs.python.org/issues + source forge bug id points to the converted ticket. And yes the search could be better. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python as primary language
On Nov 8, 12:52 am, Michel Albert [EMAIL PROTECTED] wrote: In our company we are looking for one language to be used as default language. So far Python looks like a good choice (slacking behind Java). A few requirements that the language should be able cope with are: * Database access to Sybase. This seems to be available for python, but the windows-binaries for the library are not available. Self-Compiling them proved to be non-trivial (As always on windows). Consider using ODBC. mxODBC as well as pyodbc and ceODBC could be good alternatives. * Easy GUI creation. Solved using PyQt. * Cross Platform (Linux + Windows). Again, PyQt, solves this * Easy deployment. Solved using py2exe + innosetup * Charting (Histograms, Line charts, bar charts, pie charts, ...) I am currently looking into PyQwt, which looks promising. * Report generation with GUI support reportlab + rml? So far, nearly all point seems to be manageable. But I was not yet able to find a solution for the report generation. What we would like to have is a sort of GUI interface to prepare the reports without having to code the positioning. I found reportlab, and it looks like it can do all that is needed in terms of output. But you still have to code the report. And this is a no go. In context, I found RML and saw links to graphical RML editors. But I have not yet found a concrete example code, or documentation. What am I missing? Is RML a reportlab creation or is it a recognised open standard? If not, is there an open standard, that is easily to process with python? I still have to try it but pisa looks very promising: http://pisa.spirito.de/content/501/pisa3.html PDF generation using HTML+CSS for layout. I hope your boss considers HTML acceptable coding. Any pointers? I would prefer coding Python to coding Java or worse. VB ;) which is another contender in our roundup. You mean VB before .Net? You know that Microsoft ended support for it. Thanks to that brilliant decision Python is an official language at my place of work. -- http://mail.python.org/mailman/listinfo/python-list
[issue1090] doctools/sphinx/web/application.py does not start on windows
New submission from Waldemar Osuch: Loading pickles on windows without specifying 'rb' does not work in http://svn.python.org/projects/doctools/trunk/sphinx/web/application.py A simple patch attached -- components: Documentation tools (Sphinx) files: sphinx_web_application.patch messages: 55595 nosy: osuchw severity: normal status: open title: doctools/sphinx/web/application.py does not start on windows type: crash __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1090 __ sphinx_web_application.patch Description: Binary data ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: python-ldap for Python 2.5 on Windows?
On Jun 11, 6:42 am, Benedict Verheyen [EMAIL PROTECTED] wrote: Thorsten Kampe schreef: snip I'm on Vista (boohoo :(), what's your platform? XP SP2 Hmmm it thought so. So in my case it would be interesting to know how to build it so i can make a build that works on Vista too. I have also build it on XP SP2. I have wrapped the files from setup.py build and all required .dll using Inno Setup. Maybe Vista does not like the executable produced by Inno. If you still want to try then unzip the following: http://www.osuch.org/python-ldap.zip into your site-packages and see how far you can get. The detailed instructions on how to build would be quite long and I'm sure I have forgotten some of the steps already but if you know about ./configure make make install dance and know how to use Google you should be OK. 1. First install MinGW, Msys and msysDTK. 2. Then you need to compile openldap. See: http://mail.gnome.org/archives/gnomemeeting-devel-list/2005-September/msg00019.html for reference. You will need regex but you can skip Berkley DB before you start. 3. I have compiled openssl too but I have seen ready made libraries for download. I do not have link handy at the moment. 4. The last step would be to run setup.py build for python-ldap. Remove sasl2 from setup.cfg since cyrus-sasl does not seem to be available for MinGW. See how far you can get with the above instructions. If you get stuck send me a private email and I will try to help you. If you could keep track of the steps and came up with better instructions than my pitiful attempt above that would be great. Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: python-ldap for Python 2.5 on Windows?
On Jun 8, 6:36 am, Benedict Verheyen [EMAIL PROTECTED] wrote: Hi, i found python-ldap for version Python 2.4. Is there i place i can find a version for 2.5? If not, how can i build it myself for Windows? I have managed to build it for myself using MinGW: http://www.osuch.org-a.googlepages.com/python-ldap-2.3.win32-py2.5.exe See if it will work for you Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: excel library without COM
On Jun 3, 6:59 pm, james_027 [EMAIL PROTECTED] wrote: is there any library to help me write excel files without using win com? One option is: https://secure.simplistix.co.uk/svn/xlwt/trunk -- http://mail.python.org/mailman/listinfo/python-list
Re: pyExcelerator bug?
On May 16, 4:42 pm, [EMAIL PROTECTED] wrote: My program creates three lists: the first has dates expressed as strings, the second has floats that are strictly positive, and the third has floats that are strictly negative. I have no trouble writing the data in these lists to a .csv file using the csv module using the following code. outfile = file(fn + '.csv','wb') writer = csv.writer(outfile) for i in range(len(dateList)): writer.writerow([dateList[i], posVals[i], negVals[i]]) outfile.close() However, when I try to write to an Excel file usingpyExcelerator(see code below), the third list is not always written correctly - my program sometimes writes positive numbers into the third column of the spreadsheet. Is this a known bug? if so, is there a workaround? IspyExceleratorbeing developed any longer? My attempts to reach the developer have gone nowhere. w =pyExcelerator.Workbook() ws = w.add_sheet(fn + p) for i,d in enumerate(dateList): ws.write(i+1, 0, dateList[i]) ws.write(i+1, 1, posVals[i]) ws.write(i+1, 2, negVals[i]) w.save(fn+'.xls') Sincerely Thomas Philps Try using this patch on Cell.py and see if it fixes your problem: --- Cell.py (revision 4522) +++ Cell.py (revision 4523) @@ -101,6 +101,14 @@ def get_biff_data(self): +return BIFFRecords.NumberRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__number).get() +# Skipping all the logic below. +# From what I understand it tries to save space. +# Unfortunately it gets it wrong and produces false results. +# For example: +# 814289000 gets written out as -259452824 + -- http://mail.python.org/mailman/listinfo/python-list
Re: Setting Up SOAPpy for Python v2.5 on Windows?
On Mar 14, 10:22 am, Steve [EMAIL PROTECTED] wrote: All, Thanks for the suggestions! I think that I will move forward with elementsoap instead of soappy... Maybe worth checking out the new kid on the block too: http://trac.optio.webfactional.com/wiki -- http://mail.python.org/mailman/listinfo/python-list
Re: When will 2.5.1 be released?
On Mar 6, 12:12 pm, A. Lloyd Flanagan [EMAIL PROTECTED] wrote: On Mar 4, 2:49 pm, Nile [EMAIL PROTECTED] wrote: And while we're waiting for 2.5.1, can somebody post a clear (as opposed to the one that comes with Tix ;)) explanation of how to manually install Tix into python 2.5? It should be possible... Copying relevant files from 2.4 installation into corresponding location in 2.5 worked for me. From what I remember I had to copy: - Python root/tcl/tix8.1/* - Python root/tcl/tix8184.lib - Python root/DLLs/tix8184.dll -- http://mail.python.org/mailman/listinfo/python-list
Re: PyExcelerator: how to set colours?
Gerry wrote: I'd like some cell to be a Blue ABCDE. Here's come code thatv tries various values for pattern_for_colour and font.colour_index, to no avail. Can anyone suggest the right way to set colours? Thanks! Gerry == from pyExcelerator import * w = Workbook() ws = w.add_sheet('alpha') style = XFStyle() fore_colour = style.pattern.pattern_fore_colour back_colour = style.pattern.pattern_back_colour ws.write (1, 1, fore_colour) ws.write (1, 2, fore_colour) ws.write (2, 1, back_colour) ws.write (2, 2, back_colour) text= ABCDE row = 5 for offset in range(-32,512): row += 1 style.font.colour_index = fore_colour + offset ws.write(row,3, fore_colour + offset, style) ws.write(row,5,text,style) style.pattern.pattern_fore_colour = fore_colour + offset ws.write(row,6,text,style) w.save('test.xls') = shows no colour variation for any of these values of offset. Is this what you were after? -- from pyExcelerator import * w = Workbook() ws = w.add_sheet('boo') style = XFStyle() fore_colour = style.pattern.pattern_fore_colour back_colour = style.pattern.pattern_back_colour ws.write (1, 1, fore_colour) ws.write (1, 2, fore_colour) ws.write (2, 1, back_colour) ws.write (2, 2, back_colour) text = ABCDE row = 5 for offset in range(-32,512): row += 1 fnt = Font() fnt.colour_index = fore_colour + offset style.font = fnt ws.write(row, 3, offset, style) ws.write(row, 5, text, style) p = Pattern() p.pattern_fore_colour = fore_colour + offset p.pattern = style.pattern.SOLID_PATTERN style.pattern = p ws.write(row, 6, text, style) w.save('test.xls') Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: The status of Python and SOAP?
Thomas W wrote: I'm going to give a presentation of python to my co-workers at a very pro-microsoft workplace. Almost everything we need is currently supported by the standard distro + the win32all package, but we also need support for SOAP. I've tried SOAPpy ( didn't get it to compile, needed a library from a dead site ) and a few others, but I cannot help the feeling that SOAP isn't very high on the list of priorities in the python community. I hope I'm wrong. In short: What library is currently the best alternative to implement stable, efficient SOAP-webservices, both client and servers? What library is being actively maintained? Any hint or help would be great. You may have tried it already but judging from mailing list and SVN commits the most actively maintained is ZSI from http://pywebsvcs.sourceforge.net/ Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Oracle database export
On Oct 5, 9:05 am, Tor Erik Soenvisen [EMAIL PROTECTED] wrote: Hi, I need to export an Oracle database to a DDL-formated file. On the Web, I found a Python script that did exactly this for a MS Access database, but not one for Oracle databases. Does anyone know of such a tool or Python script. regards tores Would that help? http://www.python.net/crew/atuining/cx_OracleTools/README.txt Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: pyXLWriter - grid lines and if formula
Luis P. Mendes wrote: Gregory Piñero escreveu: On 7/7/06, Luis P. Mendes [EMAIL PROTECTED] wrote: Hi, I know that pyExelerator is the supported project now, but I can't use it because I'd need it to generate files from a web platform. Since I can not save a file to a file-like object, I have to use pyXLWriter. So, perhaps you could show me how to generate an excel file as a http response in django? If it is a simple one sheet Workbook you can produce HTML document with a table and set the headers to indicate it is Excel. Content-Type: application/vnd.ms-excel Content-Disposition: attachment;filename=report.xls Lookup documentation on how to generate formula: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoffxml/html/ofxml2k.asp Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivalent of Perl-ISAPI?
What Roger says and also: http://pyisapie.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets
- xlrd seems to be focused on extracting data. - pyexcelerator can also generate Excel files. -- http://mail.python.org/mailman/listinfo/python-list
Re: How To Request Delivery Receipts On Emails
Gregory Piñero wrote: Does anyone know how to program a Python script to send out emails with a request delivery receipt? Is it something I can build into the email message via the mime stuff? You have to add 'Disposition-Notification-To' header from email.MIMEText import MIMEText msg = MIMEText('Very important email I need confirmation on') me = '[EMAIL PROTECTED]' msg['From'] = me msg['To'] = '[EMAIL PROTECTED]' msg['Subject'] = 'You better follow up' msg['Disposition-Notification-To'] = me print msg.as_string() Content-Type: text/plain; charset=us-ascii MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: You better follow up Disposition-Notification-To: [EMAIL PROTECTED] Very important email I need confirmation on -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write file with cp1250 encodings?
Grzegorz Smith wrote: Hi all. I have got situation: i load data from database(MSSQL) wchich are encoded cp1250 and I fill template with that data (Cheetah Template), after all i want to save template to file on disk. I'm using One way to do it: from Cheetah.Template import Template print open('city.tmpl').read() !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=cp1250 http-equiv=content-type titleWelcome/title /head body Welcome to $city br /body /html t = Template(file='city.tmpl') city = u'Lódz' t.city = city.encode('cp1250') open('city.html', 'w').write(str(t)) The idea here is to encode your unicode before passing it to the template. Waldemar -- http://mail.python.org/mailman/listinfo/python-list