From mail at beatrixwillius.de Mon Dec 1 02:11:30 2014 From: mail at beatrixwillius.de (Beatrix Willius from Moth Software) Date: Mon, 1 Dec 2014 08:11:30 +0100 Subject: Getting errors from Imaplib In-Reply-To: References: <4B0DF114-E705-47B3-9815-003899F174CE@beatrixwillius.de> Message-ID: <2DB358DA-5AEC-412D-A0AC-CD2EB6746C93@beatrixwillius.de> On 30.11.2014, at 21:11, Chris Angelico wrote: > > 2) Network failures and auth problems should be dealt with the same > way. Change one line of code: > except (imaplib.IMAP4.error, OSError): > > Now it'll cope with OSError the same way it copes with IMAP errors. > > Does that answer your question? Thanks! That solves my problem. Mit freundlichen Gr??en/Regards Trixi Willius http://www.mothsoftware.com Mail Archiver X: The email archiving solution for professionals From ezhilarasan at geoconcept.com Mon Dec 1 03:59:02 2014 From: ezhilarasan at geoconcept.com (Ezhilarasan Chandrasekar) Date: Mon, 1 Dec 2014 14:29:02 +0530 Subject: I need Help Message-ID: Hi Python-list Team, I'm a beginner of python, I just want your help. I'm using the Python in Pydev - Eclipse. How can I get the Failure values from the Console in to a txt or a csv file? And how can I get the final result of the TC (lets say, OK or FAIL or ERROR)? So that If I'm working with 1000 Test cases, I can easily find out the Failed TCs and work on them. Please find my above questions and revert me with a good answer. Thanks in advance, Ezhilarasan -------------- next part -------------- An HTML attachment was scrubbed... URL: From nigamreetesh84 at gmail.com Mon Dec 1 05:54:44 2014 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Mon, 1 Dec 2014 02:54:44 -0800 (PST) Subject: Read response XML attributes in django rest framework Message-ID: <1248a112-88fd-4346-a733-7716671b835e@googlegroups.com> I need to read xml attributes coming in response data. I am using Django rest framework. requested XML : Response I am getting: {'xyz': None} I am using : 'DEFAULT_PARSER_CLASSES': ('rest_framework.parsers.XMLParser') in my setting.py file From poalman at gmail.com Mon Dec 1 06:29:57 2014 From: poalman at gmail.com (Paul Wiseman) Date: Mon, 1 Dec 2014 11:29:57 +0000 Subject: ssl error with the python mac binary In-Reply-To: References: Message-ID: On 10 November 2014 at 22:51, Ned Deily wrote: > In article > , > Paul Wiseman wrote: > > I've been using the latest mac ppc/i386 binaries from python.org > > (https://www.python.org/ftp/python/2.7.8/python-2.7.8-macosx10.5.dmg). > > From what I can tell this version is linked against a pretty old > > version of OpenSSL (OpenSSL 0.9.7l 28 Sep 2006) which doesn't seem to > > be able to handle new sha-256 certificates. > > > > For example I'm unable to use pip (I guess the certificate was updated > > recently) > > Yes, the current python.org certificate does seem to cause problems for > that version of OpenSSL, unfortunately. > > > Am I right in thinking this is an issue with the build of python > > itself? Is there a way I can upgrade the version of OpenSSL linked > > with python- or force the python build to look elsewhere for the > > library? Or will I have to build my own from source? > > In the Pythons from the python.org OS X installers, the Python _ssl and > _hashlib extension modules are dynamically linked with the > system-supplied OpenSSL libraries. If actually running on OS X 10.5, > one would have to rebuild _ssl.so and _hashlib.so, linking them with a > locally-supplied version of a newer OpenSSL, since different versions of > OpenSSL are not ABI-compatible, e.g. 0.9.7 vs 0.9.8 vs 1.0.1. If > running on OS X 10.6 or later, another option might be to install from > the 64-bit/32-bit installer which is a good idea to do anyway. For pip > usage, a workaround would be to manually download distributions from > PyPI (or elsewhere) using a web browser and then use pip to install from > the downloaded file. The next version of pip is expected to have a > --no-check-certificate option that bypasses the certificate check at the > cost of reduced security. For the upcoming Python 2.7.9 release > (planned for early December), I intend to have the Pythons in the > python.org OS X installers use their own versions of OpenSSL and thus no > longer depend on the now-deprecated system OpenSSL. > > I just gave 2.7.9rc1 a go and seems like it is still linked to the same version of openssl? Python 2.7.9rc1 (v2.7.9rc1:40eada278702, Nov 25 2014, 17:10:11) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> >>> import requests >>> requests.get("https://python.org") Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/api.py", line 60, in get return request('get', url, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/api.py", line 49, in request return session.request(method=method, url=url, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/sessions.py", line 457, in request resp = self.send(prep, **send_kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/sessions.py", line 569, in send r = adapter.send(request, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/adapters.py", line 420, in send raise SSLError(e, request=request) requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581) >>> >>> import ssl >>> ssl.OPENSSL_VERSION 'OpenSSL 0.9.7l 28 Sep 2006' > -- > Ned Deily, > nad at acm.org > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ganesh1pal at gmail.com Mon Dec 1 06:55:56 2014 From: ganesh1pal at gmail.com (Ganesh Pal) Date: Mon, 1 Dec 2014 17:25:56 +0530 Subject: Python and GUI development Message-ID: Hi folks, I want to design a GUI interface for my project . I wanted it to use it Python and it has to work on freebsd . Please provide me the latest trends for GUI development with python. Regard s Ganesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Dec 1 07:13:32 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 1 Dec 2014 23:13:32 +1100 Subject: Python and GUI development In-Reply-To: References: Message-ID: On Mon, Dec 1, 2014 at 10:55 PM, Ganesh Pal wrote: > Hi folks, > > I want to design a GUI interface for my project . I wanted it to use it > Python and it has to work on freebsd . Please provide me the latest > trends for GUI development with python. > > Regard s > Ganesh There are lots of Python GUI toolkits. You can use GTK with PyGObject, or PyQt, or wxPython, or Tkinter, or any of quite a few lesser-known ones. You could do a quick web search to find out which ones work on FreeBSD (probably all, or at least most, of them), and then you could find out something about each one, and make a decision based on that. ChrisA From aezhil90 at gmail.com Mon Dec 1 08:05:32 2014 From: aezhil90 at gmail.com (Ezhilarasan Chandrasekar) Date: Mon, 1 Dec 2014 18:35:32 +0530 Subject: Need Help Message-ID: Hi Guys, I'm a beginner of python, I just want your help. I'm using the Python in Pydev - Eclipse. How can I get the Failure values from the Console in to a txt or a csv file? And how can I get the final result of the TC (lets say, OK or FAIL or ERROR)? So that If I'm working with 1000 Test cases, I can easily find out the Failed TCs and work on them. Please find my above questions and revert me with a good answer. -- Warm regards, Ezhilarasan -------------- next part -------------- An HTML attachment was scrubbed... URL: From aezhil90 at gmail.com Mon Dec 1 08:11:27 2014 From: aezhil90 at gmail.com (Ezhilarasan Chandrasekar) Date: Mon, 1 Dec 2014 18:41:27 +0530 Subject: Fwd: Need Help In-Reply-To: References: Message-ID: Hi Guys, I'm a beginner of python, I just want your help. I'm using the Python in Pydev - Eclipse. How can I get the Failure values from the Console in to a txt or a csv file? And how can I get the final result of the TC (lets say, OK or FAIL or ERROR)? So that If I'm working with 1000 Test cases, I can easily find out the Failed TCs and work on them. Please find my above questions and revert me with a good answer. -- Warm regards, Ezhilarasan -------------- next part -------------- An HTML attachment was scrubbed... URL: From roy at panix.com Mon Dec 1 08:21:11 2014 From: roy at panix.com (Roy Smith) Date: Mon, 01 Dec 2014 08:21:11 -0500 Subject: Read response XML attributes in django rest framework References: <1248a112-88fd-4346-a733-7716671b835e@googlegroups.com> Message-ID: In article <1248a112-88fd-4346-a733-7716671b835e at googlegroups.com>, reetesh nigam wrote: > I need to read xml attributes coming in response data. I am using Django rest > framework. > > requested XML : startDate="02-02-2014"/> > > Response I am getting: {'xyz': None} > > I am using : 'DEFAULT_PARSER_CLASSES': ('rest_framework.parsers.XMLParser') > in my setting.py file This seems like a question for the django-users mailing list. https://docs.djangoproject.com/en/1.7/internals/mailing-lists From alister.nospam.ware at ntlworld.com Mon Dec 1 09:27:22 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Mon, 01 Dec 2014 14:27:22 GMT Subject: Fwd: Need Help Message-ID: On Mon, 01 Dec 2014 18:41:27 +0530, Ezhilarasan Chandrasekar wrote: > Hi Guys, > > I'm a beginner of python, I just want your help. > > I'm using the Python in Pydev - Eclipse. > > How can I get the Failure values from the Console in to a txt or a csv > file? > > And how can I get the final result of the TC (lets say, OK or FAIL or > ERROR)? > > So that If I'm working with 1000 Test cases, I can easily find out the > Failed TCs and work on them. > > Please find my above questions and revert me with a good answer. if you expect any assistance yopu need to try the fiollowing:- 1) DO NOT keep reposting the same question - it wont get you results any faster (it is more likely to antagonise those who may be able to help & stop them responding). 2) Post the code you are working with and a full traceback of any errors. Your problem does not look like a beginner question but something a professional would require -- Its the InterNIC's fault. From gianniboncompagni at mail.com Mon Dec 1 09:33:22 2014 From: gianniboncompagni at mail.com (MICHELE CALZOLARI CREDIT SUISSE ASSOSIM) Date: Mon, 1 Dec 2014 06:33:22 -0800 (PST) Subject: -- redacted -- In-Reply-To: References: Message-ID: <2045cfb8-2c74-469f-967d-8344740012d7@googlegroups.com> -- redacted -- From billyfurlong at gmail.com Mon Dec 1 11:40:16 2014 From: billyfurlong at gmail.com (billyfurlong at gmail.com) Date: Mon, 1 Dec 2014 08:40:16 -0800 (PST) Subject: Issues installing Python 2.7 In-Reply-To: <5476dd45$0$2855$c3e8da3$76491128@news.astraweb.com> References: <2680a96a-f5a9-44d8-b4b1-6e0ca32a53ed@googlegroups.com> <5476dd45$0$2855$c3e8da3$76491128@news.astraweb.com> Message-ID: <84aa01c7-5a55-4489-8ef7-43713b0abb01@googlegroups.com> This actually worked!! It's a bare machine with nothing (except the system) using python. From rosuav at gmail.com Mon Dec 1 11:50:15 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Dec 2014 03:50:15 +1100 Subject: Issues installing Python 2.7 In-Reply-To: <84aa01c7-5a55-4489-8ef7-43713b0abb01@googlegroups.com> References: <2680a96a-f5a9-44d8-b4b1-6e0ca32a53ed@googlegroups.com> <5476dd45$0$2855$c3e8da3$76491128@news.astraweb.com> <84aa01c7-5a55-4489-8ef7-43713b0abb01@googlegroups.com> Message-ID: On Tue, Dec 2, 2014 at 3:40 AM, wrote: > This actually worked!! It's a bare machine with nothing (except the system) using python. Good to know! But, uhh... *what* actually worked? You've posted with no content, so we have no idea which of the several suggestions in this thread worked - and,more importantly, neither does anyone who comes reading the archive. One of the beauties of a good mailing list is that information hangs around; if anyone else has the same problem as you do, s/he can read the response and know what to do, without waiting for the turn-around time of email questions and answers. For that to work, context is crucial. But I'm glad you're sorted out! ChrisA From billyfurlong at gmail.com Mon Dec 1 11:58:20 2014 From: billyfurlong at gmail.com (billyfurlong at gmail.com) Date: Mon, 1 Dec 2014 08:58:20 -0800 (PST) Subject: Invalid Syntax Installing pip - ez_setup.py Message-ID: Hi all, Getting an error when I try to install ez_setup.py. I thought that this was an issues with an incorrect version of python, so I upgraded to 2.7.5 successfully. But unfortunately I get the same error. [root at yyboxname tmp]# wget https://bootstrap.pypa.io/ez_setup.py --no-check-certificate -O - | sudo python --2014-12-01 11:30:17-- https://bootstrap.pypa.io/ez_setup.py Resolving bootstrap.pypa.io... 23.235.39.175 Connecting to bootstrap.pypa.io|23.235.39.175|:443... connected. WARNING: certificate common name `*.c.ssl.fastly.net' doesn't match requested host name `bootstrap.pypa.io'. HTTP request sent, awaiting response... 200 OK Length: 10476 (10K) [text/x-python] Saving to: `STDOUT' 100%[=============================================================================>] 10,476 --.-K/s in 0s 2014-12-01 11:30:17 (31.4 MB/s) - `-' saved [10476/10476] File "", line 51 with archive_context(archive_filename): ^ SyntaxError: invalid syntax Any help or direction would be greatly appreciated. Billy, From rosuav at gmail.com Mon Dec 1 12:06:53 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Dec 2014 04:06:53 +1100 Subject: Invalid Syntax Installing pip - ez_setup.py In-Reply-To: References: Message-ID: On Tue, Dec 2, 2014 at 3:58 AM, wrote: > Getting an error when I try to install ez_setup.py. I thought that this was an issues with an incorrect version of python, so I upgraded to 2.7.5 successfully. But unfortunately I get the same error. > > > File "", line 51 > with archive_context(archive_filename): > ^ > SyntaxError: invalid syntax When you run 'python', you apparently are getting the old version still. Try 'python2.7' instead. If you used a bash alias to change the meaning of the word 'python', that won't work with sudo. But the fuller name should work. ChrisA From larry.martell at gmail.com Mon Dec 1 13:05:04 2014 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 1 Dec 2014 13:05:04 -0500 Subject: Setting default_factory of defaultdict to key Message-ID: Is there a way to set the default_factory of defaultdict so that accesses to undefined keys get to set to the key? i.e. if d['xxx'] were accessed and there was no key 'xxx' then d['xxx'] would get set to 'xxx' I know I can define a function with lambda for the default_factory, but I don't see how to access the key. I tried: d = defaultdict(lambda: key) But that did not work. From ian.g.kelly at gmail.com Mon Dec 1 13:11:54 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 1 Dec 2014 11:11:54 -0700 Subject: Setting default_factory of defaultdict to key In-Reply-To: References: Message-ID: On Mon, Dec 1, 2014 at 11:05 AM, Larry Martell wrote: > Is there a way to set the default_factory of defaultdict so that > accesses to undefined keys get to set to the key? > > i.e. if d['xxx'] were accessed and there was no key 'xxx' then > d['xxx'] would get set to 'xxx' > > I know I can define a function with lambda for the default_factory, > but I don't see how to access the key. I tried: > > d = defaultdict(lambda: key) > > But that did not work. Not with defaultdict, but you can subclass dict and provide a __missing__ method directly, which is passed the key. This is basically all that defaultdict does. From ethan at stoneleaf.us Mon Dec 1 13:19:24 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 01 Dec 2014 10:19:24 -0800 Subject: Setting default_factory of defaultdict to key In-Reply-To: References: Message-ID: <547CB12C.3010502@stoneleaf.us> On 12/01/2014 10:05 AM, Larry Martell wrote: > > Is there a way to set the default_factory of defaultdict so that > accesses to undefined keys get to set to the key? You need to subclass and modify __missing__ to actually pass along the key: --> class defaultdictkey(defaultdict): ... def __missing__(self, key): ... self[key] = self.default_factory(key) ... return self[key] ... and in action: --> huh = defaultdictkey(lambda k: k) --> huh defaultdict( at 0x7fe1305de3f0>, {}) --> huh['x'] 'x' --> huh['x'] 'x' --> huh.get('y') --> huh['y'] 'y' --> huh.get('y') 'y' -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From billyfurlong at gmail.com Mon Dec 1 13:14:39 2014 From: billyfurlong at gmail.com (Billy Furlong) Date: Mon, 1 Dec 2014 10:14:39 -0800 (PST) Subject: Invalid Syntax Installing pip - ez_setup.py In-Reply-To: References: Message-ID: <037a66ca-02f4-4753-ab0d-a008f98faafb@googlegroups.com> Hi Chris, Yep that got me closer. I found that using | sudo python2.7 was a bad command. So I changed over to | python2.7. [root at myserver tmp]# wget https://bootstrap.pypa.io/ez_setup.py --no-check-certificate -O - | python2.7 --2014-12-01 12:57:07-- https://bootstrap.pypa.io/ez_setup.py Resolving bootstrap.pypa.io... 23.235.46.175 Connecting to bootstrap.pypa.io|23.235.46.175|:443... connected. WARNING: certificate common name `*.c.ssl.fastly.net' doesn't match requested host name `bootstrap.pypa.io'. HTTP request sent, awaiting response... 200 OK Length: 10476 (10K) [text/x-python] Saving to: `STDOUT' 100%[=============================================================================================>] 10,476 --.-K/s in 0s 2014-12-01 12:57:07 (30.8 MB/s) - `-' saved [10476/10476] Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.zip Traceback (most recent call last): File "", line 332, in File "", line 327, in main File "", line 287, in download_setuptools File "", line 224, in download_file_wget File "", line 169, in _clean_check File "/opt/python2.7/lib/python2.7/subprocess.py", line 542, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['wget', 'https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.zip', '--quiet', '--output-document', '/tmp/setuptools-7.0.zip']' returned non-zero exit status 1 From larry.martell at gmail.com Mon Dec 1 13:23:47 2014 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 1 Dec 2014 13:23:47 -0500 Subject: Setting default_factory of defaultdict to key In-Reply-To: <547CB12C.3010502@stoneleaf.us> References: <547CB12C.3010502@stoneleaf.us> Message-ID: On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote: > On 12/01/2014 10:05 AM, Larry Martell wrote: >> >> Is there a way to set the default_factory of defaultdict so that >> accesses to undefined keys get to set to the key? > > You need to subclass and modify __missing__ to actually pass along the key: > > --> class defaultdictkey(defaultdict): > ... def __missing__(self, key): > ... self[key] = self.default_factory(key) > ... return self[key] > ... > > and in action: > > --> huh = defaultdictkey(lambda k: k) > --> huh > defaultdict( at 0x7fe1305de3f0>, {}) > --> huh['x'] > 'x' > --> huh['x'] > 'x' > --> huh.get('y') > --> huh['y'] > 'y' > --> huh.get('y') > 'y' Perfect. Thanks much. From larry.martell at gmail.com Mon Dec 1 13:29:33 2014 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 1 Dec 2014 13:29:33 -0500 Subject: Setting default_factory of defaultdict to key In-Reply-To: <547CB12C.3010502@stoneleaf.us> References: <547CB12C.3010502@stoneleaf.us> Message-ID: On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote: > On 12/01/2014 10:05 AM, Larry Martell wrote: >> >> Is there a way to set the default_factory of defaultdict so that >> accesses to undefined keys get to set to the key? > > You need to subclass and modify __missing__ to actually pass along the key: > > --> class defaultdictkey(defaultdict): > ... def __missing__(self, key): > ... self[key] = self.default_factory(key) > ... return self[key] > ... > > and in action: > > --> huh = defaultdictkey(lambda k: k) > --> huh > defaultdict( at 0x7fe1305de3f0>, {}) > --> huh['x'] > 'x' > --> huh['x'] > 'x' > --> huh.get('y') > --> huh['y'] > 'y' > --> huh.get('y') > 'y' I spoke too soon: >>> class defaultdictkey(defaultdict): ... def __missing__(self, key): ... self[key] = self.default_factory(key) ... >>> x = defaultdictkey(lambda k: k) >>> print x['aaa'] None >>> print x['aaa'] aaa >>> a = x['qqq'] >>> print a None From python.list at tim.thechases.com Mon Dec 1 13:25:53 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 1 Dec 2014 12:25:53 -0600 Subject: Setting default_factory of defaultdict to key In-Reply-To: References: Message-ID: <20141201122553.1b249c93@bigbox.christie.dr> On 2014-12-01 13:05, Larry Martell wrote: > Is there a way to set the default_factory of defaultdict so that > accesses to undefined keys get to set to the key? > > i.e. if d['xxx'] were accessed and there was no key 'xxx' then > d['xxx'] would get set to 'xxx' > > I know I can define a function with lambda for the default_factory, > but I don't see how to access the key. I tried: > > d = defaultdict(lambda: key) You could subclass it: class MyDefaultDict(defaultdict): def __missing__(self, key): #self[key] = key # if you actually want it in the dict return key You might also have to override the __contains__ method to always return True if you want value_not_in_dict = 42 my_default_dict = MyDefaultDict(int) if value_not_in_dict in my_default_dict: this_branch_would_always_happen() else: this_branch_should_never_happen You'd also have weird behaviors with iterators as they'd only ever iterate over things that were in the dict. -tkc From ethan at stoneleaf.us Mon Dec 1 13:36:25 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 01 Dec 2014 10:36:25 -0800 Subject: Setting default_factory of defaultdict to key In-Reply-To: References: <547CB12C.3010502@stoneleaf.us> Message-ID: <547CB529.9080202@stoneleaf.us> On 12/01/2014 10:29 AM, Larry Martell wrote: > On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote: >> On 12/01/2014 10:05 AM, Larry Martell wrote: >>> >>> Is there a way to set the default_factory of defaultdict so that >>> accesses to undefined keys get to set to the key? >> >> You need to subclass and modify __missing__ to actually pass along the key: >> >> --> class defaultdictkey(defaultdict): >> ... def __missing__(self, key): >> ... self[key] = self.default_factory(key) >> ... return self[key] >> ... >> >> and in action: >> >> --> huh = defaultdictkey(lambda k: k) >> --> huh >> defaultdict( at 0x7fe1305de3f0>, {}) >> --> huh['x'] >> 'x' >> --> huh['x'] >> 'x' >> --> huh.get('y') >> --> huh['y'] >> 'y' >> --> huh.get('y') >> 'y' > > > I spoke too soon: > >>>> class defaultdictkey(defaultdict): > ... def __missing__(self, key): > ... self[key] = self.default_factory(key) You missed the third line here ^ ... return self[key] -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From larry.martell at gmail.com Mon Dec 1 13:41:28 2014 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 1 Dec 2014 13:41:28 -0500 Subject: Setting default_factory of defaultdict to key In-Reply-To: <547CB529.9080202@stoneleaf.us> References: <547CB12C.3010502@stoneleaf.us> <547CB529.9080202@stoneleaf.us> Message-ID: On Mon, Dec 1, 2014 at 1:36 PM, Ethan Furman wrote: > On 12/01/2014 10:29 AM, Larry Martell wrote: >> On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote: >>> On 12/01/2014 10:05 AM, Larry Martell wrote: >>>> >>>> Is there a way to set the default_factory of defaultdict so that >>>> accesses to undefined keys get to set to the key? >>> >>> You need to subclass and modify __missing__ to actually pass along the key: >>> >>> --> class defaultdictkey(defaultdict): >>> ... def __missing__(self, key): >>> ... self[key] = self.default_factory(key) >>> ... return self[key] >>> ... >>> >>> and in action: >>> >>> --> huh = defaultdictkey(lambda k: k) >>> --> huh >>> defaultdict( at 0x7fe1305de3f0>, {}) >>> --> huh['x'] >>> 'x' >>> --> huh['x'] >>> 'x' >>> --> huh.get('y') >>> --> huh['y'] >>> 'y' >>> --> huh.get('y') >>> 'y' >> >> >> I spoke too soon: >> >>>>> class defaultdictkey(defaultdict): >> ... def __missing__(self, key): >> ... self[key] = self.default_factory(key) > > You missed the third line here ^ > > ... return self[key] Oops! Thanks. Working now. From ian.g.kelly at gmail.com Mon Dec 1 13:35:22 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 1 Dec 2014 11:35:22 -0700 Subject: Setting default_factory of defaultdict to key In-Reply-To: References: <547CB12C.3010502@stoneleaf.us> Message-ID: On Mon, Dec 1, 2014 at 11:29 AM, Larry Martell wrote: > I spoke too soon: > >>>> class defaultdictkey(defaultdict): > ... def __missing__(self, key): > ... self[key] = self.default_factory(key) > ... >>>> x = defaultdictkey(lambda k: k) >>>> print x['aaa'] > None >>>> print x['aaa'] > aaa >>>> a = x['qqq'] >>>> print a > None You need to also return the value from __missing__. From fabiofz at gmail.com Mon Dec 1 13:58:50 2014 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Mon, 1 Dec 2014 16:58:50 -0200 Subject: Need Help In-Reply-To: References: Message-ID: On Mon, Dec 1, 2014 at 11:05 AM, Ezhilarasan Chandrasekar < aezhil90 at gmail.com> wrote: > Hi Guys, > > I'm a beginner of python, I just want your help. > > I'm using the Python in Pydev - Eclipse. > > How can I get the Failure values from the Console in to a txt or a csv > file? > > And how can I get the final result of the TC (lets say, OK or FAIL or > ERROR)? > > So that If I'm working with 1000 Test cases, I can easily find out the > Failed TCs and work on them. > > Please find my above questions and revert me with a good answer. > > Well, you want that to work/rerun the failed tests, PyDev does have a unittest-integration view which shows failed tests. Just run the tests right-clicking a folder -> run tests and the view should show the results (and it provides a way to show only failed tests, rerun only failures, see output, etc) -- see: http://pydev.org/manual_adv_pyunit.html The only thing is that it doesn't export that to a file... if you want to have that as an exported file, my suggestion would be using nose or pytest (which can also be used as the runners inside of PyDev -- http://pydev.org/manual_adv_pyunit.html also has more details on that) and pass a xml dump file (which I think both support). Cheers, Fabio -------------- next part -------------- An HTML attachment was scrubbed... URL: From billyfurlong at gmail.com Mon Dec 1 14:09:59 2014 From: billyfurlong at gmail.com (Billy Furlong) Date: Mon, 1 Dec 2014 11:09:59 -0800 (PST) Subject: Invalid Syntax Installing pip - ez_setup.py In-Reply-To: <037a66ca-02f4-4753-ab0d-a008f98faafb@googlegroups.com> References: <037a66ca-02f4-4753-ab0d-a008f98faafb@googlegroups.com> Message-ID: Success. Whats happening is that the second wget command is not recognizing the --no-check-certificate. So I went around the problem and installed it manually. wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.zip --no-check-certificate unzip setuptools-7.0.zip python2.7 setup.py install easy_install pip I'm good. Pip is installed. From 19aadan95 at gmail.com Mon Dec 1 14:28:16 2014 From: 19aadan95 at gmail.com (python help required) Date: Mon, 1 Dec 2014 11:28:16 -0800 (PST) Subject: i have to create this patch in python but wasnt having any luck i was wondering if anyone had a solution? Message-ID: <6bfc3acd-0a71-4f76-a335-022d0a7fc535@googlegroups.com> def penultimatePatch(): win = GraphWin("Patch1",(100), 100) amountOfCircles = 5 #Filled Red Circles fillCircle = Circle(Point(20,20)+100/amountOfCircles) fillCircle.draw(win) fillCircle.setFill("red") #Verticle white rectangles rectangleVerticle1 = Rectangle(Point(0,0), Point(10,100)) rectangleVerticle1.setFill("white") rectangleVerticle1.setOutline("white") rectangleVerticle1.draw(win) rectangleVerticle2 = Rectangle(Point(41,0), Point(51,100)) rectangleVerticle2.setFill("white") rectangleVerticle2.setOutline("white") rectangleVerticle2.draw(win) rectangleVerticle3 = Rectangle(Point(81,0), Point(91,100)) rectangleVerticle3.setFill("white") rectangleVerticle3.setOutline("white") rectangleVerticle3.draw(win) #Horizontal white rectangles rectangleHorizontal = Rectangle(Point(21,11), Point(41,21)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(61,11), Point(81,21)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(21,31), Point(51,41)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(81,31), Point(61,41)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(21,51), Point(51,61)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(61,51), Point(91,61)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(21,71), Point(51,81)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(61,71), Point(81,81)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(21,91), Point(51,100)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) rectangleHorizontal = Rectangle(Point(61,91), Point(91,100)) rectangleHorizontal.setFill("white") rectangleHorizontal.setOutline("white") rectangleHorizontal.draw(win) #Outlined Red circles fillCircle = Circle(Point(20,20)+100/amountOfCircles) fillCircle.draw(win) fillCircle.setOutline("red") it is supposed to create this design>>> http://i.stack.imgur.com/2dfGi.jpg From patrickkidd at gmail.com Mon Dec 1 15:15:09 2014 From: patrickkidd at gmail.com (Patrick Stinson) Date: Mon, 1 Dec 2014 11:15:09 -0900 Subject: Python and GUI development In-Reply-To: References: Message-ID: <40F01BA2-E07B-4DA7-883A-241480AFEF22@gmail.com> I?ve been using PyQt for 10 years. Absolutely fabulous, fun, and I imagine the others are also excellent as they have all been around long enough to die naturally if they were not very useful. > On Dec 1, 2014, at 3:13 AM, Chris Angelico wrote: > > On Mon, Dec 1, 2014 at 10:55 PM, Ganesh Pal wrote: >> Hi folks, >> >> I want to design a GUI interface for my project . I wanted it to use it >> Python and it has to work on freebsd . Please provide me the latest >> trends for GUI development with python. >> >> Regard s >> Ganesh > > There are lots of Python GUI toolkits. You can use GTK with PyGObject, > or PyQt, or wxPython, or Tkinter, or any of quite a few lesser-known > ones. You could do a quick web search to find out which ones work on > FreeBSD (probably all, or at least most, of them), and then you could > find out something about each one, and make a decision based on that. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From israel at ravnalaska.net Mon Dec 1 15:28:42 2014 From: israel at ravnalaska.net (Israel Brewster) Date: Mon, 1 Dec 2014 11:28:42 -0900 Subject: Cherrypy - prevent browser "prefetch"? Message-ID: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> I don't know if this is a cherrypy specific question (although it will be implemented in cherrypy for sure), or more of a general http protocol question, but when using cherrypy to serve a web app, is there anyway to prevent browser prefetch? I'm running to a problem, specifically from Safari on the Mac, where I start to type a URL, and Safari auto-fills the rest of a random URL matching what I started to type, and simultaneously sends a request for that URL to my server, occasionally causing unwanted effects. For example, I have a URL on my Cherrypy app that updates some local caches. It is accessed at http:///admin/updatecaches So if I start typing http:///a, for example, safari may auto-fill the "dmin/updatecaches", and trigger a cache refresh on the server - even though I was just trying to get to the main admin page at /admin. Or, it might auto-fill "uth/logout" instead (http:///auth/logout), and log me out of my session. While the former may be acceptable (after all, a cache update, even if not strictly needed, is at least non-harmfull), the latter could cause serious issues with usability. So how can cherrypy tell the difference between the "prefetch" and an actual request, and not respond to the prefetch? ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Israel Brewster.vcf Type: text/directory Size: 417 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Mon Dec 1 15:46:51 2014 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 02 Dec 2014 07:46:51 +1100 Subject: Python and GUI development References: Message-ID: <85oarnumh0.fsf@benfinney.id.au> Ganesh Pal writes: > I want to design a GUI interface for my project . I wanted it to use it > Python and it has to work on freebsd . Please provide me the latest > trends for GUI development with python. A good starting point . -- \ ?Truth is stranger than fiction, but it is because fiction is | `\ obliged to stick to possibilities, truth isn't.? ?Mark Twain, | _o__) _Following the Equator_ | Ben Finney From sohcahtoa82 at gmail.com Mon Dec 1 15:41:08 2014 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Mon, 1 Dec 2014 12:41:08 -0800 (PST) Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: References: Message-ID: <850a70bb-f065-42e7-8c3f-9f2d6e58eee4@googlegroups.com> On Monday, December 1, 2014 12:29:04 PM UTC-8, Israel Brewster wrote: > I don't know if this is a cherrypy specific question (although it will be implemented in cherrypy for sure), or more of a general http protocol question, but when using cherrypy to serve a web app, is there anyway to prevent browser prefetch? I'm running to a problem, specifically from Safari on the Mac, where I start to type a URL, and Safari auto-fills the rest of a random URL matching what I started to type, and simultaneously sends a request for that URL to my server, occasionally causing unwanted effects. > > > For example, I have a URL on my Cherrypy app that updates some local caches. It is accessed at http:///admin/updatecaches So if I start typing http:///a, for example, safari may auto-fill the "dmin/updatecaches", and trigger a cache refresh on the server - even though I was just trying to get to the main admin page at /admin. Or, it might auto-fill "uth/logout" instead (http:///auth/logout), and log me out of my session. While the former may be acceptable (after all, a cache update, even if not strictly needed, is at least non-harmfull), the latter could cause serious issues with usability. So how can cherrypy tell the difference between the "prefetch" and an actual request, and not respond to the prefetch? > > > > > > ----------------------------------------------- > > Israel Brewster > > Systems Analyst II > > Ravn Alaska > > 5245 Airport Industrial Rd > > Fairbanks, AK 99709 > > (907) 450-7293 > > ----------------------------------------------- That sounds like a seriously misbehaving client to me. Your browser should not be sending requests until the user actually chooses a URL to open. The only thing I would suggest is to check the HTTP request headers (cherrypy.request.headers) of a genuine request versus one made by the automatic URL completion. If there are different headers, such as maybe an "X-Prefetch: True" or something, you could check for that. From python.list at tim.thechases.com Mon Dec 1 16:26:08 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 1 Dec 2014 15:26:08 -0600 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> Message-ID: <20141201152608.09ca6f13@bigbox.christie.dr> On 2014-12-01 11:28, Israel Brewster wrote: > I don't know if this is a cherrypy specific question (although it > will be implemented in cherrypy for sure), or more of a general > http protocol question, but when using cherrypy to serve a web app, > is there anyway to prevent browser prefetch? I'm running to a > problem, specifically from Safari on the Mac, where I start to type > a URL, and Safari auto-fills the rest of a random URL matching what > I started to type, and simultaneously sends a request for that URL > to my server, occasionally causing unwanted effects. This SO post[1] suggests that Firefox sets/sends a X-moz: prefetch header, while Safari and Chrome use the X-Purpose: preview header. You could create a decorator that sniffs those headers and reacts accordingly. Though be aware that, based on my reading, Safari only sends that X-Purpose header for the base page, not any referenced assets (JS, CSS, images, etc). Also, while I can't find any documentation on how Safari/Chrome(ium) handle it, if your logout/ page sends an HTTP/302 redirect to a final landing page, Safari/Chrome(ium) may be smart enough to not suggest (and thus not prefetch) the bounce page, only the landing page. I haven't investigated recently, but I remember Django's ability to trigger a log-out merely via a GET was something that irked me. I don't have a recent version of Safari (my only Apple machine is a PPC iBook laptop running 10.4 which no longer receives any updates) so I can't verify that this header is actually being sent in the case you describe, but it would be where I'd start hunting. All this to also say that performing non-idempotent actions on a GET request is just begging for trouble. ;-) -tkc [1] http://stackoverflow.com/questions/9852257/http-header-to-detect-a-preload-request-by-google-chrome From cmbecker69 at arcor.de Mon Dec 1 16:44:20 2014 From: cmbecker69 at arcor.de (Christoph M. Becker) Date: Mon, 01 Dec 2014 22:44:20 +0100 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> Message-ID: Tim Chase wrote: > I > haven't investigated recently, but I remember Django's ability to > trigger a log-out merely via a GET was something that irked me. > > All this to also say that performing non-idempotent actions on a GET > request is just begging for trouble. ;-) ACK. However, isn't log-out an idempotent action? -- Christoph M. Becker From ned at nedbatchelder.com Mon Dec 1 16:50:09 2014 From: ned at nedbatchelder.com (Ned Batchelder) Date: Mon, 01 Dec 2014 16:50:09 -0500 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: <20141201152608.09ca6f13@bigbox.christie.dr> References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> <20141201152608.09ca6f13@bigbox.christie.dr> Message-ID: On 12/1/14 4:26 PM, Tim Chase wrote: > On 2014-12-01 11:28, Israel Brewster wrote: >> I don't know if this is a cherrypy specific question (although it >> will be implemented in cherrypy for sure), or more of a general >> http protocol question, but when using cherrypy to serve a web app, >> is there anyway to prevent browser prefetch? I'm running to a >> problem, specifically from Safari on the Mac, where I start to type >> a URL, and Safari auto-fills the rest of a random URL matching what >> I started to type, and simultaneously sends a request for that URL >> to my server, occasionally causing unwanted effects. > > All this to also say that performing non-idempotent actions on a GET > request is just begging for trouble. ;-) > This is the key point: your web application shouldn't be doing these kinds of actions in response to a GET request. Make them POST requests, and Safari won't give you any trouble. Trying to stop Safari from making the GET requests might work for Safari, but then you will find another browser, or a proxy server, or an edge-caching accelerator, etc, that makes the GET requests when you don't want them. The way to indicate to a browser that it shouldn't pre-fetch a URL is to make it a POST request. -- Ned Batchelder, http://nedbatchelder.com From python.list at tim.thechases.com Mon Dec 1 17:04:20 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 1 Dec 2014 16:04:20 -0600 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> Message-ID: <20141201160420.5b06a0d0@bigbox.christie.dr> On 2014-12-01 22:44, Christoph M. Becker wrote: > Tim Chase wrote: > > haven't investigated recently, but I remember Django's ability to > > trigger a log-out merely via a GET was something that irked me. > > > > All this to also say that performing non-idempotent actions on a > > GET request is just begging for trouble. ;-) > > ACK. However, isn't log-out an idempotent action? A minor note here...the OP talked about CherryPy and I've been in Django-land too long that I started talking Django. I'd have to pick open the scabs of my CherryPy experience to answer about CP. But yes, it appears that Django's contrib.auth module still allows for performing a logout/ on a GET (something I remember encountering/researching several years ago) rather than limiting it to a POST. As best I can tell, it doesn't even check the refer(r)er, so this charmingly means that I can put a tag like on *my* site, and it will log you out from yoursite.example.com despite. Not even a CSRF-token check because it's not a POST. -tkc From python.list at tim.thechases.com Mon Dec 1 17:12:07 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 1 Dec 2014 16:12:07 -0600 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> <20141201152608.09ca6f13@bigbox.christie.dr> Message-ID: <20141201161207.725c041f@bigbox.christie.dr> On 2014-12-01 16:50, Ned Batchelder wrote: > On 12/1/14 4:26 PM, Tim Chase wrote: >> All this to also say that performing non-idempotent actions on a >> GET request is just begging for trouble. ;-) > > This is the key point: your web application shouldn't be doing > these kinds of actions in response to a GET request. Make them > POST requests, and Safari won't give you any trouble. Though to be fair, based on the reading I did, Safari also pulls in the various JS and executes it too, meaning that merely (pre)"viewing" the page triggers any Google Analytics (or other analytics) code you have on that page, sending "page views" with a high bounce rate (looks like you only hit one page and never browsed elsewhere on the site). Additionally, if the target GET URL involves high processing load on the server, it might be worthwhile to put a caching proxy in front of it to serve (semi)stale data for any preview request rather than impose additional load on the server just so a preview can be updated. So I can see at least two cases in which you might want to sniff the "are you just previewing, or do you actually want the page" information. Perhaps there are more. -tkc From israel at ravnalaska.net Mon Dec 1 17:14:46 2014 From: israel at ravnalaska.net (Israel Brewster) Date: Mon, 1 Dec 2014 13:14:46 -0900 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> <20141201152608.09ca6f13@bigbox.christie.dr> Message-ID: <60102F31-5184-4FFF-B99E-23A5B0313399@ravnalaska.net> On Dec 1, 2014, at 12:50 PM, Ned Batchelder wrote: > On 12/1/14 4:26 PM, Tim Chase wrote: >> On 2014-12-01 11:28, Israel Brewster wrote: >>> I don't know if this is a cherrypy specific question (although it >>> will be implemented in cherrypy for sure), or more of a general >>> http protocol question, but when using cherrypy to serve a web app, >>> is there anyway to prevent browser prefetch? I'm running to a >>> problem, specifically from Safari on the Mac, where I start to type >>> a URL, and Safari auto-fills the rest of a random URL matching what >>> I started to type, and simultaneously sends a request for that URL >>> to my server, occasionally causing unwanted effects. >> >> All this to also say that performing non-idempotent actions on a GET >> request is just begging for trouble. ;-) >> > > This is the key point: your web application shouldn't be doing these kinds of actions in response to a GET request. Make them POST requests, and Safari won't give you any trouble. > > Trying to stop Safari from making the GET requests might work for Safari, but then you will find another browser, or a proxy server, or an edge-caching accelerator, etc, that makes the GET requests when you don't want them. > > The way to indicate to a browser that it shouldn't pre-fetch a URL is to make it a POST request. Ok, that makes sense. The only difficulty I have with that answer is that to the best of my knowledge the only way to make a HTML link do a POST is to use the onclick function to run a javascript, while having the "link" itself point to nothing. Just feels a bit ugly to me, but if that's the Right Way? to do it, then that's fine. Thanks! > > -- > Ned Batchelder, http://nedbatchelder.com > > -- > https://mail.python.org/mailman/listinfo/python-list ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- From israel at ravnalaska.net Mon Dec 1 17:19:36 2014 From: israel at ravnalaska.net (Israel Brewster) Date: Mon, 1 Dec 2014 13:19:36 -0900 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: <20141201161207.725c041f@bigbox.christie.dr> References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> <20141201152608.09ca6f13@bigbox.christie.dr> <20141201161207.725c041f@bigbox.christie.dr> Message-ID: On Dec 1, 2014, at 1:12 PM, Tim Chase wrote: > On 2014-12-01 16:50, Ned Batchelder wrote: >> On 12/1/14 4:26 PM, Tim Chase wrote: >>> All this to also say that performing non-idempotent actions on a >>> GET request is just begging for trouble. ;-) >> >> This is the key point: your web application shouldn't be doing >> these kinds of actions in response to a GET request. Make them >> POST requests, and Safari won't give you any trouble. > > Though to be fair, based on the reading I did, Safari also pulls in > the various JS and executes it too, meaning that merely > (pre)"viewing" the page triggers any Google Analytics (or other > analytics) code you have on that page, sending "page views" with a > high bounce rate (looks like you only hit one page and never browsed > elsewhere on the site). > > Additionally, if the target GET URL involves high processing load on > the server, it might be worthwhile to put a caching proxy in front of > it to serve (semi)stale data for any preview request rather than > impose additional load on the server just so a preview can be updated. Right, and there are probably some URL's in my app where this may be the case - I still need to go back and audit the code now that I'm aware of this going on. In general, though, it does sound as though changing things to POST requests, and disallowing GET requests for those URLS in my CherryPy app is the way to go. Thanks! > > So I can see at least two cases in which you might want to sniff the > "are you just previewing, or do you actually want the page" > information. Perhaps there are more. > > -tkc > > > > -- > https://mail.python.org/mailman/listinfo/python-list ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- From rodperson at rodperson.com Mon Dec 1 17:43:06 2014 From: rodperson at rodperson.com (Rod Person) Date: Mon, 1 Dec 2014 17:43:06 -0500 Subject: Python and GUI development In-Reply-To: References: Message-ID: <20141201174306.49eb9cad@atomizer> On Mon, 1 Dec 2014 23:13:32 +1100 Chris Angelico wrote: > On Mon, Dec 1, 2014 at 10:55 PM, Ganesh Pal > wrote: > > Hi folks, > > > > I want to design a GUI interface for my project . I wanted it to > > use it Python and it has to work on freebsd . Please > > provide me the latest trends for GUI development with python. > > > > Regard s > > Ganesh > > There are lots of Python GUI toolkits. You can use GTK with > PyGObject, or PyQt, or wxPython, or Tkinter, or any of quite a few > lesser-known ones. You could do a quick web search to find out > which ones work on FreeBSD (probably all, or at least most, of > them), and then you could find out something about each one, and > make a decision based on that. > > ChrisA All of the above mentioned work on FreeBSD as I used all to some extent for GUI Apps on FreeBSD. I would say the easiest for a newbie would be PyQt for the fact that you can use the Eric IDE (http://www.freshports.org/devel/eric4/) which will install the QtDesigner which makes designing GUIs easier. -- Rod http://www.rodperson.com He who knows himself to be one way and pretends it is another way is a thief who robs his own soul. The Mahabharata Sakuntala 25 From nad at acm.org Mon Dec 1 17:59:04 2014 From: nad at acm.org (Ned Deily) Date: Mon, 01 Dec 2014 14:59:04 -0800 Subject: ssl error with the python mac binary References: Message-ID: In article , Paul Wiseman wrote: > I just gave 2.7.9rc1 a go and seems like it is still linked to the same > version of openssl? Yes, it still is for rc1. Unfortunately, I was not able to get everything done in time for rc1 and I didn't want to hold up rc1's release as there are a lot of other changes that need exposure. The final release installer *will* have the new version of openssl. -- Ned Deily, nad at acm.org From poalman at gmail.com Mon Dec 1 18:13:30 2014 From: poalman at gmail.com (Paul Wiseman) Date: Mon, 1 Dec 2014 23:13:30 +0000 Subject: ssl error with the python mac binary In-Reply-To: References: Message-ID: On 1 December 2014 at 22:59, Ned Deily wrote: > In article > , > Paul Wiseman wrote: > > I just gave 2.7.9rc1 a go and seems like it is still linked to the same > > version of openssl? > > Yes, it still is for rc1. Unfortunately, I was not able to get > everything done in time for rc1 and I didn't want to hold up rc1's > release as there are a lot of other changes that need exposure. The > final release installer *will* have the new version of openssl. > > Awesome thanks Ned! look forward to it :) > -- > Ned Deily, > nad at acm.org > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Mon Dec 1 18:19:51 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 01 Dec 2014 15:19:51 -0800 Subject: How about some syntactic sugar for " __name__ == '__main__' "? In-Reply-To: <5464F958.4070404@stoneleaf.us> References: <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> <5464F958.4070404@stoneleaf.us> Message-ID: <547CF797.4030407@stoneleaf.us> On 11/13/2014 10:32 AM, Ethan Furman wrote: > On 11/12/2014 01:51 PM, Ian Kelly wrote: >> On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote: >>> >>> A decorator is an interesting idea, and should be easy to implement (only >>> lightly tested): >>> >>> def main(func): >>> if func.__module__ == "__main__": >>> func() >>> return func # The return could be omitted to block the function from >>> being manually called after import. >> >> This calls it at the wrong time, though. [...] > > One decorator that won't call too early is atexit.register(). Well, I've tried this out, and it's only okay. As soon as interesting things start happening, spurious errors about thread IDs start printing, which really messes up the user experience [1]. [1] something like Exception KeyError: KeyError(139924387112272,) in ignored -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From ethan at stoneleaf.us Mon Dec 1 19:45:03 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 01 Dec 2014 16:45:03 -0800 Subject: How about some syntactic sugar for " __name__ == '__main__' "? In-Reply-To: <547CF797.4030407@stoneleaf.us> References: <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> <5464F958.4070404@stoneleaf.us> <547CF797.4030407@stoneleaf.us> Message-ID: <547D0B8F.1090906@stoneleaf.us> On 12/01/2014 03:19 PM, Ethan Furman wrote: > > Well, I've tried this out, and it's only okay. As soon as interesting things start happening, spurious errors about > thread IDs start printing, which really messes up the user experience [...] So here's another thought: Have a small python script that loads and runs the actual script -- here's a POC: --- 8< py_main ------------------------------ #!/usr/bin/env python import sys sys.argv.pop(0) try: execfile except NameError: def execfile(file_name, globals): with open(file_name) as fh: script = fh.read() exec(fh, globals) module = {} execfile(sys.argv[0], module) module['main']() --------------------------------------------- Put the above somewhere in your path (e.g. /usr/local/bin), make it executable, and then instead of shebanging your scripts with `/usr/local/bin/python` you can use `/usr/local/bin/py_main`, which will load and execute the script, calling script.main as its last act. -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From rosuav at gmail.com Mon Dec 1 20:15:22 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Dec 2014 12:15:22 +1100 Subject: How about some syntactic sugar for " __name__ == '__main__' "? In-Reply-To: <547D0B8F.1090906@stoneleaf.us> References: <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> <5464F958.4070404@stoneleaf.us> <547CF797.4030407@stoneleaf.us> <547D0B8F.1090906@stoneleaf.us> Message-ID: On Tue, Dec 2, 2014 at 11:45 AM, Ethan Furman wrote: > Put the above somewhere in your path (e.g. /usr/local/bin), make it executable, and then instead of shebanging your > scripts with `/usr/local/bin/python` you can use `/usr/local/bin/py_main`, which will load and execute the script, > calling script.main as its last act. Be aware that this trick (shebanging to a script rather than a binary) isn't specified by the POSIX standard. It works on Linux, but I don't know about other systems. It's a great trick, though. I once had shebangs chained something like three or four levels deep. ChrisA From python.list at tim.thechases.com Mon Dec 1 21:50:00 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 1 Dec 2014 20:50:00 -0600 Subject: Cherrypy - prevent browser "prefetch"? In-Reply-To: <60102F31-5184-4FFF-B99E-23A5B0313399@ravnalaska.net> References: <6B74D6DD-A597-4BCF-8586-D0A56C9CDB77@ravnalaska.net> <20141201152608.09ca6f13@bigbox.christie.dr> <60102F31-5184-4FFF-B99E-23A5B0313399@ravnalaska.net> Message-ID: <20141201205000.56d42532@bigbox.christie.dr> On 2014-12-01 13:14, Israel Brewster wrote: > On Dec 1, 2014, at 12:50 PM, Ned Batchelder >> The way to indicate to a browser that it shouldn't pre-fetch a >> URL is to make it a POST request. > > Ok, that makes sense. The only difficulty I have with that answer > is that to the best of my knowledge the only way to make a HTML > link do a POST is to use the onclick function to run a javascript, > while having the "link" itself point to nothing. Well, generally one would use a form where the method=POST and then the button/input submits it:
This is an input
or
The advantage of a