Re: (new try) - Running a second wsgi script from within the first wsgi script

2018-09-10 Thread Alister via Python-list
On Sun, 09 Sep 2018 18:47:49 -0700, Νίκος Βέργος wrote:

> I have 3 wsgi scripts listening on 3 locations. What i'm trying to run
> an wsgi script from within another wsgi script with the following
> statement.
> 
> page = 'clientele'
> pdata = requests.get( 'http://superhost.gr/' + page )
> pdata = pdata.text + counter page = the location of another wsgi app.
> 
> The error i'am getting when for i.e i try to load
> http://superhost.gr/clientele
> 
> mod_wsgi (pid=7152): Exception occurred processing WSGI script
> '/home/nikos/public_html/app.py'
> OSError: Apache/mod_wsgi failed to write response data: Broken pipe.
> The other script by itself executes normally but NOT from within my
> app.py script.
> 
> Any ideas on how to execute a wsgi app (b) from within a wsgi app(a) and
> store the response as html data?

repeatedly asking the same question will not get you answered any faster
in fact it may simply get you black-listed by many posters



-- 
Why are you so hard to ignore?
-- 
https://mail.python.org/mailman/listinfo/python-list


on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium and getting error

2018-09-10 Thread alon . najman
hi ,
on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium 
and getting an error the Firefox browser is opened automatically :) it just 
don't work I'm not getting the stock value on the print BTW it works on my PC 
with ChromeDriver -

Traceback (most recent call last):
  File "/home/pi/Desktop/Automation RatiL works on PC.py", line 22, in 
driver.get('https://www.investing.com/equities/ratio-par')
  File 
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
 line 248, in get
self.execute(Command.GET, {'url': url})
  File 
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
 line 234, in execute
response = self.command_executor.execute(driver_command, params)
  File 
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py",
 line 401, in execute
return self._request(command_info[0], url, body=data)
  File 
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py",
 line 433, in _request
resp = self._conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line , in getresponse
response.begin()
  File "/usr/lib/python2.7/httplib.py", line 444, in begin
version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 408, in _read_status
raise BadStatusLine(line)
BadStatusLine: ''




thanks all
-- 
https://mail.python.org/mailman/listinfo/python-list


Lightweight Learn Python book

2018-09-10 Thread Abdur-Rahmaan Janhangeer
wrote a small guide on python,
feedbacks appreciated

https://www.pythonmembers.club/wp-content/uploads/2018/09/lightweight_learn_python_draft_1-1.pdf

Abdur-Rahmaan Janhangeer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "glob.glob('weirdness')" Any thoughts?

2018-09-10 Thread Max Zettlmeißl via Python-list
On Sun, Sep 9, 2018 at 2:20 PM, Gilmeh Serda
 wrote:
>
> # Python 3.6.1/Linux
> (acts the same in Python 2.7.3 also, by the way)
>
 from glob import glob
>
 glob('./Testfile *')
> ['./Testfile [comment] some text.txt']
>
 glob('./Testfile [comment]*')
> []
>
 glob('./Testfile [comment? some text.*')
> ['./Testfile [comment] some text.txt']
>

The behaviour is stated rather clearly in the documentation:

For glob:
"No tilde expansion is done, but *, ?, and character ranges expressed
with [] will be correctly matched. This is done by using the
os.scandir() and fnmatch.fnmatch() functions in concert, and not by
actually invoking a subshell." [1]

And then for fnmatch, since that is used by glob:
"For a literal match, wrap the meta-characters in brackets. For
example, '[?]' matches the character '?'." [2]

Therefore glob('./Testfile [[]comment[]]*') is what you are looking
for. It should be straightforward to wrap all the meta-characters
which you want to use in their literal form in square brackets.
The results of your analysis are also stated in the documentation for
the glob patterns [1], so there is no guessing required. Your analysis
about escaping special characters is wrong though.
While backslashes are often used as escape characters, they are not
used in such a fashion everywhere. In this case they are not used as
escape characters, which makes a lot of sense when considering that
the directory separator in Windows is a backslash and additionally
using backslashes as escape characters would lead to quite some
confusion in this case.

[1] https://docs.python.org/3/library/glob.html
[2] https://docs.python.org/3/library/fnmatch.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: don't quite understand mailing list

2018-09-10 Thread Ethan Furman

On 09/06/2018 07:40 PM, Steven D'Aprano wrote:

On Thu, 06 Sep 2018 13:06:22 -0700, Ethan Furman wrote:

On 09/06/2018 12:42 PM, Reto Brunner wrote:


What do you think the link, which is attached to every email you
receive from the list, is for? Listinfo sounds very promising, doesn't
it?

And if you actually go to it you'll find: "To unsubscribe from
Python-list, get a password reminder, or change your subscription
options enter your subscription email address"

