Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
a7874675
Commit
a7874675
authored
Jul 31, 2015
by
Tom Soulanille
Committed by
Damien George
Oct 19, 2015
Browse files
Options
Downloads
Patches
Plain Diff
tools/pyboard: Add -c argument to run a program passed as a string.
parent
4078336d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/pyboard.py
+12
-5
12 additions, 5 deletions
tools/pyboard.py
with
12 additions
and
5 deletions
tools/pyboard.py
+
12
−
5
View file @
a7874675
...
@@ -253,17 +253,16 @@ def main():
...
@@ -253,17 +253,16 @@ def main():
cmd_parser
.
add_argument
(
'
-b
'
,
'
--baudrate
'
,
default
=
115200
,
help
=
'
the baud rate of the serial device
'
)
cmd_parser
.
add_argument
(
'
-b
'
,
'
--baudrate
'
,
default
=
115200
,
help
=
'
the baud rate of the serial device
'
)
cmd_parser
.
add_argument
(
'
-u
'
,
'
--user
'
,
default
=
'
micro
'
,
help
=
'
the telnet login username
'
)
cmd_parser
.
add_argument
(
'
-u
'
,
'
--user
'
,
default
=
'
micro
'
,
help
=
'
the telnet login username
'
)
cmd_parser
.
add_argument
(
'
-p
'
,
'
--password
'
,
default
=
'
python
'
,
help
=
'
the telnet login password
'
)
cmd_parser
.
add_argument
(
'
-p
'
,
'
--password
'
,
default
=
'
python
'
,
help
=
'
the telnet login password
'
)
cmd_parser
.
add_argument
(
'
-c
'
,
'
--command
'
,
help
=
'
program passed in as string
'
)
cmd_parser
.
add_argument
(
'
--follow
'
,
action
=
'
store_true
'
,
help
=
'
follow the output after running the scripts [default if no scripts given]
'
)
cmd_parser
.
add_argument
(
'
--follow
'
,
action
=
'
store_true
'
,
help
=
'
follow the output after running the scripts [default if no scripts given]
'
)
cmd_parser
.
add_argument
(
'
files
'
,
nargs
=
'
*
'
,
help
=
'
input files
'
)
cmd_parser
.
add_argument
(
'
files
'
,
nargs
=
'
*
'
,
help
=
'
input files
'
)
args
=
cmd_parser
.
parse_args
()
args
=
cmd_parser
.
parse_args
()
for
filename
in
args
.
files
:
def
execbuffer
(
buf
)
:
try
:
try
:
pyb
=
Pyboard
(
args
.
device
,
args
.
baudrate
,
args
.
user
,
args
.
password
)
pyb
=
Pyboard
(
args
.
device
,
args
.
baudrate
,
args
.
user
,
args
.
password
)
pyb
.
enter_raw_repl
()
pyb
.
enter_raw_repl
()
with
open
(
filename
,
'
rb
'
)
as
f
:
ret
,
ret_err
=
pyb
.
exec_raw
(
buf
,
timeout
=
None
,
data_consumer
=
stdout_write_bytes
)
pyfile
=
f
.
read
()
ret
,
ret_err
=
pyb
.
exec_raw
(
pyfile
,
timeout
=
None
,
data_consumer
=
stdout_write_bytes
)
pyb
.
exit_raw_repl
()
pyb
.
exit_raw_repl
()
pyb
.
close
()
pyb
.
close
()
except
PyboardError
as
er
:
except
PyboardError
as
er
:
...
@@ -275,7 +274,15 @@ def main():
...
@@ -275,7 +274,15 @@ def main():
stdout_write_bytes
(
ret_err
)
stdout_write_bytes
(
ret_err
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
if
args
.
follow
or
len
(
args
.
files
)
==
0
:
if
args
.
command
is
not
None
:
execbuffer
(
bytes
(
args
.
command
,
'
utf-8
'
))
for
filename
in
args
.
files
:
with
open
(
filename
,
'
rb
'
)
as
f
:
pyfile
=
f
.
read
()
execbuffer
(
pyfile
)
if
args
.
follow
or
(
args
.
command
is
None
and
len
(
args
.
files
)
==
0
):
try
:
try
:
pyb
=
Pyboard
(
args
.
device
,
args
.
baudrate
,
args
.
user
,
args
.
password
)
pyb
=
Pyboard
(
args
.
device
,
args
.
baudrate
,
args
.
user
,
args
.
password
)
ret
,
ret_err
=
pyb
.
follow
(
timeout
=
None
,
data_consumer
=
stdout_write_bytes
)
ret
,
ret_err
=
pyb
.
follow
(
timeout
=
None
,
data_consumer
=
stdout_write_bytes
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment