mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Move all scripts and documentation to Python3 (#6378)
* Move all scripts and documentation to Python3 Python 2 EOL is Jan 1, 2020. Migrate scripts to run under Python 3. Under Windows, we're already running Python 3.7, by dumb luck. The oddness is that the Windows standalone executable for Python 3 is called "python" whereas under UNIX-like OSes it's called "python3" with "python" always referring to the Python 2 executable. The ZIP needs to be updated to include a Python3.exe (copy of Python.exe) so that we can use the same command lines under Linux and Windows, and to preserve my sanity. Fixes #6376 * Add new Windows ZIP with python3.exe file * Sort options in boards.txt generation for repeatability The order of the board opts dict changes depending on the Python version and machine, so sort the options before printing them to get a stable ordering. * Re-add Python2 compatibility tweaks Most scripts can run as Python 2 or Python 3 with minimal changes, so re-add (and fix, as necessary) compatibility tweaks to the scripts.
This commit is contained in:
committed by
GitHub
parent
1800bb5abe
commit
0a031ce957
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
|
||||
# This script pulls the list of Mozilla trusted certificate authorities
|
||||
# from the web at the "mozurl" below, parses the file to grab the PEM
|
||||
@ -7,16 +7,18 @@
|
||||
# and use them for your outgoing SSL connections.
|
||||
#
|
||||
# Script by Earle F. Philhower, III. Released to the public domain.
|
||||
|
||||
from __future__ import print_function
|
||||
import csv
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, PIPE, call
|
||||
import urllib2
|
||||
try:
|
||||
# for Python 2.x
|
||||
from urllib.request import urlopen
|
||||
except:
|
||||
from urllib2 import urlopen
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
# for Python 3.x
|
||||
except:
|
||||
from io import StringIO
|
||||
|
||||
# Mozilla's URL for the CSV file with included PEM certs
|
||||
@ -25,9 +27,12 @@ mozurl = "https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateRep
|
||||
# Load the manes[] and pems[] array from the URL
|
||||
names = []
|
||||
pems = []
|
||||
response = urllib2.urlopen(mozurl)
|
||||
response = urlopen(mozurl)
|
||||
csvData = response.read()
|
||||
csvReader = csv.reader(StringIO(csvData))
|
||||
if sys.version_info[0] > 2:
|
||||
csvData = csvData.decode('utf-8')
|
||||
csvFile = StringIO(csvData)
|
||||
csvReader = csv.reader(csvFile)
|
||||
for row in csvReader:
|
||||
names.append(row[0]+":"+row[1]+":"+row[2])
|
||||
pems.append(row[30])
|
||||
@ -46,10 +51,10 @@ idx = 0
|
||||
for i in range(0, len(pems)):
|
||||
certName = "data/ca_%03d.der" % (idx);
|
||||
thisPem = pems[i].replace("'", "")
|
||||
print names[i] + " -> " + certName
|
||||
print(names[i] + " -> " + certName)
|
||||
ssl = Popen(['openssl','x509','-inform','PEM','-outform','DER','-out', certName], shell = False, stdin = PIPE)
|
||||
pipe = ssl.stdin
|
||||
pipe.write(thisPem)
|
||||
pipe.write(thisPem.encode('utf-8'))
|
||||
pipe.close()
|
||||
ssl.wait()
|
||||
if os.path.exists(certName):
|
||||
|
Reference in New Issue
Block a user