So how about you try that?


Reto,  your response is inappropriate.  If you can't be kind and/or
respectful, let someone else respond.


No it wasn't inappropriate, and your attack on Reto is uncalled for.


It was inappropriate, and I wasn't attacking Reto.


Reto's answer was kind and infinitely more respectful than your
unnecessary criticism. As far as I can tell, this is Reto's first post
here. After your hostile and unwelcoming response, I wouldn't be
surprised if it was his last.

His answer was both helpful and an *amazingly* restrained and kind
response to a stupid question[1] asked by somebody claiming to be an
professional software engineer. It was not condescending or mean-
spirited, as you said in another post, nor was it snarky.


Wow.  I suddenly feel like I'm running for political office to get hit 
with such a distortion of facts.



But even had the OP been a total beginner to computing, it was still a
helpful response containing the information needed to solve their
immediate problem (how to unsubscribe from the list) with just the
*tiniest* (and appropriate) hint of reproach to encourage them to learn
how to solve their own problems for themselves so that in future, they
will be a better contributor to whatever discussion forums they might
find themselves on.


Yes, there was some helpful content.  That doesn't excuse the manner of 
delivery.



Ethan, you are a great contributor on many of the Python mailing lists,
but your tone-policing is inappropriate, and your CoC banning of Rick and
Bart back in July was an excessive and uncalled for misuse of moderator
power.


Mailing lists consists of two things: content and tone, and both are 
equally important.  I volunteered to be a moderator for Python List as 
it felt to me like the existing moderators were overwhelmed by the sheer 
volume of this list, and a few bad actors were making this venue an 
unpleasant place to be.



To my shame, I didn't say anything at the time, but I won't be
intimidated any longer by fear of the CoC and accusations of incivility.
I'm speaking up now because your reply to Reto is unwelcoming, unhelpful
and disrespectful, and coming from a moderator who has been known to ban
people, that makes it even more hostile.


Actually, you did say something at the time: 
https://mail.python.org/pipermail/python-list


What I find most interesting in this post, though, is your declaration 
"I won't be intimidated any longer by fear of the CoC" -- it doesn't 
strike me as a scary document; it basically says, "be nice".



[1] Yes, there are such things as stupid questions. If your doctor asked
you "remind me again, which end of the needle goes into your arm?" what
would you do?


I would laugh, because he would be joking.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: don't quite understand mailing list

2018-09-10 Thread Chris Angelico
On Mon, Sep 10, 2018 at 10:03 PM, Ethan Furman  wrote:
> On 09/06/2018 07:40 PM, Steven D'Aprano wrote:
>> Ethan, you are a great contributor on many of the Python mailing lists,
>> but your tone-policing is inappropriate, and your CoC banning of Rick and
>> Bart back in July was an excessive and uncalled for misuse of moderator
>> power.
>>
>> To my shame, I didn't say anything at the time, but I won't be
>> intimidated any longer by fear of the CoC and accusations of incivility.
>> I'm speaking up now because your reply to Reto is unwelcoming, unhelpful
>> and disrespectful, and coming from a moderator who has been known to ban
>> people, that makes it even more hostile.
>
>
> Actually, you did say something at the time:
> https://mail.python.org/pipermail/python-list

Not sure what this link is stating. Did you intend to link directly to
a post? Or are you saying generally that "stuff was said, check the
archive"?

> What I find most interesting in this post, though, is your declaration "I
> won't be intimidated any longer by fear of the CoC" -- it doesn't strike me
> as a scary document; it basically says, "be nice".

It doesn't have to be worded scarily. Suppose the CoC simply said "be
nice" - literally just those two words. It would actually be *more*
scary, because its power would be far more arbitrary and at the whim
of the individual moderators.

Perhaps the mods would be less scary if there were more words in the
CoC, such that we could point to section 5, subsection b2q, paragraph
theta, as an explanation of the ban. I don't think it'd make
python-list a better place, but at least it'd remove any accusations
of "misuse of moderator power".

