Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Programmable RF Attenuator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Programmable RF Attenuator
Commits
6a882196
Commit
6a882196
authored
Nov 05, 2021
by
Juan David González Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: add history and SIGINT mgmt
parent
18f5c601
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
oautest
software/lib/oautest
+23
-1
No files found.
software/lib/oautest
View file @
6a882196
...
...
@@ -3,6 +3,7 @@
import
cmd
import
readline
import
os.path
import
pdb
from
ctypes
import
*
...
...
@@ -25,6 +26,7 @@ class OauTest(cmd.Cmd):
def
__init__
(
self
):
cmd
.
Cmd
.
__init__
(
self
)
self
.
solib
=
'./liboasis-usb-att.so'
self
.
history
=
os
.
path
.
expanduser
(
'~/.oau_history'
)
self
.
api
=
CDLL
(
self
.
solib
)
self
.
lun
=
None
self
.
fd
=
None
...
...
@@ -100,6 +102,26 @@ class OauTest(cmd.Cmd):
def
do_EOF
(
self
,
arg
):
return
True
def
my_preloop
(
self
):
try
:
readline
.
read_history_file
(
self
.
history
)
except
FileNotFoundError
:
readline
.
write_history_file
(
self
.
history
)
def
my_postloop
(
self
):
readline
.
write_history_file
(
self
.
history
)
# catch Ctrl-C and drop me back into cli
def
cmdloop_intr
(
self
,
intro
=
None
):
self
.
my_preloop
()
while
True
:
try
:
self
.
cmdloop
()
break
except
KeyboardInterrupt
as
e
:
self
.
intro
=
None
print
(
'^C'
)
self
.
my_postloop
()
do_q
=
do_EOF
do_h
=
cmd
.
Cmd
.
do_help
...
...
@@ -107,7 +129,7 @@ class OauTest(cmd.Cmd):
if
__name__
==
'__main__'
:
cli
=
OauTest
()
cli
.
cmdloop
()
cli
.
cmdloop
_intr
()
if
False
:
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment