Python Forum
How to do the same as python -m requests.certs inside script?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to do the same as python -m requests.certs inside script?
#1
This might be a dumb question -

in the command line, python -m requests.cert gives result:
/etc/pki/tls/certs/ca-bundle.crt

How is the right way to get the result inside python script?
#!/usr/bin/env python
import requets

result=requests.cert
print(result)
The script above returns result:
Output:
<module 'requests.certs' from '/usr/lib/python2.7/dist-packages/requests/certs.pyc'>
not sure why it is like this. I would like to get /etc/pki/tls/certs/ca-bundle.crt
Reply
#2
you have mispelled requests line 2
method name is certs, not cert line 4
Reply
#3
Look at the source code of requests.certs.py you will see all it does is to import where() function from third-party package certifi

the rest of the code is within if __name__ == '__main__': block and executed when you execute crts.py as standalone script.
So if you want to replicate
from certifi import where
print(where())
the source of where()
import os


def where():
    f = os.path.dirname(__file__)

    return os.path.join(f, 'cacert.pem')
of course this assumes certiffi is installed
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 278 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,007 Jun-29-2023, 11:57 AM
Last Post: gologica
  python requests library .JSON() error mHosseinDS86 6 3,235 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  Python requests oauth2 access token herobpv 6 3,769 Sep-27-2021, 06:54 PM
Last Post: herobpv
  Python Requests SSL Aussie 0 1,960 Jan-07-2021, 02:09 AM
Last Post: Aussie
  Python Requests Aussie 2 2,689 Dec-23-2020, 03:24 AM
Last Post: Aussie
  Python Requests package: Handling xml response soumyarani 1 2,101 Sep-14-2020, 11:41 AM
Last Post: buran
  Python API and requests deep_logic 9 4,180 Jul-29-2020, 03:47 PM
Last Post: ndc85430
  How to save Python Requests data sent to server? RedLeonard 5 4,794 Jul-05-2020, 10:33 AM
Last Post: RedLeonard
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,788 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020