Re: search for a data in my browser via script

2017-02-07 Thread Meeran Rizvi
On Monday, February 6, 2017 at 8:13:17 PM UTC+5:30, Meeran Rizvi wrote:
> Hello guys,
> Here i am writing a script which will open my chrome browser and opens the 
> URL www.google.com.
> But how to search for a data via script.
> for example i need to search for 'Rose' in google.com via script.
> how to do that?
> 
> 
> import webbrowser
> url="www.google.com"
> chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %s'
> webbrowser.get(chrome_path)
> webbrowser.open(url)
> 

This works as easy,when you search for a data in google.com via chrome

import webbrowser
search_word = 'Rose'
url = 'https://www.google.com/#q={}'.format(search_word)
chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %s'
webbrowser.get(chrome_path)
webbrowser.open(url)

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


Re: Strategies when hunting for dictionary corruption

2017-02-07 Thread dieter
Skip Montanaro  writes:

> I'm wrapping some C++ libraries using pybind11. On the pybind11 side of
> things, I've written a simple type converter between Python's datetime.date
> objects and our internal C++ date objects. The first thing the type
> converter needs to do is to insure that the datetime C API is initialized:
>
> if (!PyDateTimeAPI) { PyDateTime_IMPORT; }
>
> This is failing because a dictionary internal to the import mechanism is
> being corrupted, the extensions dict in import.c. I highly doubt this is a
> Python issue. It's much more likely to be a bug in our C++ libraries or in
> pybind11.
>
> The problem is, dictionaries being rather dynamic objects (growing and
> sometimes shrinking), the actual data location which might be corrupted
> isn't fixed, but can move around. I've got a Python interpreter configured
> using --with-pydebug, it's compiled with -ggdb -O0, and I'm ready to watch
> some memory locations, but it's not clear what exactly I should watch or
> how/when to move my watchpoint(s) around. Should I not be thinking in terms
> of watchpoints? Is there a better way to approach this problem? (I also
> have valgrind at my disposal, but am not very skilled in its use.)

I would use a form of binary search approach -- unless there is
an obvious cause, such as GIL not hold.

For the "binary search approach", you would need a non destructive way
to detect the corruption during a "gdb" debugging session.
There is a set of "gdb" macros to manage (e.g. print out) Python
objects from the debugger. Based on them, you might develop similar
macros to access dicts and check for their validity.
Once you have a way to detect the corruption, you can step into
the "PyDateTime_IMPORT" and find out where the corruption happens.

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


Re: Strategies when hunting for dictionary corruption

2017-02-07 Thread Erik

On 06/02/17 12:56, Skip Montanaro wrote:

Is there a better way to approach this problem? (I also
have valgrind at my disposal, but am not very skilled in its use.)


valgrind is what I was going to suggest. You have to compile Python with 
extra flags to get it to integrate well with valgrind though, because of 
its custom allocators (if you're just trying to run it now and are 
confused by the results, that might be why).


