import textwrap
default_drivers = ['demo:analog_channels=4']
-default_loglevel = sr.LogLevel.WARN
+default_loglevel = 2
def parse_cli():
parser = argparse.ArgumentParser(
help='The driver to use')
parser.add_argument('-l', '--loglevel',
type=int,
+ default=default_loglevel,
help='Set loglevel (5 is most verbose)')
parser.add_argument('--pyside',
action='store_true',
help='Force use of PySide (default is to use PyQt4)')
args = parser.parse_args()
- result = {
- 'drivers': default_drivers,
- 'loglevel': default_loglevel,
- 'pyside': args.pyside
- }
+ if not args.driver:
+ args.driver = default_drivers
- if args.driver:
- result['drivers'] = args.driver
-
- if args.loglevel != None:
- try:
- result['loglevel'] = sr.LogLevel.get(args.loglevel)
- except:
- sys.exit('error: invalid log level')
-
- return result
+ return args
if __name__ == '__main__':
args = parse_cli()
import qtcompat
- qtcompat.load_modules(args['pyside'])
+ qtcompat.load_modules(args.pyside)
QtCore = qtcompat.QtCore
QtGui = qtcompat.QtGui
import mainwindow
context = sr.Context_create()
- context.log_level = args['loglevel']
+ try:
+ loglevel = sr.LogLevel.get(args.loglevel)
+ context.log_level = loglevel
+ except:
+ sys.exit('error: invalid log level')
app = QtGui.QApplication([])
- s = mainwindow.MainWindow(context, args['drivers'])
+ s = mainwindow.MainWindow(context, args.driver)
s.show()
sys.exit(app.exec_())