For what it's worth, I support Ethan's actions - including when I've
been on the receiving end of the criticism. The banning of Rick and
Bart was most assuredly NOT misuse of power, at least not in my
opinion (which, I'm aware, has zero weight, but hey, we all have one).
Maybe people are forgetting that python-list IS a moderated list, and
should be treated as one?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "glob.glob('weirdness')" Any thoughts?

2018-09-10 Thread Max Zettlmeißl via Python-list
On Sun, Sep 9, 2018 at 6:03 PM, Thomas Jollans  wrote:
> On 09/09/2018 02:20 PM, Gilmeh Serda wrote:
>>
>>
>> # Python 3.6.1/Linux
>> (acts the same in Python 2.7.3 also, by the way)
>>
> from glob import glob
>>
>>
> glob('./Testfile *')
>>
>> ['./Testfile [comment] some text.txt']
>>
> glob('./Testfile [comment]*')
>>
>> []
>>
[...]
>
> https://docs.python.org/3/library/glob.html#glob.escape demonstrates a way
> of escaping that works:
>
> glob('./Testfile [[]comment]*')
>

That is about the least correct working solution one could conceive.
Of course your suggested "glob('./Testfile [[]comment]*')" works in
the positive case, but pretty much comes down to a glob('./Testfile
[[]*').
And in the negative case it would provide many false positives. (e.g.
"Testfile [falacy]", "Testfile monty", "Testfile ]not quite" and so
on)
Even if you wanted to use that strange character class, which is not a
good idea (as explained above), using "[[]coment]" would be better,
since there is no reason to repeat a character.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "glob.glob('weirdness')" Any thoughts?

2018-09-10 Thread Thomas Jollans

On 10/09/18 14:40, Max Zettlmeißl via Python-list wrote:

On Sun, Sep 9, 2018 at 6:03 PM, Thomas Jollans  wrote:

https://docs.python.org/3/library/glob.html#glob.escape demonstrates a way
of escaping that works:

glob('./Testfile [[]comment]*')


That is about the least correct working solution one could conceive.
Of course your suggested "glob('./Testfile [[]comment]*')" works in
the positive case, but pretty much comes down to a glob('./Testfile
[[]*').
And in the negative case it would provide many false positives. (e.g.
"Testfile [falacy]", "Testfile monty", "Testfile ]not quite" and so
on)
Even if you wanted to use that strange character class, which is not a
good idea (as explained above), using "[[]coment]" would be better,
since there is no reason to repeat a character.


>>> from glob import glob
>>> glob('test *')
['test comment', 'test [co]mment', 'test [fallacy]', 'test [comments]', 
'test [comment] a']

>>> glob('test [[]*')
['test [co]mment', 'test [fallacy]', 'test [comments]', 'test [comment] a']
>>> glob('test [[]c*')
['test [co]mment', 'test [comments]', 'test [comment] a']
>>> glob('test [[]comment]*')
['test [comment] a']
>>>

I'm escaping the '[' as '[[]'. You can escape the ']' as well if you 
want, but there's no need as a ']' is not special unless it's preceded 
by an unescaped '['.


To match the character class I think you thought my glob was matching, 
you'd have to use '[][comment]' rather than '[[]comment]'.


-- Thomas

--
https://mail.python.org/mailman/listinfo/python-list


Re: "glob.glob('weirdness')" Any thoughts?

2018-09-10 Thread Peter Otten
Max Zettlmeißl via Python-list wrote:

>> glob('./Testfile [[]comment]*')
>>
> 
> That is about the least correct working solution one could conceive.
> Of course your suggested "glob('./Testfile [[]comment]*')" works in
> the positive case, but pretty much comes down to a glob('./Testfile
> [[]*').
> 

If you know regular expressions there is an easy way to verify that you are 
wrong:

>>> import fnmatch
>>> fnmatch.translate("foo [[]bar]*")
'foo\\ [[]bar\\].*\\Z(?ms)'

And if you don't:

>>> re.compile(_, re.DEBUG)
literal 102
literal 111
literal 111
literal 32
literal 91
literal 98
literal 97
literal 114
literal 93
max_repeat 0 4294967295
  any None
at at_end_string
re.compile('foo\\ [[]bar\\].*\\Z(?ms)', re.MULTILINE|re.DOTALL|re.DEBUG)
>>> chr(91)
'['


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: don't quite understand mailing list

2018-09-10 Thread Ethan Furman

On 09/10/2018 05:23 AM, Chris Angelico wrote:

On Mon, Sep 10, 2018 at 10:03 PM, Ethan Furman wrote:



Actually, you did say something at the time:
https://mail.python.org/pipermail/python-list


Not sure what this link is stating. Did you intend to link directly to
a post? Or are you saying generally that "stuff was said, check the
archive"?


No, it was a supposed to be a link, which I obviously mis-copied.  Sorry.

--
~Ethan
--
https://mail.python.org/mailman/listinfo/python-list


Re: don't quite understand mailing list

2018-09-10 Thread Tomasz Rola
On Thu, Sep 06, 2018 at 07:10:10PM +, VanDyk, Richard T wrote:
> Greetings;
> 
> I sent in a question on how to install robot framework on python 3.7
> using pip (or any other way). None of the commands on the >>> seem
> to work for me. I was asked to update the c/c++ runtime which I
> don't know what that means.

In such cases I ask google, like, literally type "update c/c++
runtime" in it.

> I was also asked to subscribe to the mailing list. I did that but
> don't want everyone's submitted question to come to me.

Judging from what you wrote here, you:

a) are going to use Python a bit in a near future

b) have a bit to read before you understand what you are doing

If both a) and b) are true, then I advice that you stay on list and
keep reading whichever mail tingles your curiosity, or even at
random. If you do this for long enough, you will finally learn enough
to solve your problem(s). Maybe you will even be able to unsubscribe
on your very own?

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "glob.glob('weirdness')" Any thoughts?

2018-09-10 Thread Max Zettlmeißl via Python-list
On Mon, Sep 10, 2018 at 3:05 PM, Thomas Jollans  wrote:
 from glob import glob
 glob('test *')
> ['test comment', 'test [co]mment', 'test [fallacy]', 'test [comments]',
> 'test [comment] a']
 glob('test [[]*')
> ['test [co]mment', 'test [fallacy]', 'test [comments]', 'test [comment] a']
 glob('test [[]c*')
> ['test [co]mment', 'test [comments]', 'test [comment] a']
 glob('test [[]comment]*')
> ['test [comment] a']

>
> I'm escaping the '[' as '[[]'. You can escape the ']' as well if you want,
> but there's no need as a ']' is not special unless it's preceded by an
> unescaped '['.
>
> To match the character class I think you thought my glob was matching, you'd
> have to use '[][comment]' rather than '[[]comment]'.
>

That is of course correct.
I'm sorry. Now that I looked at it again, I can't see how I came to
that wrong conclusion.
Your suggested "[][comment]" is exactly what I thought your
"[[]comment]" to be and I can't explain to myself anymore how I came
to that conclusion.

There actually is glob.ecape [1] which escapes all the glob
meta-characters in a path and does so exactly as in your example.
(Since it is obviously the shortest and therefore in this case best
way.)

[1] https://docs.python.org/3/library/glob.html#glob.escape
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: perplexing error

2018-09-10 Thread Peter Pearson
On 8 Sep 2018 19:10:09 GMT, Stefan Ram  wrote:
> Peter Pearson  writes:
>>On 8 Sep 2018 17:25:52 GMT, Stefan Ram  wrote:
>>>In such cases, I do:
>>>print( 'at position 1' )
>>This approach is especially valuable when it turns out that
>>the file you're editing is not the file being included.
>
>   I am not sure whether this is taken to be literally or as
>   being sarcastic.
[snip]

No sarcasm intended.  I've made the editing-wrong-file goof many times.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: perplexing error

2018-09-10 Thread Chris Angelico
On Tue, Sep 11, 2018 at 7:50 AM, Peter Pearson
 wrote:
> On 8 Sep 2018 19:10:09 GMT, Stefan Ram  wrote:
>> Peter Pearson  writes:
>>>On 8 Sep 2018 17:25:52 GMT, Stefan Ram  wrote:
In such cases, I do:
print( 'at position 1' )
>>>This approach is especially valuable when it turns out that
>>>the file you're editing is not the file being included.
>>
>>   I am not sure whether this is taken to be literally or as
>>   being sarcastic.
> [snip]
>
> No sarcasm intended.  I've made the editing-wrong-file goof many times.
>

Me too. Or it's the right file, but not being deployed correctly. Or
you're working on the wrong computer (especially if you have editors
open via SSH). Or you just plain forgot to save... This sort of smoke
test is invaluable.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


logging module - how to include method's class name when using %(funcName)

2018-09-10 Thread Malcolm Greene
I'm using the Python logging module and looking for a way to include a
method's class name when using %(funcName). Is this possible? When you
have several related classes, just getting the function (method) name is
not enough information to provide context on the code being executed.
I'm outputting module name and line number so I can always go back and
double check a caller's location in source, but that seems like an
archaic way to find this type of information.
Thank you,
Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium and getting error

2018-09-10 Thread dieter
alon.naj...@gmail.com writes:

> on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium 
> and getting an error the Firefox browser is opened automatically :) it just 
> don't work I'm not getting the stock value on the print BTW it works on my PC 
> with ChromeDriver -
>
> Traceback (most recent call last):
> ...
>   File "/usr/lib/python2.7/httplib.py", line 408, in _read_status
> raise BadStatusLine(line)
> BadStatusLine: ''

This means that the (HTTP/HTTPS) server response in not valid HTTP --
maybe, because the server died during the request processing.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: logging module - how to include method's class name when using %(funcName)

2018-09-10 Thread dieter
Malcolm Greene  writes:
> I'm using the Python logging module and looking for a way to include a
> method's class name when using %(funcName). Is this possible?

If it does not happen automatically, the standard logging components
will not let you do it (the name "funcName" is rather explicit;
you get what the name promises).

However, all logging components can be customized. The logging
implementation has a fine grained architecture (read the
documentation of the "logging" package). The component
for your kind of customization is likely called "formatter".
By registering you own "formatter", you will be able to get
what you want.

-- 
https://mail.python.org/mailman/listinfo/python-list