style: format python files with isort and double-quote-string-fixer

This commit is contained in:
Fu Hanxi
2021-01-26 10:49:01 +08:00
parent dc8402ea61
commit 0146f258d7
276 changed files with 8241 additions and 8162 deletions

View File

@@ -1,8 +1,9 @@
from tiny_test_fw import Utility
import random
import re
import time
import ttfw_idf
from tiny_test_fw import Utility
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')

View File

@@ -1,5 +1,5 @@
from tiny_test_fw import Utility
import ttfw_idf
from tiny_test_fw import Utility
try:
from itertools import izip_longest as zip_longest

View File

@@ -1,5 +1,5 @@
from tiny_test_fw import Utility
import ttfw_idf
from tiny_test_fw import Utility
try:
from itertools import izip_longest as zip_longest

View File

@@ -1,4 +1,5 @@
import re
import ttfw_idf

View File

@@ -1,7 +1,8 @@
from __future__ import print_function
import os
import sys
import subprocess
import sys
import ttfw_idf
@@ -12,23 +13,23 @@ def test_examples_parttool(env, extra_data):
dut.start_app(False)
# Verify factory firmware
dut.expect("Partitions Tool Example")
dut.expect("Example end")
dut.expect('Partitions Tool Example')
dut.expect('Example end')
# Close connection to DUT
dut.receive_thread.exit()
dut.port_inst.close()
# Run the example python script
script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "storage", "parttool", "parttool_example.py")
script_path = os.path.join(os.getenv('IDF_PATH'), 'examples', 'storage', 'parttool', 'parttool_example.py')
binary_path = ""
binary_path = ''
for flash_file in dut.app.flash_files:
if "parttool.bin" in flash_file[1]:
if 'parttool.bin' in flash_file[1]:
binary_path = flash_file[1]
break
subprocess.check_call([sys.executable, script_path, "--binary", binary_path, "--port", dut.port])
subprocess.check_call([sys.executable, script_path, '--binary', binary_path, '--port', dut.port])
if __name__ == '__main__':

View File

@@ -16,16 +16,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import os
import sys
import argparse
PARTITION_TABLE_DIR = os.path.join("components", "partition_table", "")
PARTITION_TABLE_DIR = os.path.join('components', 'partition_table', '')
def assert_file_same(file1, file2, err):
with open(file1, "rb") as f1:
with open(file2, "rb") as f2:
with open(file1, 'rb') as f1:
with open(file2, 'rb') as f2:
f1 = f1.read()
f2 = f2.read()
@@ -39,17 +39,17 @@ def assert_file_same(file1, file2, err):
def main():
COMPONENTS_PATH = os.path.expandvars(os.path.join("$IDF_PATH", "components"))
PARTTOOL_DIR = os.path.join(COMPONENTS_PATH, "partition_table")
COMPONENTS_PATH = os.path.expandvars(os.path.join('$IDF_PATH', 'components'))
PARTTOOL_DIR = os.path.join(COMPONENTS_PATH, 'partition_table')
sys.path.append(PARTTOOL_DIR)
from parttool import PartitionName, PartitionType, ParttoolTarget
from gen_empty_partition import generate_blanked_file
from parttool import PartitionName, PartitionType, ParttoolTarget
parser = argparse.ArgumentParser("ESP-IDF Partitions Tool Example")
parser = argparse.ArgumentParser('ESP-IDF Partitions Tool Example')
parser.add_argument("--port", "-p", help="port where the device to perform operations on is connected")
parser.add_argument("--binary", "-b", help="path to built example binary", default=os.path.join("build", "parttool.bin"))
parser.add_argument('--port', '-p', help='port where the device to perform operations on is connected')
parser.add_argument('--binary', '-b', help='path to built example binary', default=os.path.join('build', 'parttool.bin'))
args = parser.parse_args()
@@ -57,47 +57,47 @@ def main():
# Read app partition and save the contents to a file. The app partition is identified
# using type-subtype combination
print("Checking if device app binary matches built binary")
factory = PartitionType("app", "factory")
target.read_partition(factory, "app.bin")
assert_file_same(args.binary, "app.bin", "Device app binary does not match built binary")
print('Checking if device app binary matches built binary')
factory = PartitionType('app', 'factory')
target.read_partition(factory, 'app.bin')
assert_file_same(args.binary, 'app.bin', 'Device app binary does not match built binary')
# Retrieve info on data storage partition, this time identifying it by name.
storage = PartitionName("storage")
storage = PartitionName('storage')
storage_info = target.get_partition_info(storage)
print("Found data partition at offset 0x{:x} with size 0x{:x}".format(storage_info.offset, storage_info.size))
print('Found data partition at offset 0x{:x} with size 0x{:x}'.format(storage_info.offset, storage_info.size))
# Create a file whose contents will be written to the storage partition
with open("write.bin", "wb") as f:
with open('write.bin', 'wb') as f:
# Create a file to write to the data partition with randomly generated content
f.write(os.urandom(storage_info.size))
# Write the contents of the created file to storage partition
print("Writing to data partition")
target.write_partition(storage, "write.bin")
print('Writing to data partition')
target.write_partition(storage, 'write.bin')
# Read back the contents of the storage partition
print("Reading data partition")
target.read_partition(storage, "read.bin")
print('Reading data partition')
target.read_partition(storage, 'read.bin')
assert_file_same("write.bin", "read.bin", "Read contents of storage partition does not match source file contents")
assert_file_same('write.bin', 'read.bin', 'Read contents of storage partition does not match source file contents')
# Erase contents of the storage partition
print("Erasing data partition")
print('Erasing data partition')
target.erase_partition(storage)
# Read back the erased data partition
print("Reading data partition")
target.read_partition(storage, "read.bin")
print('Reading data partition')
target.read_partition(storage, 'read.bin')
# Generate a file of all 0xFF
generate_blanked_file(storage_info.size, "blank.bin")
generate_blanked_file(storage_info.size, 'blank.bin')
assert_file_same("blank.bin", "read.bin", "Contents of storage partition not fully erased")
assert_file_same('blank.bin', 'read.bin', 'Contents of storage partition not fully erased')
# Example end and cleanup
print("\nPartition tool operations performed successfully!")
clean_files = ["app.bin", "read.bin", "blank.bin", "write.bin"]
print('\nPartition tool operations performed successfully!')
clean_files = ['app.bin', 'read.bin', 'blank.bin', 'write.bin']
for clean_file in clean_files:
os.unlink(clean_file)

View File

@@ -1,7 +1,8 @@
from tiny_test_fw import Utility
import ttfw_idf
import re
import ttfw_idf
from tiny_test_fw import Utility
@ttfw_idf.idf_example_test(env_tag='UT_T1_SDMODE')
def test_examples_sd_card(env, extra_data):

View File

@@ -1,7 +1,8 @@
from io import open
import os
import shutil
import tempfile
from io import open
import ttfw_idf
try:
@@ -11,7 +12,7 @@ except ImportError:
from itertools import zip_longest
@ttfw_idf.idf_example_test(env_tag="test_jtag_arm")
@ttfw_idf.idf_example_test(env_tag='test_jtag_arm')
def test_examples_semihost_vfs(env, extra_data):
rel_project_path = os.path.join('examples', 'storage', 'semihost_vfs')

View File

@@ -1,4 +1,5 @@
import re
import ttfw_idf

View File

@@ -1,6 +1,7 @@
from __future__ import print_function
import os
import hashlib
import os
import ttfw_idf

View File

@@ -1,4 +1,5 @@
import re
import ttfw_idf