valgrind (or rather, valgrind's "memcheck" module) has command line 
flags for giving deeper information than the default, but at the expense 
of tracking more and slowing things down.


E.

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


How to configure SSL client trusted CA certificates?

2017-02-07 Thread gangyang7
Hi,



I'm using Python 3.X (3.5 on Windows 2008 and 3.4 on CentOS 6.7) and 
encountered an SSL client side CA certificates issue. The issue came up when a 
third-party package (django-cas-ng) tried to verify the CAS service ticket (ST) 
by calling CAS server using requests.get(...) and failed with 
CERTIFICATE_VERIFY_FAILED error. The CAS server is accessed by HTTPS with a 
self-signed server certificate. Following some suggestions on the internet, 
I've tried to modify django-cas-ng's code to call requests.get(..) with verify 
parameter, such as requests.get(..., verify=False) and requests.get(..., 
verify="CAS server cert"). Both workarounds worked, but I can't change 
third-party package code. I also tried to add the CAS server cert to the 
underlying OS (Windows 2008 and CentOS 6.7), but it did not help.



My question is where does SSL client code get the trusted CA certificates from, 
from Python or the underlying OS? What configuration do I need in order for the 
SSL client to conduct the SSL handshake successfully?



Appreciate any help!



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


How to configure trusted CA certificates for SSL client?

2017-02-07 Thread Yang, Gang CTR (US)
Hi,



I'm using Python 3.X (3.5 on Windows 2008 and 3.4 on CentOS 6.7) and 
encountered an SSL client side CA certificates issue. The issue came up when a 
third-party package (django-cas-ng) tried to verify the CAS service ticket (ST) 
by calling CAS server using requests.get(...) and failed with 
CERTIFICATE_VERIFY_FAILED error. The CAS server is accessed by HTTPS with a 
self-signed server certificate. Following some suggestions on the internet, 
I've tried to modify django-cas-ng's code to call requests.get(..) with verify 
parameter, such as requests.get(..., verify=False) and requests.get(..., 
verify="CAS server cert"). Both workarounds worked, but I can't change 
third-party package code. I also tried to add the CAS server cert to the 
underlying OS (Windows 2008 and CentOS 6.7), but it did not help.



My question is where does SSL client code get the trusted CA certificates from, 
from Python or the underlying OS? What configuration do I need in order for the 
SSL client to conduct the SSL handshake successfully?



Appreciate any help!



Gang



Gang Yang

Shonborn-Becker Systems Inc. (SBSI)
Contractor Engineering Supporting SEC
Office: 732-982-8561, x427

Cell: 732-788-7501
Email: gang.yang@mail.mil
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Strategies when hunting for dictionary corruption

2017-02-07 Thread Ethan Furman

On 02/06/2017 04:56 AM, Skip Montanaro wrote:


I'm wrapping some C++ libraries using pybind11.


I asked one of the core-devs about it, and he suggested:


Python 3.6 got a new C define in Objects/dictobjet.c
which might help to track the bug:

/* Uncomment to check the dict content in _PyDict_CheckConsistency() */
/* #define DEBUG_PYDICT */

Uncomment and recompile Python (in debug mode).

Victor


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


Re: Coding issue with XML for word document

2017-02-07 Thread Deborah_Swanson
From: "Deborah Swanson" 

I don't see any Python in your code. The python.org list isn't generally
familiar with Microsoft proprietary code, which is often quite different from
other versions. Try asking this question in Microsoft's Office/Word Document
forums. Good luck!


accessnew...@gmail.com wrote, on February 06, 2017 5:00 PM Subject: Coding
issue with XML for word document
>
>
> I am constructing a sentence to insert into a word xml
> template. My code is below
>
> 
> #Create a list
>
> if len(myList) > 0:
> if len(myList) > 1:
> testText = list_format(myList) + " dealers."
> else:
> myText = myList[0] + " dealer."
>
> #Contruct sentence
>
> #myBlurb = "My
> Favorite Cars -  My favorite cars are
> available at "  + myText + ""
> myBlurb = "My Favorite Cars - My favorite cars are
> available at " + myText + ""
> else:
> myBlurb = ""
>
>
> ---
>
> If a list exists (not = 0) Then
>
> I am trying to get the following output:
>
> My Favorite Cars - My favorite cars are available at (list of
> dealers) dealers.
>
> There is a newline above and below this line. The first three
> words and the dash are bold. All other words are regular.
>
> This works
>
> myBlurb = "My Favorite Cars - My favorite cars are
> available at " + myText + ""
>
> But when I try to bold, it bombs. It does not seem to like
> either of these (+ myText + "") (separately or
> together) appended on the end.
>
> Thia does not work
>
> myBlurb = "My Favorite
> Cars -  My favorite cars are available
> at "  + myText + "
>
> What am I missing here?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Re: How to add months to a date (datetime object)?

2017-02-07 Thread John_Gordon
From: John Gordon 

In  "Deborah Swanson"
 writes:

> bajimicb...@gmail.com wrote, on February 02, 2017 2:44 AM
> >
> > for start of month to the beginning of next month
> >
> > from datetime import timedelta
> > from dateutil.relativedelta import relativedelta
> >
> > end_date = start_date + relativedelta(months=delta_period) +
> > timedelta(days=-delta_period)

> Where do you define 'delta_period', and what is your question?

There is no question; it is an answer in response to the original post asking
how to add months to a datetime object.

--
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: search for a data in my browser via script

2017-02-07 Thread kelvidpang
From: kelvidp...@gmail.com

On Monday, 6 February 2017 22:43:17 UTC+8, Meeran Rizvi  wrote:
> Hello guys,
> Here i am writing a script which will open my chrome browser and opens the
URL www.google.com.
> But how to search for a data via script.
> for example i need to search for 'Rose' in google.com via script.
> how to do that?
>
> 
> import webbrowser
> url="www.google.com"
> chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
%s'
> webbrowser.get(chrome_path)
> webbrowser.open(url)
> 


You may try to search for selenium for python, which has chrome driver.. it
works like charm.

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


RE: Coding issue with XML for word document

2017-02-07 Thread Deborah Swanson
Cute, whoever you are. Very cute. (I know how to sign up for fake email
addresses too.)

> -Original Message-
> From: Python-list 
> [mailto:python-list-bounces+python=deborahswanson.net@python.o
> rg] On Behalf Of Deborah_Swanson@f38.n261.z1
> Sent: Monday, February 06, 2017 9:52 AM
> To: python-list@python.org
> Subject: Re: Coding issue with XML for word document
> 
> 
> From: "Deborah Swanson" 
> 
> I don't see any Python in your code. The python.org list 
> isn't generally familiar with Microsoft proprietary code, 
> which is often quite different from other versions. Try 
> asking this question in Microsoft's Office/Word Document 
> forums. Good luck!
> 
> 
> accessnew...@gmail.com wrote, on February 06, 2017 5:00 PM 
> Subject: Coding issue with XML for word document
> >
> >
> > I am constructing a sentence to insert into a word xml template. My 
> > code is below
> >
> > 
> > #Create a list
> >
> > if len(myList) > 0:
> > if len(myList) > 1:
> > testText = list_format(myList) + " dealers."
> > else:
> > myText = myList[0] + " dealer."
> >
> > #Contruct sentence
> >
> > #myBlurb = "My
> > Favorite Cars -  My favorite cars are 
> available 
> > at "  + myText + ""
> > myBlurb = "My Favorite Cars - My favorite cars are 
> > available at " + myText + ""
> > else:
> > myBlurb = ""
> >
> >
> > ---
> >
> > If a list exists (not = 0) Then
> >
> > I am trying to get the following output:
> >
> > My Favorite Cars - My favorite cars are available at (list of
> > dealers) dealers.
> >
> > There is a newline above and below this line. The first three words 
> > and the dash are bold. All other words are regular.
> >
> > This works
> >
> > myBlurb = "My Favorite Cars - My favorite cars are 
> available at 
> > " + myText + ""
> >
> > But when I try to bold, it bombs. It does not seem to like 
> either of 
> > these (+ myText + "") (separately or
> > together) appended on the end.
> >
> > Thia does not work
> >
> > myBlurb = "My Favorite Cars - 
> >  My favorite cars are available at 
> "  
> > + myText + "
> >
> > What am I missing here?
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: Coding issue with XML for word document

2017-02-07 Thread Deborah_Swanson
From: Deborah_Swanson@f38.n261.z1

From: "Deborah Swanson" 

I don't see any Python in your code. The python.org list isn't generally
familiar with Microsoft proprietary code, which is often quite different from
other versions. Try asking this question in Microsoft's Office/Word Document
forums. Good luck!


accessnew...@gmail.com wrote, on February 06, 2017 5:00 PM Subject: Coding
issue with XML for word document
>
>
> I am constructing a sentence to insert into a word xml
> template. My code is below
>
> 
> #Create a list
>
> if len(myList) > 0:
> if len(myList) > 1:
> testText = list_format(myList) + " dealers."
> else:
> myText = myList[0] + " dealer."
>
> #Contruct sentence
>
> #myBlurb = "My
> Favorite Cars -  My favorite cars are
> available at "  + myText + ""
> myBlurb = "My Favorite Cars - My favorite cars are
> available at " + myText + ""
> else:
> myBlurb = ""
>
>
> ---
>
> If a list exists (not = 0) Then
>
> I am trying to get the following output:
>
> My Favorite Cars - My favorite cars are available at (list of
> dealers) dealers.
>
> There is a newline above and below this line. The first three
> words and the dash are bold. All other words are regular.
>
> This works
>
> myBlurb = "My Favorite Cars - My favorite cars are
> available at " + myText + ""
>
> But when I try to bold, it bombs. It does not seem to like
> either of these (+ myText + "") (separately or
> together) appended on the end.
>
> Thia does not work
>
> myBlurb = "My Favorite
> Cars -  My favorite cars are available
> at "  + myText + "
>
> What am I missing here?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Re: How to add months to a date (datetime object)?

2017-02-07 Thread John_Gordon
From: John_Gordon@f38.n261.z1

From: John Gordon 

In  "Deborah Swanson"
 writes:

> bajimicb...@gmail.com wrote, on February 02, 2017 2:44 AM
> >
> > for start of month to the beginning of next month
> >
> > from datetime import timedelta
> > from dateutil.relativedelta import relativedelta
> >
> > end_date = start_date + relativedelta(months=delta_period) +
> > timedelta(days=-delta_period)

> Where do you define 'delta_period', and what is your question?

There is no question; it is an answer in response to the original post asking
how to add months to a datetime object.

--
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: search for a data in my browser via script

2017-02-07 Thread kelvidpang
From: kelvidpang@f38.n261.z1

From: kelvidp...@gmail.com

On Monday, 6 February 2017 22:43:17 UTC+8, Meeran Rizvi  wrote:
> Hello guys,
> Here i am writing a script which will open my chrome browser and opens the
URL www.google.com.
> But how to search for a data via script.
> for example i need to search for 'Rose' in google.com via script.
> how to do that?
>
> 
> import webbrowser
> url="www.google.com"
> chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
%s'
> webbrowser.get(chrome_path)
> webbrowser.open(url)
> 


You may try to search for selenium for python, which has chrome driver.. it
works like charm.

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


What's with all the messages from @f38.n261.z1

2017-02-07 Thread Michael Torrie
Seems like we're getting a bunch of messages on the mailing list that
appear to be copies of real member posts that are saying they are from
@f38.n261.z1?  They don't appear to be deliberate impersonations.  Some
misconfigured server reflecting messages back to the list perhaps?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Strategies when hunting for dictionary corruption

2017-02-07 Thread Skip Montanaro
Thanks all. I am stuck on 2.7 for the foreseeable future, so the
DEBUG_PYDICT won't help. I think we're set though. for the moment, we
seem to have moved past that bug (might have just been ordering in the
pybind11 wrapper).

Skip

On Tue, Feb 7, 2017 at 12:35 PM, Ethan Furman  wrote:
> On 02/06/2017 04:56 AM, Skip Montanaro wrote:
>
>> I'm wrapping some C++ libraries using pybind11.
>
>
> I asked one of the core-devs about it, and he suggested:
>
>> Python 3.6 got a new C define in Objects/dictobjet.c
>> which might help to track the bug:
>>
>> /* Uncomment to check the dict content in _PyDict_CheckConsistency() */
>> /* #define DEBUG_PYDICT */
>>
>> Uncomment and recompile Python (in debug mode).
>>
>> Victor
>
>
> --
> ~Ethan~
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's with all the messages from @f38.n261.z1

2017-02-07 Thread Random832
On Tue, Feb 7, 2017, at 15:08, Michael Torrie wrote:
> Seems like we're getting a bunch of messages on the mailing list that
> appear to be copies of real member posts that are saying they are from
> @f38.n261.z1?  They don't appear to be deliberate impersonations.  Some
> misconfigured server reflecting messages back to the list perhaps?

Looking at it (compared to the original), It has Usenet headers for
comp.lang.python (and a path header indicating an origin at
eternal-september.org), and headers associated with FidoNet and
something called "Prism BBS".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-07 Thread Pavol Lisy
On 2/6/17, Chris Angelico  wrote:
> On Mon, Feb 6, 2017 at 1:19 PM, Steve D'Aprano
>  wrote:

[...]

>> How about graphic and video designers? Just how well does hg cope with
>> gigabytes of video data?
>
> I've no idea, but I know that git can handle large amounts of data.
> (There are a couple of extensions that make it easier.)

But there could be problem with "keeping eye" part of your premise.
("If you commit everything to git and keep an eye on your diffs before
you push, the encryption would have to be _extremely_ sneaky").
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to ensure './' is at beginning of sys.path?

2017-02-07 Thread Chris Angelico
On Wed, Feb 8, 2017 at 8:22 AM, Pavol Lisy  wrote:
>>> How about graphic and video designers? Just how well does hg cope with
>>> gigabytes of video data?
>>
>> I've no idea, but I know that git can handle large amounts of data.
>> (There are a couple of extensions that make it easier.)
>
> But there could be problem with "keeping eye" part of your premise.
> ("If you commit everything to git and keep an eye on your diffs before
> you push, the encryption would have to be _extremely_ sneaky").

True, which is why as much as possible should be done with raw video
data that never changes, and then text files that indicate the
alterations. The raw video data gets recorded once and then kept
as-is, and then your editing work gets saved into some textual form
(maybe a JSON file, maybe a series of commands) that you can plausibly
diff. The only time you actually add binary files is when you do
initial recording work, and a diff that affects those files should
always be suspicious.

(Obviously it would be horrendously inefficient to work from the raw
files all the time. But the edited files could be gitignored, since
they can be reconstructed from the originals; share them for
convenience, but don't sweat their loss.)

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


Re: Coding issue with XML for word document

2017-02-07 Thread Pavol Lisy
On 2/7/17, Steven D'Aprano  wrote:
> On Mon, 06 Feb 2017 17:00:25 -0800, accessnewbie wrote:
[...]
>> But when I try to bold, it bombs. It does not seem to like either of
>> these (+ myText + "") (separately or together) appended on the
>> end.
>
> How are you trying to bold? If you're programming in a word processor,
> and you apply bold to your code, that won't work.
>
> What do you mean, "bombs"? Do you literally mean you are running a
> classic Macintosh from the 1990s and you are getting a fatal System Error
> in a "Bomb" dialog box?
>
> Otherwise, please be more precise: do you get a Blue Screen of Death? A
> kernel panic? Does the Python interpreter segfault? Or do you get an
> ordinary Python traceback?
>
> If it is an ordinary Python traceback, don't keep it a secret -- tell us
> what it says. COPY AND PASTE the traceback, in full, not just the last
> line.

I am afraid he means that it create mishmash in word document...

Dear accessnewbie I propose divide problem to smaller subproblems.

For example make python code as simple as possible (avoid python part
if you could! As Deborah wrote it is very probably not problem in
python)

And try to explicitly try to write example text where is bold part.
#myBlurb = "My Favorite Cars -
 My favorite cars are available at "
 + myText + ""
myBlurb = "My Favorite Cars -
 My favorite cars are available at 
my garage "

if it is still wrong try to make more and more similar text to:
myBlurb = "My Favorite Cars - My favorite cars are available at
my garage"

I mean for example remove "" part etc.

Second - This is probably not your problem (unless you have special
char in your example myList) but if you could have xml spec chars in
your input then python could help. See example ->

>>> from xml.sax.saxutils import escape
>>> escape("< & >")
'< & >'

myBlurb = "My Favorite Cars - My favorite cars are available at
" + escape(myText) + ""  # this is safer than your code!

I hope you understand why it is useful. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to configure trusted CA certificates for SSL client?

2017-02-07 Thread MeV
On Tuesday, February 7, 2017 at 9:42:54 AM UTC-8, Yang, Gang CTR (US) wrote:

> My question is where does SSL client code get the trusted CA certificates 
> from, from Python or the underlying OS? What configuration do I need in order 
> for the SSL client to conduct the SSL handshake successfully?
> 

When I setup TLS for a K/V pair database with self-signed certs, I could supply 
two types of certs

-peer certs with the IP and DNS name tied to the node signed by the self-signed 
CA I generated
-client cert that had the IP and DNS for ALL the machines in the cluster signed 
by the CA

To connect to the any of the clients, I had to provide the client cert, key, 
and the CA.  That's just the way the software built.

For browsers, each browser has a CA from various authorities and you add an 
intermediate key signed by one of those authorities (e.g. Verisign which costs 
$2000) to the browser to allow you to access a specific domain through a 
wildcard cert.  My K/V software didn't support that.

Look at how CentOS 6 stores it's certs in /etc/pki.  I think where you'd put 
your CA + client key bundle.  Which means you have to do this for all machines 
that run your code.  That's not optimal or at all portable.  You'll probably 
have to deliver the app as a VM or a docker container to put it all together.

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