ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol

2017-12-15 Thread Piyush Verma
Getting SSL error while connecting from httplib.HTTPSConnection.

Any help would be appreciated.

self.connection.request(method, request, payload, self.headers)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1053, in request
self._send_request(method, url, body, headers)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1093, in _send_request
self.endheaders(body)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1049, in endheaders
self._send_output(message_body)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 893, in _send_output
self.send(msg)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 855, in send
self.connect()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
line 1274, in connect
server_hostname=server_hostname)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
line 352, in wrap_socket
_context=self)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
line 579, in __init__
self.do_handshake()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
line 808, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

Regards,
~Piyush
Facebook  Twitter

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


Re: ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol

2017-12-17 Thread Piyush Verma
Yes Dieter, I see that it is connecting with 443 port number and service is
running. Is this related to python version or mac?

Regards,
~Piyush
Facebook <https://www.facebook.com/piyushkv1> Twitter
<https://twitter.com/SocializePiyush>

On Sat, Dec 16, 2017 at 1:59 PM, dieter  wrote:

> Piyush Verma <114piy...@gmail.com> writes:
>
> > Getting SSL error while connecting from httplib.HTTPSConnection.
> >
> > Any help would be appreciated.
> > ...
> > line 579, in __init__
> > self.do_handshake()
> >   File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/ssl.py",
> > line 808, in do_handshake
> > self._sslobj.do_handshake()
> > ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
>
> Are you sure, you try to connect to an HTTPS port?
>
> The error message tells you that the "ssl" handshake failed because
> the protocol was unknown (likely because the message was not understood).
> The most natural reason is to try to connect to something which is not
> prepared for an "ssl" handshake.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol

2017-12-18 Thread Piyush Verma
Hi Chris, Yes it is HTTPS server. I was debugging and found some relevant
data which may help to identify the problem.

In my Mac OS, I have two version of openssl version installed. default was
/usr/bin/openssl, which i changed to brew installed one.
(virtenv) $ /usr/bin/openssl version
OpenSSL 0.9.8zh 14 Jan 2016
(virtenv) $ openssl version
OpenSSL 1.0.2n  7 Dec 2017

In my python code when I printed the ssl version, python still taking the
system installed ssl version in my Mac OS. I think same problem in my code,
how can I make python to understand to take latest ssl?
import ssl
ssl.OPENSSL_VERSION
'OpenSSL 0.9.8zh 14 Jan 2016'





Regards,
~Piyush
Facebook <https://www.facebook.com/piyushkv1> Twitter
<https://twitter.com/SocializePiyush>

On Mon, Dec 18, 2017 at 2:49 AM, Chris Angelico  wrote:

> On Mon, Dec 18, 2017 at 6:28 AM, Piyush Verma <114piy...@gmail.com> wrote:
> > Yes Dieter, I see that it is connecting with 443 port number and service
> is
> > running. Is this related to python version or mac?
>
> Can you confirm that it really is an HTTPS server, not just an HTTP
> server that's running on port 443? Try accessing it using a web
> browser or some other program.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Catch exception with message?

2016-06-03 Thread Piyush Verma
Generally we catch exception using
except Exception as e:

But sometimes, we see same type of exception is present with different
message.Is there a way to capture same exception with message
filtering? Please help me to do this.

Regards,
~Piyush
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Catch exception with message?

2016-06-03 Thread Piyush Verma
Below is exception type and it is user defined exception. I do not see
error number in exception stack. What other option we can use as
filter in below exception apart from message?

UserDefinedException: User defined message: {}
#012  File "/opt/cio/lib/python2.7/site-packages/manager.py", line
1100, in create_from_abc
#012yield self.create(x, name, description)
#012  File "/opt/cio/lib/python2.7/site-packages/manager.py", line
1132, in create
#012'errors.create.type_not_supported.{0}'.format(abc['type']),


On Sat, Jun 4, 2016 at 6:12 AM, Random832  wrote:
> On Fri, Jun 3, 2016, at 19:14, Piyush Verma wrote:
>> Generally we catch exception using
>> except Exception as e:
>>
>> But sometimes, we see same type of exception is present with different
>> message.Is there a way to capture same exception with message
>> filtering? Please help me to do this.
>
> The message is meant to be human-readable, and may change without
> warning. Is there no other property on the exceptions you want to catch
> that can be used to distinguish them? (errno, perhaps?) What's your
> specific use case?
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


How do we pass default argument value to create thread object?

2014-03-12 Thread Piyush Verma
Hi,

I am using Thread class to create threads.

thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"])
thread.start()


This code is throwing compilation error(Ipython).
In [19]: import threading

In [20]: def Fun(agr1, arg2, arg3=None):
   : pass
   :

In [21]: thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"
])

   File "", line 1
 thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"])
 ^
SyntaxError: invalid syntax

How do we pass the value to default arguments while creating thread object?

Regards,
~Piyush
Facebook 
Twitter
-- 
https://mail.python.org/mailman/listinfo/python-list


PUDB Traceback

2015-05-27 Thread Piyush Verma
Hi,

I'm facing traceback when using pudb python debugger to debug. Any help to
resolve it.

# python -m pudb file.py 
main()
  File "/usr/local/lib/python2.7/dist-packages/pudb/run.py", line 30, in
main
steal_output=options.steal_output)
  File "/usr/local/lib/python2.7/dist-packages/pudb/__init__.py", line 84,
in runscript
dbg.interaction(None, sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/pudb/debugger.py", line 338,
in interaction
show_exc_dialog=show_exc_dialog)
  File "/usr/local/lib/python2.7/dist-packages/pudb/debugger.py", line
2020, in call_with_ui
return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pudb/debugger.py", line
2212, in interaction
self.show_exception_dialog(exc_tuple)
  File "/usr/local/lib/python2.7/dist-packages/pudb/debugger.py", line
1966, in show_exception_dialog
("Save traceback", "save"),
  File "/usr/local/lib/python2.7/dist-packages/pudb/debugger.py", line
1939, in dialog
return self.event_loop(w)[0]
  File "/usr/local/lib/python2.7/dist-packages/pudb/debugger.py", line
2185, in event_loop
keys = self.screen.get_input()
  File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line
324, in get_input
keys, raw = self.parse_input(None, None, self.get_available_raw_input())
  File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line
426, in get_available_raw_input
codes = self._get_gpm_codes() + self._get_keyboard_codes()
  File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line
500, in _get_keyboard_codes
code = self._getch_nodelay()
  File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line
634, in _getch_nodelay
return self._getch(0)
  File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line
544, in _getch
return ord(os.read(self._term_input_file.fileno(), 1))
TypeError: ord() expected a character, but string of length 0 found

Regards,
~Piyush
-- 
https://mail.python.org/mailman/listinfo/python-list


thread.interrupt_main() behaviour

2014-07-01 Thread Piyush Verma
Hi,

What is the behavior when we call thread.interrupt_main() method.

Using this method I have implemented a new method for checking timeout.

359def TimeoutFunc(self):360   '''Function invoked by timer
thread in case of timeout '''361   self.log.debug("Timeout thread
invoked now for test %s" % self.name)362   self.isTimeout =
True363   #Interrupt test process364   thread.interrupt_main()

Above method is invoked correctly, but I am not able to understand the
behaviour. Please have a look into below diagram to explain which I am
using.

[image: Inline image 1]


Since two threads are running same method, I wanted to know which main
thread will be interrupted in both case.

Regards,
~Piyush
Facebook  Twitter

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