forked from bmaltais/kohya_ss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssl_certifi.py
33 lines (26 loc) · 887 Bytes
/
ssl_certifi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import os.path
import ssl
import subprocess
import sys
def main():
openssl_dir, openssl_cafile = os.path.split(
ssl.get_default_verify_paths().openssl_cafile)
print(" -- pip install --upgrade certifi")
subprocess.check_call([sys.executable,
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
import certifi
# change working directory to the default SSL directory
os.chdir(openssl_dir)
print(" -- removing any existing file or link")
try:
os.remove(openssl_cafile)
except FileNotFoundError:
pass
print(" -- copying certifi certificate bundle")
with open(certifi.where(), 'rb') as source_file:
with open(openssl_cafile, 'wb') as dest_file:
dest_file.write(source_file.read())
print(" -- update complete")
if __name__ == '__main__':
main()