summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grc/CMakeLists.txt6
-rw-r--r--grc/converter/main.py3
-rw-r--r--grc/core/FlowGraph.py16
-rw-r--r--grc/core/generator/hier_block.py4
-rw-r--r--grc/core/utils/flow_graph_complexity.py97
-rw-r--r--grc/gui/Dialogs.py5
-rwxr-xr-xgrc/main.py3
-rwxr-xr-xgrc/scripts/gnuradio-companion6
8 files changed, 69 insertions, 71 deletions
diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt
index d0002325b6..77c8d4c00d 100644
--- a/grc/CMakeLists.txt
+++ b/grc/CMakeLists.txt
@@ -149,11 +149,11 @@ GR_PYTHON_INSTALL(
)
GR_PYTHON_INSTALL(
- DIRECTORY core gui
+ DIRECTORY core gui converter
DESTINATION "${GR_PYTHON_DIR}/gnuradio/grc"
- FILES_MATCHING REGEX "\\.(py|dtd|grc|tmpl|png)$"
+ FILES_MATCHING REGEX "\\.(py|dtd|grc|tmpl|png|mako)$"
)
-
+
########################################################################
# Append NSIS commands to set environment variables
########################################################################
diff --git a/grc/converter/main.py b/grc/converter/main.py
index e5a836f511..5a18471fc7 100644
--- a/grc/converter/main.py
+++ b/grc/converter/main.py
@@ -64,6 +64,7 @@ class Converter(object):
self._force = force
try:
+ logger.debug("Loading block cache from: {}".format(self.cache_file))
with open(self.cache_file, encoding='utf-8') as cache_file:
self.cache = byteify(json.load(cache_file))
except (IOError, ValueError):
@@ -158,7 +159,7 @@ def byteify(data):
return {byteify(key): byteify(value) for key, value in six.iteritems(data)}
elif isinstance(data, list):
return [byteify(element) for element in data]
- elif isinstance(data, unicode):
+ elif isinstance(data, six.text_type) and six.PY2:
return data.encode('utf-8')
else:
return data
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 481dda5786..3f21ec6a9c 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -387,9 +387,9 @@ class FlowGraph(Element):
had_connect_errors = False
_blocks = {block.name: block for block in self.blocks}
- # TODO: Crashes if connections section exists without actual connections.
- for src_blk_id, src_port_id, snk_blk_id, snk_port_id in data.get('connections', []):
- try:
+ try:
+ # TODO: Add better error handling if no connections exist in the flowgraph file.
+ for src_blk_id, src_port_id, snk_blk_id, snk_port_id in data.get('connections', []):
source_block = _blocks[src_blk_id]
sink_block = _blocks[snk_blk_id]
@@ -404,11 +404,11 @@ class FlowGraph(Element):
self.connect(source_port, sink_port)
- except (KeyError, LookupError) as e:
- Messages.send_error_load(
- 'Connection between {}({}) and {}({}) could not be made.\n\t{}'.format(
- src_blk_id, src_port_id, snk_blk_id, snk_port_id, e))
- had_connect_errors = True
+ except (KeyError, LookupError) as e:
+ Messages.send_error_load(
+ 'Connection between {}({}) and {}({}) could not be made.\n\t{}'.format(
+ src_blk_id, src_port_id, snk_blk_id, snk_port_id, e))
+ had_connect_errors = True
self.rewrite() # global rewrite
return had_connect_errors
diff --git a/grc/core/generator/hier_block.py b/grc/core/generator/hier_block.py
index 301562fa4f..237fd71377 100644
--- a/grc/core/generator/hier_block.py
+++ b/grc/core/generator/hier_block.py
@@ -191,7 +191,3 @@ def get_hier_block_io(flow_graph, direction, domain=None):
ports.append(clone)
else:
ports.append(master)
-
- if domain is not None:
- ports = [p for p in ports if p.domain == domain]
- yield ports # TODO: Not sure this fix is correct
diff --git a/grc/core/utils/flow_graph_complexity.py b/grc/core/utils/flow_graph_complexity.py
index 15ac131d9b..e8962b0ae3 100644
--- a/grc/core/utils/flow_graph_complexity.py
+++ b/grc/core/utils/flow_graph_complexity.py
@@ -1,51 +1,54 @@
def calculate(flowgraph):
""" Determines the complexity of a flowgraph """
- return " *** DISABLED *** " # TODO: Temporarily disabled.
- dbal = 0
- for block in flowgraph.blocks:
- # Skip options block
- if block.key == 'options':
- continue
-
- # Don't worry about optional sinks?
- sink_list = [c for c in block.sinks if not c.optional]
- source_list = [c for c in block.sources if not c.optional]
- sinks = float(len(sink_list))
- sources = float(len(source_list))
- base = max(min(sinks, sources), 1)
-
- # Port ratio multiplier
- if min(sinks, sources) > 0:
- multi = sinks / sources
- multi = (1 / multi) if multi > 1 else multi
+
+ try:
+ dbal = 0.0
+ for block in flowgraph.blocks:
+ if block.key == "options":
+ continue
+
+ # Determine the base value for this block
+ sinks = sum(1.0 for port in block.sinks if not port.optional)
+ sources = sum(1.0 for port in block.sources if not port.optional)
+ base = max(min(sinks, sources), 1)
+
+ # Determine the port multiplier
+ block_connections = 0.0
+ for port in block.sources:
+ block_connections += sum(1.0 for c in port.connections())
+ source_multi = max(block_connections / max(sources, 1.0), 1.0)
+
+ # Port ratio multiplier
+ multi = 1.0
+ if min(sinks, sources) > 0:
+ multi = float(sinks / sources)
+ multi = float(1 / multi) if multi > 1 else multi
+
+ dbal += base * multi * source_multi
+
+ blocks = float(len(flowgraph.blocks) - 1)
+ connections = float(len(flowgraph.connections))
+ variables = float(len(flowgraph.get_variables()))
+
+ enabled = float(len(flowgraph.get_enabled_blocks()))
+ enabled_connections = float(len(flowgraph.get_enabled_connections()))
+ disabled_connections = connections - enabled_connections
+
+ # Disabled multiplier
+ if enabled > 0:
+ disabled_multi = 1 / (max(1 - ((blocks - enabled) / max(blocks, 1)), 0.05))
+ else:
+ disabled_multi = 1
+
+ # Connection multiplier (How many connections )
+ if (connections - disabled_connections) > 0:
+ conn_multi = 1 / (max(1 - (disabled_connections / max(connections, 1)), 0.05))
else:
- multi = 1
-
- # Connection ratio multiplier
- sink_multi = max(float(sum(len(c.connections()) for c in sink_list) / max(sinks, 1.0)), 1.0)
- source_multi = max(float(sum(len(c.connections()) for c in source_list) / max(sources, 1.0)), 1.0)
- dbal += base * multi * sink_multi * source_multi
-
- blocks = float(len(flowgraph.blocks))
- connections = float(len(flowgraph.connections))
- elements = blocks + connections
- disabled_connections = sum(not c.enabled for c in flowgraph.connections)
-
- variables = elements - blocks - connections
- enabled = float(len(flowgraph.get_enabled_blocks()))
-
- # Disabled multiplier
- if enabled > 0:
- disabled_multi = 1 / (max(1 - ((blocks - enabled) / max(blocks, 1)), 0.05))
- else:
- disabled_multi = 1
-
- # Connection multiplier (How many connections )
- if (connections - disabled_connections) > 0:
- conn_multi = 1 / (max(1 - (disabled_connections / max(connections, 1)), 0.05))
- else:
- conn_multi = 1
-
- final = round(max((dbal - 1) * disabled_multi * conn_multi * connections, 0.0) / 1000000, 6)
- return final
+ conn_multi = 1
+
+ final = round(max((dbal - 1) * disabled_multi * conn_multi * connections, 0.0) / 1000000, 6)
+ return final
+
+ except Exception:
+ return "<Error>"
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index 45c9095313..f58ea78ca2 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -265,14 +265,17 @@ def show_about(parent, config):
ad = Gtk.AboutDialog(transient_for=parent)
ad.set_program_name(config.name)
ad.set_name('')
- ad.set_version(config.version)
ad.set_license(config.license)
+ py_version = sys.version.split()[0]
+ ad.set_version("{} (Python {})".format(config.version, py_version))
+
try:
ad.set_logo(Gtk.IconTheme().load_icon('gnuradio-grc', 64, 0))
except:
pass
+ #ad.set_comments("")
ad.set_copyright(config.license.splitlines()[0])
ad.set_website(config.website)
diff --git a/grc/main.py b/grc/main.py
index 2d182c226f..4f4cd68704 100755
--- a/grc/main.py
+++ b/grc/main.py
@@ -71,7 +71,8 @@ def main():
console.setFormatter(formatter)
log.addHandler(console)
- log.debug("Running main")
+ py_version = sys.version.split()[0]
+ log.debug("Starting GNU Radio Companion ({})".format(py_version))
# Delay importing until the logging is setup
from .gui.Platform import Platform
diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion
index de776f22a7..55e66cc761 100755
--- a/grc/scripts/gnuradio-companion
+++ b/grc/scripts/gnuradio-companion
@@ -81,11 +81,6 @@ def check_blocks_path():
"Can't find block definitions. Use config.conf or GRC_BLOCKS_PATH.")
-def check_python_version():
- if sys.version_info.major > 2:
- die(RuntimeError('No python3 support yet.'), 'Stay tuned...')
-
-
def run_main():
script_path = os.path.dirname(os.path.abspath(__file__))
source_tree_subpath = "/grc/scripts"
@@ -103,6 +98,5 @@ def run_main():
if __name__ == '__main__':
check_gnuradio_import()
check_gtk()
- check_python_version()
check_blocks_path()
run_main()