[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8859 - gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r8859 - gnuradio/branches/features/experimental-gui |
Date: |
Thu, 10 Jul 2008 15:04:47 -0600 (MDT) |
Author: jblum
Date: 2008-07-10 15:04:47 -0600 (Thu, 10 Jul 2008)
New Revision: 8859
Added:
gnuradio/branches/features/experimental-gui/cli.py
Modified:
gnuradio/branches/features/experimental-gui/fft_gui.py
gnuradio/branches/features/experimental-gui/prop_val.py
Log:
command line interface for controller
Added: gnuradio/branches/features/experimental-gui/cli.py
===================================================================
--- gnuradio/branches/features/experimental-gui/cli.py
(rev 0)
+++ gnuradio/branches/features/experimental-gui/cli.py 2008-07-10 21:04:47 UTC
(rev 8859)
@@ -0,0 +1,66 @@
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+"""!
+Command line interface to a prop val controller.
+"""
+
+class cli(object):
+ def __init__(self, controller):
+ self._controller = controller
+
+ def print_help(self):
+ print 'Commands:'
+ print ' * help'
+ print ' * list'
+ print ' * set <key> <value>'
+ print ' * get <key>'
+ print ' * exit'
+
+ def print_list(self):
+ for key in self._controller.keys():
+ print ' * %s: %s'%(key, self._controller[key])
+
+ def handle_cmd(self, cmd, args):
+ print ''
+ if cmd == 'help': self.print_help()
+ elif cmd == 'list': self.print_list()
+ elif cmd == 'set':
+ key, value = args.split(None, 1)
+ self._controller[key] = value
+ elif cmd == 'get':
+ key = args.split(None, 1)[0]
+ print self._controller[key]
+ elif cmd == 'exit':
+ exit(0)
+ else:
+ print 'unknown command'
+ print ''
+
+ def run(self):
+ print 'Type help for options...'
+ while True:
+ line = raw_input('>>> ').split(None, 1)
+ if line:
+ args = len(line) == 2 and line[1] or ''
+ self.handle_cmd(cmd=line[0], args=args)
+
+if __name__ == '__main__':
+ cli({'test1':'1', 'test2':'2'}).run()
Modified: gnuradio/branches/features/experimental-gui/fft_gui.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fft_gui.py 2008-07-10
19:56:51 UTC (rev 8858)
+++ gnuradio/branches/features/experimental-gui/fft_gui.py 2008-07-10
21:04:47 UTC (rev 8859)
@@ -36,7 +36,7 @@
self._win = fft_window(parent=self.GetWin(),
controller=controller,
size=(600, 300),
- title='fft window',
+ title=title,
real=False,
baseband_freq=0.0,
sample_rate_key='sample_rate',
Modified: gnuradio/branches/features/experimental-gui/prop_val.py
===================================================================
--- gnuradio/branches/features/experimental-gui/prop_val.py 2008-07-10
19:56:51 UTC (rev 8858)
+++ gnuradio/branches/features/experimental-gui/prop_val.py 2008-07-10
21:04:47 UTC (rev 8859)
@@ -110,6 +110,8 @@
def __setitem__(self, key, value):
self._get_prop(key).set(value)
+
+ def keys(self): return self._props.keys()
def add_listener(self, key, handler, obj=None):
"""
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8859 - gnuradio/branches/features/experimental-gui,
jblum <=