diff --git a/setup.py b/setup.py index 4702461..5b0861b 100755 --- a/setup.py +++ b/setup.py @@ -30,7 +30,10 @@ setup( 'Programming Language :: Python :: 3.8', ], entry_points={ - 'console_scripts': ['sigmf_validate=sigmf.validate:main'] + 'console_scripts': [ + 'sigmf_validate = sigmf.validate:main', + 'sigmf_gui = sigmf.gui:main [gui]', + ] }, packages=['sigmf'], package_data={ diff --git a/sigmf/__init__.py b/sigmf/__init__.py index d10d089..0c44259 100644 --- a/sigmf/__init__.py +++ b/sigmf/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2016 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/sigmf/archive.py b/sigmf/archive.py index ff2e8e8..7d21b99 100644 --- a/sigmf/archive.py +++ b/sigmf/archive.py @@ -1,4 +1,4 @@ -# Copyright 2017 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/sigmf/error.py b/sigmf/error.py index 75d6db7..079f07d 100644 --- a/sigmf/error.py +++ b/sigmf/error.py @@ -1,4 +1,4 @@ -# Copyright 2017 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/scripts/sigmf_gui.py b/sigmf/gui.py old mode 100755 new mode 100644 similarity index 97% rename from scripts/sigmf_gui.py rename to sigmf/gui.py index 360d30c..e7d3473 --- a/scripts/sigmf_gui.py +++ b/sigmf/gui.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python3 -# Copyright 2020 The Johns Hopkins University Applied Physics Laboratory LLC. All Rights Reserved. +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -8,8 +7,8 @@ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -19,12 +18,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +'''GUI for creating & editing SigMF Files''' + from PySimpleGUI import * -from sigmf.sigmffile import SigMFFile, fromarchive, dtype_info -from sigmf.archive import SIGMF_ARCHIVE_EXT import os import warnings +from .sigmffile import SigMFFile, fromarchive, dtype_info +from .archive import SIGMF_ARCHIVE_EXT + warnings.filterwarnings("error") validate_button = Button('Update', bind_return_key=False, enable_events=True) @@ -227,13 +229,13 @@ def add_sigmf_field(funct, values, field_name, *args, required=False, type=None, return False try: input = int(input) - except: + except ValueError: show_error('Expected an integer for: {}'.format(field_name)) return False elif type == float: try: input = float(input) - except: + except ValueError: show_error('Expected a double for: {}'.format(field_name)) return False elif type == bool: @@ -241,7 +243,7 @@ def add_sigmf_field(funct, values, field_name, *args, required=False, type=None, if input != 'False' and input != 'True': raise ValueError('Unexpected input for boolean') input = True if input == 'True' else False - except: + except ValueError: show_error('Expected a bool for: {}'.format(field_name)) return False Unit.convert(unit, input) @@ -251,7 +253,7 @@ def add_sigmf_field(funct, values, field_name, *args, required=False, type=None, else: funct(*args, input) except UserWarning as w: - Popup('Warning: '.format(repr(w)), title='Warning') + Popup('Warning: {}'.format(repr(w)), title='Warning') except Exception as e: show_error(repr(e)) return False @@ -367,7 +369,7 @@ def add_capture(capture_data_input, values, capture_selector_dict, file_data, fr combo_button.Update(values=tuple(new_values), value=new_val) -def run_gui(): +def main(): window_input = WindowInput() capture_data_input = CaptureData() capture_text_blocks = dict() @@ -375,7 +377,7 @@ def run_gui(): f = SigMFFile() capture_selector_dict = dict() - layout = [[Text('This is the APL SIGMF tool to archive RF datasets', size=(80, 1))], + layout = [[Text('This is the SigMF tool to archive RF datasets', size=(80, 1))], [Text('Enter your data and signal captures below. You must include', auto_size_text=True), Text('required', text_color='red', font=DEFAULT_FONT + ('italic',), auto_size_text=True), Text('fields.', size=(50, 1), auto_size_text=True)], @@ -463,7 +465,7 @@ def run_gui(): [validate_button, Button('View Data')]] ) - window = Window('APL SigMF Archive Creator', + window = Window('SigMF Archive Creator', auto_size_buttons=False, default_element_size=(20, 1), auto_size_text=False, @@ -601,7 +603,3 @@ def run_gui(): break window.Close() - - -if __name__ == '__main__': - run_gui() diff --git a/sigmf/schema.py b/sigmf/schema.py index c0816a0..219ec40 100644 --- a/sigmf/schema.py +++ b/sigmf/schema.py @@ -1,4 +1,4 @@ -# Copyright 2016 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -27,8 +27,15 @@ from . import utils def get_schema(version=None): + ''' + safe load json + + In the future load specific schema versions. + ''' schema_file = os.path.join( utils.get_schema_path(os.path.dirname(utils.__file__)), 'schema.json' ) - return json.load(open(schema_file)) + with open(schema_file, 'rb') as handle: + schema = json.load(handle) + return schema diff --git a/sigmf/sigmf_hash.py b/sigmf/sigmf_hash.py index 0c45301..acdf0de 100644 --- a/sigmf/sigmf_hash.py +++ b/sigmf/sigmf_hash.py @@ -1,4 +1,4 @@ -# Copyright 2016 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/sigmf/sigmffile.py b/sigmf/sigmffile.py index 10cd8df..0e71de9 100644 --- a/sigmf/sigmffile.py +++ b/sigmf/sigmffile.py @@ -1,4 +1,4 @@ -# Copyright 2016 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/sigmf/utils.py b/sigmf/utils.py index 8c1c6f7..377339e 100644 --- a/sigmf/utils.py +++ b/sigmf/utils.py @@ -1,4 +1,4 @@ -# Copyright 2016 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/sigmf/validate.py b/sigmf/validate.py index b1c846c..de45026 100644 --- a/sigmf/validate.py +++ b/sigmf/validate.py @@ -1,4 +1,4 @@ -# Copyright 2016 GNU Radio Foundation +# Copyright 2021 GNU Radio Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal