-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #797 from OpenC3/python_interfaces
Add Python streams and interfaces
- Loading branch information
Showing
73 changed files
with
8,825 additions
and
456 deletions.
There are no files selected for viewing
29 changes: 16 additions & 13 deletions
29
...cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/procedures_py/target_file.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
from openc3.script import * | ||
from openc3.utilities.string import formatted | ||
import tempfile | ||
|
||
put_target_file("INST/test.txt", "this is a string test") | ||
download_file("INST/test.txt") # download via path | ||
file = get_target_file("INST/test.txt") | ||
print(file.read) | ||
file.rewind # rewind so download_file can read | ||
print(file.read()) | ||
file.seek(0) # rewind so download_file can read | ||
download_file(file) # download using file | ||
file.delete | ||
file.close() # closing deletes tempfile | ||
delete_target_file("INST/test.txt") | ||
|
||
save_file = Tempfile.new("test") | ||
save_file = tempfile.NamedTemporaryFile(mode="w+t") | ||
save_file.write("this is a Io test") | ||
save_file.rewind | ||
save_file.seek(0) | ||
put_target_file("INST/test.txt", save_file) | ||
save_file.delete | ||
save_file.close() # Delete the tempfile | ||
file = get_target_file("INST/test.txt") | ||
print(file.read) | ||
file.delete | ||
print(file.read()) | ||
file.close() | ||
delete_target_file("INST/test.txt") | ||
|
||
put_target_file("INST/test.bin", "\x00\x01\x02\x03\xFF\xEE\xDD\xCC") | ||
file = get_target_file("INST/test.bin") | ||
print(file.read.formatted) | ||
file.delete | ||
delete_target_file("INST/test.bin") | ||
# TODO: Binary not yet supported | ||
# put_target_file("INST/test.bin", b"\x00\x01\x02\x03\xFF\xEE\xDD\xCC") | ||
# file = get_target_file("INST/test.bin") | ||
# print(formatted(file.read())) | ||
# file.close() | ||
# delete_target_file("INST/test.bin") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.