Skip to content

Commit

Permalink
修改版本号为1.1.3;
Browse files Browse the repository at this point in the history
修改传输文件的编码格式为utf-8。
  • Loading branch information
BigCircleLaw committed Feb 13, 2020
1 parent 34734c8 commit 47ccbf3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ampy/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

VERSION = (1, 1, 2)
VERSION = (1, 1, 3)

__version__ = '.'.join(map(str, VERSION))
35 changes: 19 additions & 16 deletions ampy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions ampy/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 47ccbf3

Please sign in to comment.