[Chennaipy] Chennaipy Digest, Vol 54, Issue 16

Venkata Raman S S ssv5088 at gmail.com
Fri Feb 23 05:35:15 EST 2018


Hi Karthikeyan,

There could be some SSL certificate handling  issue from within python.

Please see  if it works for you after adding the follow code snippet to
your code.

try:
    import _ssl
    _ssl.PROTOCOL_SSLv23 = _ssl.PROTOCOL_TLSv1
except:
    traceback.print_exc()
    pass


On 23 February 2018 at 15:59, <chennaipy-request at python.org> wrote:

> Send Chennaipy mailing list submissions to
>         chennaipy at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/chennaipy
> or, via email, send a message with subject or body 'help' to
>         chennaipy-request at python.org
>
> You can reach the person managing the list at
>         chennaipy-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Chennaipy digest..."
>
>
> Today's Topics:
>
>    1. Re: Require help in code (Karthikeyan S)
>    2. Re: Require help in code (Karthikeyan S)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 23 Feb 2018 15:55:46 +0530
> From: Karthikeyan S <karthik120 at gmail.com>
> To: Chennai Python User Group Mailing List <chennaipy at python.org>
> Subject: Re: [Chennaipy] Require help in code
> Message-ID:
>         <CAFPraRy0zAJMLeSe1FydX6qXkNTra-a23YA+eoaCRYDha+vfSg at mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I saw this sort of code with session in the stackoverflow and I tried it
> before posting it in the forum.. The error remains the same.
>
> On Fri, Feb 23, 2018 at 3:52 PM, Bharathwaaj S <bharath at testpress.in>
> wrote:
>
> > Try using session.
> >
> > import requests,time,json
> >
> > session = requests.Session()
> > adapter = requests.adapters.HTTPAdapter(max_retries = 5)
> > session.mount('http://', adapter)
> >
> > fobj = open("file")
> > for x in fobj:
> >        x = x.replace("\n", "")
> >        url="https://username:password@localhost/jenkins/job/job-name/
> > buildWithParameters"
> >        params = {'BRANCH':x}
> >        headers = {"Content-Type": "application/xml"}
> >        r = *session*.post(url , params=params, verify=False)
> >        print(r.status_code)
> >        print(r.text)
> >        #time.sleep(45)
> > fobj.close()
> >
> >
> >
> > On Fri, Feb 23, 2018 at 3:37 PM, Karthikeyan S <karthik120 at gmail.com>
> > wrote:
> >
> >> Yes, via CURL command it works perfectly.
> >>
> >> On Fri, Feb 23, 2018 at 3:13 PM, Shrayas rajagopal <shrayasr at gmail.com>
> >> wrote:
> >>
> >>> Hi Karthikeyan,
> >>>
> >>> On Fri, Feb 23, 2018 at 3:02 PM, Karthikeyan S <karthik120 at gmail.com>
> >>> wrote:
> >>>
> >>> [...]
> >>>
> >>> > Could you please help ?
> >>>
> >>> Are you able to execute the same thing outside of python? i.e. with
> >>> another RESTful client like postman?
> >>>
> >>> Regards,
> >>> Shrayas
> >>> _______________________________________________
> >>> Chennaipy mailing list
> >>> Chennaipy at python.org
> >>> https://mail.python.org/mailman/listinfo/chennaipy
> >>>
> >>
> >>
> >> _______________________________________________
> >> Chennaipy mailing list
> >> Chennaipy at python.org
> >> https://mail.python.org/mailman/listinfo/chennaipy
> >>
> >>
> >
> > _______________________________________________
> > Chennaipy mailing list
> > Chennaipy at python.org
> > https://mail.python.org/mailman/listinfo/chennaipy
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/chennaipy/
> attachments/20180223/b59479bf/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 23 Feb 2018 15:59:01 +0530
> From: Karthikeyan S <karthik120 at gmail.com>
> To: Chennai Python User Group Mailing List <chennaipy at python.org>
> Subject: Re: [Chennaipy] Require help in code
> Message-ID:
>         <CAFPraRzOD+M0cQpoTnCNojDiuswm2QZ_-FDy=Xss
> 4bANohKwvw at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Changing it to sessions resulted in the error below
>
> (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection
> object at 0x106278610>: Failed to establish a new connection: [Errno 8]
> nodename nor servname provided, or not known',))
>
> On Fri, Feb 23, 2018 at 3:55 PM, Karthikeyan S <karthik120 at gmail.com>
> wrote:
>
> > I saw this sort of code with session in the stackoverflow and I tried it
> > before posting it in the forum.. The error remains the same.
> >
> > On Fri, Feb 23, 2018 at 3:52 PM, Bharathwaaj S <bharath at testpress.in>
> > wrote:
> >
> >> Try using session.
> >>
> >> import requests,time,json
> >>
> >> session = requests.Session()
> >> adapter = requests.adapters.HTTPAdapter(max_retries = 5)
> >> session.mount('http://', adapter)
> >>
> >> fobj = open("file")
> >> for x in fobj:
> >>        x = x.replace("\n", "")
> >>        url="https://username:password@localhost/jenkins/job/job-name/
> >> buildWithParameters"
> >>        params = {'BRANCH':x}
> >>        headers = {"Content-Type": "application/xml"}
> >>        r = *session*.post(url , params=params, verify=False)
> >>        print(r.status_code)
> >>        print(r.text)
> >>        #time.sleep(45)
> >> fobj.close()
> >>
> >>
> >>
> >> On Fri, Feb 23, 2018 at 3:37 PM, Karthikeyan S <karthik120 at gmail.com>
> >> wrote:
> >>
> >>> Yes, via CURL command it works perfectly.
> >>>
> >>> On Fri, Feb 23, 2018 at 3:13 PM, Shrayas rajagopal <shrayasr at gmail.com
> >
> >>> wrote:
> >>>
> >>>> Hi Karthikeyan,
> >>>>
> >>>> On Fri, Feb 23, 2018 at 3:02 PM, Karthikeyan S <karthik120 at gmail.com>
> >>>> wrote:
> >>>>
> >>>> [...]
> >>>>
> >>>> > Could you please help ?
> >>>>
> >>>> Are you able to execute the same thing outside of python? i.e. with
> >>>> another RESTful client like postman?
> >>>>
> >>>> Regards,
> >>>> Shrayas
> >>>> _______________________________________________
> >>>> Chennaipy mailing list
> >>>> Chennaipy at python.org
> >>>> https://mail.python.org/mailman/listinfo/chennaipy
> >>>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Chennaipy mailing list
> >>> Chennaipy at python.org
> >>> https://mail.python.org/mailman/listinfo/chennaipy
> >>>
> >>>
> >>
> >> _______________________________________________
> >> Chennaipy mailing list
> >> Chennaipy at python.org
> >> https://mail.python.org/mailman/listinfo/chennaipy
> >>
> >>
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/chennaipy/
> attachments/20180223/3a78e13b/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy
>
>
> ------------------------------
>
> End of Chennaipy Digest, Vol 54, Issue 16
> *****************************************
>



-- 
Thanks,
*S. S. Venkata Raman*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20180223/37e283b5/attachment.html>


More information about the Chennaipy mailing list