From 47ccbf3c325f7c34a3586e129debca8a204cd1be Mon Sep 17 00:00:00 2001 From: Big Circle <794557226@qq.com> Date: Thu, 13 Feb 2020 17:34:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E4=B8=BA1.1.3=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E4=BC=A0=E8=BE=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E7=BC=96=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E4=B8=BAutf-8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ampy/__version__.py | 2 +- ampy/cli.py | 35 +++++++++++++++++++---------------- ampy/files.py | 14 ++++++++------ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/ampy/__version__.py b/ampy/__version__.py index 9cbca53..34f15d7 100644 --- a/ampy/__version__.py +++ b/ampy/__version__.py @@ -1,4 +1,4 @@ -VERSION = (1, 1, 2) +VERSION = (1, 1, 3) __version__ = '.'.join(map(str, VERSION)) diff --git a/ampy/cli.py b/ampy/cli.py index 410a8bc..2ae8dff 100644 --- a/ampy/cli.py +++ b/ampy/cli.py @@ -248,13 +248,15 @@ def put(local, remote): board_files.mkdir(remote_parent) # Loop through all the files and put them on the board too. for filename in child_files: - try: - with open(os.path.join(parent, filename), "r", encoding = 'utf-8') as infile: - out_content = infile.read().encode('GB2312') - except: - with open(os.path.join(parent, filename), "rb") as infile: - out_content = infile.read() - # with open(os.path.join(parent, filename), "r") as infile: + # try: + # with open(os.path.join(parent, filename), "r", encoding = 'utf-8') as infile: + # out_content = infile.read().encode('GB2312') + # except: + # with open(os.path.join(parent, filename), "rb") as infile: + # out_content = infile.read() + # # with open(os.path.join(parent, filename), "r") as infile: + with open(os.path.join(parent, filename), "rb") as infile: + out_content = infile.read() remote_filename = posixpath.join(remote_parent, filename) board_files.put(remote_filename, out_content) except files.DirectoryExistsError: @@ -264,15 +266,16 @@ def put(local, remote): else: # File copy, open the file and copy its contents to the board. # Put the file on the board. - try: - with open(local, "r", encoding = 'utf-8') as infile: - out_content = infile.read().encode('GB2312') - # print('open(r)') - except Exception as e: - with open(local, "rb") as infile: - out_content = infile.read() - # print('open(rb)',e) - # with open(local, "r") as infile: + # try: + # with open(local, "r", encoding = 'utf-8') as infile: + # out_content = infile.read().encode('GB2312') + # # print('open(r)') + # except Exception as e: + # with open(local, "rb") as infile: + # out_content = infile.read() + # # print('open(rb)',e) + with open(local, "rb") as infile: + out_content = infile.read() board_files = files.Files(_board) board_files.put(remote, out_content) # print(out_content) diff --git a/ampy/files.py b/ampy/files.py index 062b3d4..cc8a8fc 100644 --- a/ampy/files.py +++ b/ampy/files.py @@ -304,12 +304,14 @@ def run(self, filename, wait_output=True): else: # Read the file and run it using lower level pyboard functions that # won't wait for it to finish or return output. - try: - with open(filename, "r", encoding = 'utf-8') as infile: - out_content = infile.read().encode('GB2312') - except: - with open(filename, "rb") as infile: - out_content = infile.read() + # try: + # with open(filename, "r", encoding = 'utf-8') as infile: + # out_content = infile.read().encode('GB2312') + # except: + # with open(filename, "rb") as infile: + # out_content = infile.read() + with open(filename, "rb") as infile: + out_content = infile.read() self._pyboard.exec_raw_no_follow(out_content) self._pyboard.exit_raw_repl() return out