fixed loading readline history when the file does not exist
This commit is contained in:
parent
802da6a21a
commit
6e06e39612
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
LIB=`dirname "$0"`/../lib
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`uname -m`
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`arch`
|
||||
export PYTHONPATH=$LIB
|
||||
|
||||
exec python -OOu -m hidapi.hidconsole "$@"
|
||||
|
|
2
bin/scan
2
bin/scan
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
LIB=`dirname "$0"`/../lib
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`uname -m`
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`arch`
|
||||
export PYTHONPATH=$LIB
|
||||
|
||||
exec python -OOu -m logitech.scanner "$@"
|
||||
|
|
|
@ -5,7 +5,7 @@ APP=`readlink -f $(dirname "$Z")/../app`
|
|||
LIB=`readlink -f $(dirname "$Z")/../lib`
|
||||
SHARE=`readlink -f $(dirname "$Z")/../share`
|
||||
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`uname -m`
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB/native/`arch`
|
||||
export PYTHONPATH=$APP:$LIB
|
||||
export XDG_DATA_DIRS=$SHARE:$XDG_DATA_DIRS
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ def _continuous_read(handle, timeout=1000):
|
|||
if __name__ == '__main__':
|
||||
import argparse
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument('--history', default='.hidconsole-history', help='history file')
|
||||
arg_parser.add_argument('--history', help='history file')
|
||||
arg_parser.add_argument('device', default=None, help='linux device to connect to')
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
|
@ -60,7 +60,14 @@ if __name__ == '__main__':
|
|||
print (".. Press ^C/^D to exit, or type hex bytes to write to the device.")
|
||||
|
||||
import readline
|
||||
if args.history is None:
|
||||
import os.path
|
||||
args.history = os.path.join(os.path.expanduser("~"), ".hidconsole-history")
|
||||
try:
|
||||
readline.read_history_file(args.history)
|
||||
except:
|
||||
# file may not exist yet
|
||||
pass
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
|
|
Loading…
Reference in New Issue