8000 Move all scripts and documentation to Python3 by earlephilhower · Pull Request #6378 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Move all scripts and documentation to Python3 #6378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 28, 2019
Merged
Prev Previous commit
Next Next commit
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.
  • Loading branch information
earlephilhower committed Aug 4, 2019
commit 93b8bb327efac622532fd4b259e455b215ae0665
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
# 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
from urllib.request import urlopen
from io import StringIO
try:
from urllib.request import urlopen
except:
from urllib2 import urlopen
try:
from StringIO import StringIO
except:
from io import StringIO

# Mozilla's URL for the CSV file with included PEM certs
mozurl = "https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReportPEMCSV"
Expand All @@ -21,7 +28,9 @@
names = []
pems = []
response = urlopen(mozurl)
csvData = response.read().decode('utf-8')
csvData = response.read()
if sys.version_info[0] > 2:
csvData = csvData.decode('utf-8')
csvFile = StringIO(csvData)
csvReader = csv.reader(csvFile)
for row in csvReader:
Expand Down
1 change: 1 addition & 0 deletions package/drop_versions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# This script drops one or multiple versions of a release
#
from __future__ import print_function
import json
import sys
from collections import OrderedDict
Expand Down
3 changes: 2 additions & 1 deletion package/merge_packages.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
# This script merges two Arduino Board Manager package json files.
# Usage:
# python3 merge_packages.py package_esp8266com_index.json version/new/package_esp8266com_index.json
# python merge_packages.py package_esp8266com_index.json version/new/package_esp8266com_index.json
# Written by Ivan Grokhotkov, 2015
#
from __future__ import print_function
import json
import sys

Expand Down
1 change: 1 addition & 0 deletions tests/device/libraries/BSTest/runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function
import pexpect
from pexpect import EOF, TIMEOUT, fdpexpect
import sys
Expand Down
17 changes: 13 additions & 4 deletions tests/device/test_BearSSL/make_spiffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
# 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
from urllib.request import urlopen
from io import StringIO
try:
from urllib.request import urlopen
except:
from urllib2 import urlopen
try:
from StringIO import StringIO
except:
from io import StringIO

# Mozilla's URL for the CSV file with included PEM certs
mozurl = "https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReportPEMCSV"
Expand All @@ -21,7 +28,9 @@
names = []
pems = []
response = urlopen(mozurl)
csvData = response.read().decode('utf-8')
csvData = response.read()
if sys.version_info[0] > 2:
csvData = csvData.decode('utf-8')
csvFile = StringIO(csvData)
csvReader = csv.reader(csvFile)
for row in csvReader:
Expand Down
1 change: 1 addition & 0 deletions tools/boards.txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# 512K/1M/2M/4M/8M/16M: menus for flash & SPIFFS size
# lwip/lwip2 menus for available lwip versions

from __future__ import print_function
import os
import sys
import collections
Expand Down
1 change: 1 addition & 0 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#
#

from __future__ import print_function
import sys
import os
import argparse
Expand Down
1 change: 1 addition & 0 deletions tools/elf2bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function
import argparse
import re
import os
Expand Down
7 changes: 6 additions & 1 deletion tools/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Tools list is obtained from package/package_esp8266com_index.template.json file.
# Written by Ivan Grokhotkov, 2015.
#
from __future__ import print_function
import os
import shutil
import errno
Expand All @@ -14,7 +15,11 @@
import tarfile
import zipfile
import re
from urllib.request import urlretrieve
if sys.version_info[0] == 3:
from urllib.request import urlretrieve
else:
# Not Python 3 - today, it is most likely to be Python 2
from urllib import urlretrieve

dist_dir = 'dist/'

Expand Down
0