def _set_param(self):
        """
        @brief Set a single parameter
        """
        
        _all_params = self._ia_client.get_resource('DRIVER_PARAMETER_ALL')
        print "Parameters you can set are: " + str(_all_params)
        _param_valid = False
        while _param_valid is False:
            _param = prompt.text('\nEnter a single parameter')
            if _param in _all_params:
                _param_valid = True
            else:
                print 'Invalid parameter: ' + _param 

        _value = prompt.text('Enter value')
        _value = _value.lower()

        """
        DHE: Need to convert to native types here; can't be string; at this
        point it doesn't seem to be a driver problem but rather a requirement
        for messages.
        """        
        if _value == 'true':
            _value = True
        elif _value == 'false':
            _value = False

        param_dict = {_param: _value}
        self._ia_client.set_resource(param_dict)
예제 #2
0
    def _set_param(self):
        """
        @brief Set a single parameter
        """

        _all_params = self._ia_client.get_resource('DRIVER_PARAMETER_ALL')
        print "Parameters you can set are: " + str(_all_params)
        _param_valid = False
        while _param_valid is False:
            _param = prompt.text('\nEnter a single parameter')
            if _param in _all_params:
                _param_valid = True
            else:
                print 'Invalid parameter: ' + _param

        _value = prompt.text('Enter value')
        _value = _value.lower()
        """
        DHE: Need to convert to native types here; can't be string; this is a 
        problem for the UI because we need a way to get the metadata about 
        each param to the UI.
        """
        if _value == 'true':
            _value = True
        elif _value == 'false':
            _value = False

        param_dict = {_param: _value}
        self._ia_client.set_resource(param_dict)
예제 #3
0
    def fetch_comm_config(self):
        """
        @brief collect connection information for the logger from the user
        """

        config_path = "%s/%s" % (self.metadata.driver_dir(),
                                 CommConfig.config_filename())
        self.comm_config = CommConfig.get_config_from_console(config_path)
        self.comm_config.display_config()
        #self.comm_config.get_from_console()
        self.ip_address = self.comm_config.device_addr
        self.data_port = self.comm_config.data_port
        self.command_port = self.comm_config.command_port

        if not (self.ip_address):
            self.ip_address = prompt.text('Instrument IP Address',
                                          self.ip_address)

        if not (self.data_port):
            continuing = True
            while continuing:
                sport = prompt.text('Instrument Port', self.data_port)
                try:
                    self.data_port = int(sport)
                    continuing = False
                except ValueError as e:
                    print "Error converting port to number: " + str(e)
                    print "Please enter a valid port number.\n"
예제 #4
0
    def _set_param(self):
        """
        @brief Set a single parameter
        """
        
        _all_params = self._ia_client.get_resource('DRIVER_PARAMETER_ALL')
        print "Parameters you can set are: " + str(_all_params)
        _param_valid = False
        while _param_valid is False:
            _param = prompt.text('\nEnter a single parameter')
            if _param in _all_params:
                _param_valid = True
            else:
                print 'Invalid parameter: ' + _param 

        _value = prompt.text('Enter value')
        _value = _value.lower()

        """
        DHE: Need to convert to native types here; can't be string; this is a 
        problem for the UI because we need a way to get the metadata about 
        each param to the UI.
        """        
        if _value == 'true':
            _value = True
        elif _value == 'false':
            _value = False

        param_dict = {_param: _value}
        self._ia_client.set_resource(param_dict)
예제 #5
0
    def fetch_comm_config(self):
        """
        @brief collect connection information for the logger from the user
        """

        config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
        self.comm_config = CommConfig.get_config_from_console(config_path)
        self.comm_config.display_config()
        #self.comm_config.get_from_console()
        self.ip_address = self.comm_config.device_addr
        self.data_port = self.comm_config.data_port
        self.command_port = self.comm_config.command_port
        
        if not (self.ip_address):
            self.ip_address = prompt.text( 'Instrument IP Address', self.ip_address )
            
        if not (self.data_port):
            continuing = True
            while continuing:
                sport = prompt.text( 'Instrument Port', self.data_port )
                try:
                    self.data_port = int(sport)
                    continuing = False
                except ValueError as e:
                    print "Error converting port to number: " + str(e)
                    print "Please enter a valid port number.\n"
예제 #6
0
 def get_from_console(self):
     self.device_addr = prompt.text('Device Address', self.device_addr)
     self.device_tx_port = prompt.text('Device TX Port',
                                       self.device_tx_port)
     self.device_rx_port = prompt.text('Device RX Port',
                                       self.device_rx_port)
     CommConfig.get_from_console(self)
예제 #7
0
    def get_from_console(self):

        if not self.instrument_command_port: self.instrument_command_port = DEFAULT_INSTRUMENT_CMD_PORT

        self.device_addr = prompt.text('Device Address', self.device_addr)
        self.device_port = prompt.text('Device Port', self.device_port)
        self.instrument_command_port = prompt.text('Instrument Command Port', self.instrument_command_port)
        CommConfig.get_from_console(self)
예제 #8
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """
        if not (self.driver_path):
            self.driver_path = prompt.text( 'Driver Path' )

        self.metadata = mi.idk.dataset.metadata.Metadata(self.driver_path)
        self.driver_version = prompt.text('Driver Version', self.metadata.version)
예제 #9
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """
        if not (self.driver_path):
            self.driver_path = prompt.text( 'Driver Path' )

        self.get_metadata()
        self.driver_version = prompt.text('Driver Version', self.metadata.version)
예제 #10
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """
        if not (self.driver_make and self.driver_model and self.driver_name):
            self.driver_make = prompt.text( 'Driver Make', self.driver_make )
            self.driver_model = prompt.text( 'Driver Model', self.driver_model )
            self.driver_name = prompt.text( 'Driver Name', self.driver_name )

        self.metadata = Metadata(self.driver_make, self.driver_model, self.driver_name)
예제 #11
0
    def get_from_console(self):

        if not self.instrument_command_port:
            self.instrument_command_port = DEFAULT_INSTRUMENT_CMD_PORT

        self.device_addr = prompt.text('Device Address', self.device_addr)
        self.device_port = prompt.text('Device Port', self.device_port)
        self.instrument_command_port = prompt.text(
            'Instrument Command Port', self.instrument_command_port)
        CommConfig.get_from_console(self)
예제 #12
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """
        if not (self.driver_make and self.driver_model and self.driver_name):
            self.driver_make = prompt.text( 'Driver Make', self.driver_make )
            self.driver_model = prompt.text( 'Driver Model', self.driver_model )
            self.driver_name = prompt.text( 'Driver Name', self.driver_name )

        self.get_metadata()
        self.driver_version = prompt.text('Driver Version', self.metadata.version)
예제 #13
0
    def get_from_console(self):
        """
        @brief Read comm config from the console.  This should be overloaded in a sub class.
        """
        if(not self.data_port): self.data_port = DEFAULT_DATA_PORT
        if(not self.command_port): self.command_port = DEFAULT_CMD_PORT

        self.data_port = prompt.text( 'Port Agent Data Port', self.data_port )
        self.command_port = prompt.text( 'Port Agent Command Port', self.command_port )

        if( self.confirm_config() ):
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #14
0
    def send_agent_command(self, command):
        """
        @brief Send a command to the agent. 
        """

        DA_WAIT_PERIOD = 60
        waiting = False
        print "Input command: " + str(command)
        if command == 'RESOURCE_AGENT_EVENT_GO_DIRECT_ACCESS':
            cmd = AgentCommand(command=command,
                               kwargs={
                                   'session_type': DirectAccessTypes.telnet,
                                   'session_timeout': 600,
                                   'inactivity_timeout': 600
                               })
            waiting = True
        else:
            cmd = AgentCommand(command=command)

        retval = self._ia_client.execute_agent(cmd)
        print "Results of command: " + str(retval)
        while waiting:
            print "Waiting " + str(
                DA_WAIT_PERIOD) + " seconds for you to test direct access."
            gevent.sleep(DA_WAIT_PERIOD)
            still_waiting = prompt.text('Still waiting? (y/n)')
            if still_waiting is 'n':
                waiting = False
예제 #15
0
    def update_version(self):
        """
        Update the driver version for this package.  By default increment by one.
        After updating the metadata file, commit the change to git.
        """
        last_dot = self.metadata.version.rfind('.')
        last_version = int(self.metadata.version[last_dot+1:])
        suggest_version = self.metadata.version[:last_dot+1] + str(last_version + 1)
        if self.test_mode:
            new_version = suggest_version
        else:
            new_version = prompt.text('Update Driver Version', suggest_version )
        # make sure the entered version has the correct format
        self._verify_version(new_version)
        if new_version != self.metadata.version:
            # search for the tag for this version, find out if it already exists
            cmd = 'git tag -l ' + 'release_dsd_' + self.metadata.driver_name + '_' + new_version.replace('.', '_')
            # find out if this tag name exists
            output = subprocess.check_output(cmd, shell=True)
            if len(output) > 0:
                # this tag already exists and we are not repackaging
                raise InvalidParameters("Version %s already exists.  To repackage, run package driver with the --repackage option", new_version)

            # set the new driver version in the metadata
            self.metadata.set_driver_version(new_version)
            # commit the changed file to git
            cmd = 'git commit ' + str(self.metadata.metadata_path()) + ' -m \'Updated metadata driver version\''
            os.system(cmd)

        return new_version
예제 #16
0
    def update_version(self):
        """
        Update the driver version for this package.  By default increment by one.
        After updating the metadata file, commit the change to git.
        """
        last_dot = self.metadata.version.rfind('.')
        last_version = int(self.metadata.version[last_dot + 1:])
        suggest_version = self.metadata.version[:last_dot +
                                                1] + str(last_version + 1)
        new_version = prompt.text('Update Driver Version', suggest_version)
        # make sure the entered version has the correct format
        self._verify_version(new_version)
        if new_version != self.metadata.version:
            # search for the tag for this version, find out if it already exists
            cmd = 'git tag -l ' + 'release_dsd_' + self.metadata.driver_name + '_' + new_version.replace(
                '.', '_')
            # find out if this tag name exists
            output = subprocess.check_output(cmd, shell=True)
            if len(output) > 0:
                # this tag already exists and we are not repackaging
                raise InvalidParameters(
                    "Version %s already exists.  To repackage, run package driver with the --repackage option",
                    new_version)

            # set the new driver version in the metadata
            self.metadata.set_driver_version(new_version)
            # commit the changed file to git
            cmd = 'git commit ' + str(self.metadata.metadata_path(
            )) + ' -m \'Updated metadata driver version\''
            os.system(cmd)

        return new_version
예제 #17
0
 def send_agent_command(self, command):
     """
     @brief Send a command to the agent. 
     """
     
     DA_WAIT_PERIOD = 60
     waiting = False
     print "Input command: " + str(command)
     if command == 'RESOURCE_AGENT_EVENT_GO_DIRECT_ACCESS':
         cmd = AgentCommand(command = command, 
                            kwargs={'session_type': DirectAccessTypes.telnet,
                                    'session_timeout':600,
                                    'inactivity_timeout':600})
         waiting = True
     else:
         cmd = AgentCommand(command = command)
         
     retval = self._ia_client.execute_agent(cmd)
     print "Results of command: " + str(retval)
     while waiting:
         print "Waiting " + str(DA_WAIT_PERIOD) + " seconds for you to test direct access."
         gevent.sleep(DA_WAIT_PERIOD)
         still_waiting = prompt.text('Still waiting? (y/n)')
         if still_waiting is 'n':
             waiting = False
 def parser_test_filename(self):
     """
     @brief file name of the parser tests
     @retval parser test filename
     """
     if self.metadata.full_instrument_name == None:
         print( "Please provide the full instrument name (class and series)")
         self.metadata.full_instrument_name = prompt.text( 'Instrument name' )
     return "test_%s.py" % self.metadata.full_instrument_name
    def _store_resource_files(self):
        """
        @brief Store additional files added by the driver developer.  These files life in the driver resource dir.
        """
        log.debug( " -- Searching for developer added resource files." )

        for file in os.listdir(self.generator.resource_dir()):
            log.debug("    ++ found: " + file)
            desc = prompt.text( 'Describe ' + file )
            self._add_file(self.generator.resource_dir() + "/" + file, 'resource', desc)
예제 #20
0
    def get_from_console(self):
        """
        @brief Read comm config from the console.  This should be overloaded in a sub class.
        """
        if not self.host: self.host = DEFAULT_HOST
        if not self.data_port: self.data_port = DEFAULT_DATA_PORT
        if not self.command_port: self.command_port = DEFAULT_CMD_PORT
        if not self.sniffer_port: self.sniffer_port = DEFAULT_SNIFFER_PORT

        self.host = prompt.text('Port Agent Host', self.host)
        self.data_port = prompt.text('Port Agent Data Port', self.data_port)
        self.command_port = prompt.text('Port Agent Command Port', self.command_port)
        self.sniffer_port = prompt.text('Port Agent Sniffer Port', self.sniffer_port)
        #self.sniffer_prefix = prompt.text( 'Port Agent Sniffer Prefix', self.sniffer_prefix )
        #self.sniffer_suffix = prompt.text( 'Port Agent Sniffer Suffix', self.sniffer_suffix )

        if self.confirm_config():
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #21
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """

        self.metadata = Metadata()
        self.driver_make = self.metadata.driver_make
        self.driver_model = self.metadata.driver_model
        self.driver_name = self.metadata.driver_name

        if not (self.driver_make and self.driver_model and self.driver_name):
            self.driver_make = prompt.text('Driver Make', self.driver_make)
            self.driver_model = prompt.text('Driver Model', self.driver_model)
            self.driver_name = prompt.text('Driver Name', self.driver_name)

        if not (self.driver_class):
            self.driver_class = prompt.text('Driver Class', self.driver_class)

        self.metadata = Metadata(self.driver_make, self.driver_model,
                                 self.driver_name)
예제 #22
0
    def get_from_console(self):
        """
        @brief Read comm config from the console.  This should be overloaded in a sub class.
        """
        if (not self.host): self.host = DEFAULT_HOST
        if (not self.data_port): self.data_port = DEFAULT_DATA_PORT
        if (not self.command_port): self.command_port = DEFAULT_CMD_PORT
        if (not self.sniffer_port): self.sniffer_port = DEFAULT_SNIFFER_PORT

        self.host = prompt.text('Port Agent Host', self.host)
        self.data_port = prompt.text('Port Agent Data Port', self.data_port)
        self.command_port = prompt.text('Port Agent Command Port',
                                        self.command_port)
        self.sniffer_port = prompt.text('Port Agent Sniffer Port',
                                        self.sniffer_port)
        #self.sniffer_prefix = prompt.text( 'Port Agent Sniffer Prefix', self.sniffer_prefix )
        #self.sniffer_suffix = prompt.text( 'Port Agent Sniffer Suffix', self.sniffer_suffix )

        if (self.confirm_config()):
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #23
0
    def get_from_console(self):
        self.device_os_port = prompt.text('Device OS Port',
                                          self.device_os_port)
        self.device_baud = prompt.text('Device Baud', self.device_baud)
        if int(self.device_baud) not in [
                1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
        ]:
            raise InvalidCommType(str(self.device_baud) + " is not an allowed value for device baud. " +\
                                  "[1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]")
        self.device_data_bits = prompt.text('Device Data Bits',
                                            self.device_data_bits)
        if int(self.device_data_bits) not in [5, 6, 7, 8]:
            raise InvalidCommType(str(self.device_data_bits) +\
                                  " is not an allowed value for device data bits [5, 6, 7, 8].")
        self.device_parity = prompt.text('Device Parity', self.device_parity)
        if 'n' == self.device_parity.lower(
        ) or 'none' == self.device_parity.lower():
            self.device_parity = 0
        elif 'o' == self.device_parity.lower(
        ) or 'odd' == self.device_parity.lower():
            self.device_parity = 1
        elif 'e' == self.device_parity.lower(
        ) or 'even' == self.device_parity.lower():
            self.device_parity = 2
        elif 0 <= self.device_parity <= 2:
            """
            acceptable
            """
        else:
            raise InvalidCommType(str(self.device_parity) + \
                                  " is not an allowed value for device parity. [none, odd, even]")
        self.device_stop_bits = prompt.text('Device Stop Bits',
                                            self.device_stop_bits)
        if int(self.device_stop_bits) not in [0, 1, 2]:
            raise InvalidCommType(str(self.device_stop_bits) + \
                                  " is not an allowed value for device stop bits [0, 1, 2].")
        self.device_flow_control = prompt.text('Device Flow Control',
                                               self.device_flow_control)

        if 'n' == self.device_flow_control.lower(
        ) or 'none' == self.device_flow_control.lower():
            self.device_flow_control = 0
        elif 'h' == self.device_flow_control.lower(
        ) or 'hardware' == self.device_flow_control.lower():
            self.device_flow_control = 1
        elif 's' == self.device_flow_control.lower(
        ) or 'software' == self.device_flow_control.lower():
            self.device_flow_control = 2
        elif 0 <= self.device_flow_control <= 2:
            """
            acceptable
            """
        else:
            raise InvalidCommType(str(self.device_flow_control) + \
                                  " is not an allowed value for device flow control. [none, hardware, software]")

        CommConfig.get_from_console(self)
예제 #24
0
    def _store_resource_files(self):
        """
        @brief Store additional files added by the driver developer.  These
        files live in the driver resource dir.
        """
        log.debug(" -- Searching for developer added resource files.")
        resource_dir = self.generator.resource_dir()

        if os.path.exists(resource_dir):
            for file in os.listdir(resource_dir):
                log.debug("    ++ found: " + file)
                desc = prompt.text("Describe " + file)
                self._add_file(resource_dir + "/" + file, "resource", desc)
        else:
            log.debug(" --- No resource directory found, skipping...")
예제 #25
0
 def update_version(self):
     """
     Update the driver version for this package.  By default increment by one.
     After updating the metadata file, commit the change to git.
     """
     last_dot = self.metadata.version.rfind('.')
     last_version = int(self.metadata.version[last_dot+1:])
     suggest_version = self.metadata.version[:last_dot+1] + str(last_version + 1)
     new_version = prompt.text('Update Driver Version', suggest_version )
     if new_version != self.metadata.version:
         # set the new driver version in the metadata
         self.metadata.set_driver_version(new_version)
         # commit the changed file to git
         cmd = 'git commit ' + str(self.metadata.metadata_path()) + ' -m \'Updated metadata driver version\''
         os.system(cmd)
         # read metadata again to update the version in our metadata
         self.metadata = Metadata(self.metadata.driver_path, REPODIR + '/marine-integrations')
예제 #26
0
 def _store_resource_files(self):
     """
     @brief Store additional files added by the driver developer.  These
     files live in the driver resource dir.
     """
     resource_dir = os.path.join(self.metadata.relative_driver_path(), "resource")
     log.debug(" -- Searching for developer added resource files in dir: %s",
               resource_dir)
     stringfile = self.string_file()
     if os.path.exists(resource_dir):
         for file in os.listdir(resource_dir):
             if file != stringfile:
                 log.debug("    ++ found: " + file)
                 desc = prompt.text('Describe ' + file)
                 self._add_file(resource_dir + "/" + file, 'resource', desc)
     else:
         log.debug(" --- No resource directory found, skipping...")
예제 #27
0
    def get_from_console(self):
        self.device_os_port = prompt.text("Device OS Port", self.device_os_port)
        self.device_baud = prompt.text("Device Baud", self.device_baud)
        if int(self.device_baud) not in [1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]:
            raise InvalidCommType(
                str(self.device_baud)
                + " is not an allowed value for device baud. "
                + "[1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]"
            )
        self.device_data_bits = prompt.text("Device Data Bits", self.device_data_bits)
        if int(self.device_data_bits) not in [5, 6, 7, 8]:
            raise InvalidCommType(
                str(self.device_data_bits) + " is not an allowed value for device data bits [5, 6, 7, 8]."
            )
        self.device_parity = prompt.text("Device Parity", self.device_parity)
        if "n" == self.device_parity.lower() or "none" == self.device_parity.lower():
            self.device_parity = 0
        elif "o" == self.device_parity.lower() or "odd" == self.device_parity.lower():
            self.device_parity = 1
        elif "e" == self.device_parity.lower() or "even" == self.device_parity.lower():
            self.device_parity = 2
        elif 0 <= self.device_parity <= 2:
            """
            acceptable
            """
        else:
            raise InvalidCommType(
                str(self.device_parity) + " is not an allowed value for device parity. [none, odd, even]"
            )
        self.device_stop_bits = prompt.text("Device Stop Bits", self.device_stop_bits)
        if int(self.device_stop_bits) not in [0, 1, 2]:
            raise InvalidCommType(
                str(self.device_stop_bits) + " is not an allowed value for device stop bits [0, 1, 2]."
            )
        self.device_flow_control = prompt.text("Device Flow Control", self.device_flow_control)

        if "n" == self.device_flow_control.lower() or "none" == self.device_flow_control.lower():
            self.device_flow_control = 0
        elif "h" == self.device_flow_control.lower() or "hardware" == self.device_flow_control.lower():
            self.device_flow_control = 1
        elif "s" == self.device_flow_control.lower() or "software" == self.device_flow_control.lower():
            self.device_flow_control = 2
        elif 0 <= self.device_flow_control <= 2:
            """
            acceptable
            """
        else:
            raise InvalidCommType(
                str(self.device_flow_control)
                + " is not an allowed value for device flow control. [none, hardware, software]"
            )

        CommConfig.get_from_console(self)
예제 #28
0
 def _get_param(self):
     """
     @brief Get a single parameter from the instrument (will be updated to get 
     multiple later).
     """
     
     _all_params = self._ia_client.get_resource('DRIVER_PARAMETER_ALL')
     print "Parameters you can get are: " + str(_all_params)
     _param_valid = False
     while _param_valid is False:
         _param = prompt.text('\nEnter a single parameter')
         if _param in _all_params:
             _param_valid = True
         else:
             print 'Invalid parameter: ' + _param 
             
     reply = self._ia_client.get_resource([_param])
     print 'Reply is :' + str(reply)
예제 #29
0
    def _get_param(self):
        """
        @brief Get a single parameter from the instrument (will be updated to get 
        multiple later).
        """

        _all_params = self._ia_client.get_resource('DRIVER_PARAMETER_ALL')
        print "Parameters you can get are: " + str(_all_params)
        _param_valid = False
        while _param_valid is False:
            _param = prompt.text('\nEnter a single parameter')
            if _param in _all_params:
                _param_valid = True
            else:
                print 'Invalid parameter: ' + _param

        reply = self._ia_client.get_resource([_param])
        print 'Reply is :' + str(reply)
예제 #30
0
 def get_repackage_version(self, tag_base):
     """
     Get the driver version the user wants to repackage
     """
     # suggest the current driver version as default
     repkg_version = prompt.text( 'Driver Version to re-package', self.metadata.version )
     # confirm this version has the correct format
     self._verify_version(repkg_version)
     # check to make sure this driver version exists
     tag_name = 'release_' + tag_base + '_' + repkg_version.replace('.', '_')
     cmd = 'git tag -l ' + tag_name
     # find out if this tag name exists
     output = subprocess.check_output(cmd, shell=True)
     if len(output) > 0:
         # this tag exists, check it out
         os.system('git checkout tags/' + tag_name)
     else:
         log.error('No driver version %s found', tag_name)
         raise InvalidParameters('No driver version %s found', tag_name)
예제 #31
0
 def get_repackage_version(self):
     """
     Get the driver version the user wants to repackage
     """
     # suggest the current driver version as default
     repkg_version = prompt.text( 'Driver Version to re-package', self.metadata.version )
     # check to make sure this driver version exists
     tag_name = 'driver_' + self.metadata.driver_name + '_' + repkg_version.replace('.','_')
     cmd = 'git tag -l ' + tag_name 
     # find out if this tag name exists
     output = subprocess.check_output(cmd, shell=True)
     if len(output) > 0:
         # this tag exists, check it out
         os.system('git checkout tags/' + tag_name)
         # re-read the metadata since version may have changed in metadata.yml file
         self.metadata = Metadata(self.metadata.driver_path, REPODIR + '/marine-integrations')
     else:
         log.error('No driver version %s found', tag_name)
         raise InvalidParameters('No driver version %s found', tag_name)
예제 #32
0
 def _store_resource_files(self):
     """
     @brief Store additional files added by the driver developer.  These
     files live in the driver resource dir.
     """
     resource_dir = os.path.join(self.metadata.relative_driver_path(),
                                 "resource")
     log.debug(
         " -- Searching for developer added resource files in dir: %s",
         resource_dir)
     stringfile = self.string_file()
     if os.path.exists(resource_dir):
         for file in os.listdir(resource_dir):
             if file != stringfile:
                 log.debug("    ++ found: " + file)
                 desc = prompt.text('Describe ' + file)
                 self._add_file(resource_dir + "/" + file, 'resource', desc)
     else:
         log.debug(" --- No resource directory found, skipping...")
예제 #33
0
    def get_config_from_console(filename, default_type=ConfigTypes.TCP):
        """
        @brief Factory method.  Prompt and read the config type from the console
        @param filename The file where the comm config is stored in
        @retval A CommConfig object for the type entered on the console
        """
        print( "\nDriver Comm Configuration" )

        # Currently there is only one connection type so let's just default to that

        type = prompt.text('Type [' + CommConfig.valid_type_string() + ']', default_type)
        #type=ConfigTypes.ETHERNET
        #print "Type: ethernet"

        config = CommConfig.get_config_from_type(filename, type)

        if config:
            return config
        else:
            return CommConfig.get_config_from_console(filename, default_type)
예제 #34
0
 def get_repackage_version(self, tag_base):
     """
     Get the driver version the user wants to repackage
     """
     # suggest the current driver version as default
     repkg_version = prompt.text('Driver Version to re-package',
                                 self.metadata.version)
     # confirm this version has the correct format
     self._verify_version(repkg_version)
     # check to make sure this driver version exists
     tag_name = 'release_' + tag_base + '_' + repkg_version.replace(
         '.', '_')
     cmd = 'git tag -l ' + tag_name
     # find out if this tag name exists
     output = subprocess.check_output(cmd, shell=True)
     if len(output) > 0:
         # this tag exists, check it out
         os.system('git checkout tags/' + tag_name)
     else:
         log.error('No driver version %s found', tag_name)
         raise InvalidParameters('No driver version %s found', tag_name)
예제 #35
0
    def get_from_console(self):
        """
        @brief Read metadata from the console and initialize the object.  Continue to do this until we get valid input.
        """
        self.driver_path = prompt.text("Driver Path", self.driver_path)
        self.driver_name = prompt.text("Driver Name", self.driver_name)
        self.full_instrument_name = prompt.text("Parser Name (Site(s), Class, Series))", self.full_instrument_name)
        self.version = prompt.text("Driver Version", self.version)
        self.author = prompt.text("Author", self.author)
        self.email = prompt.text("Email", self.email)
        self.notes = prompt.multiline("Release Notes", self.notes)
        # constructor must match driver class constructor name in driver.py
        self.constructor = prompt.text("Driver Constructor", self.constructor)
        self._generate_versioned_metadata()

        if self.confirm_metadata():
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #36
0
    def get_config_from_console(filename, default_type=ConfigTypes.ETHERNET):
        """
        @brief Factory method.  Prompt and read the config type from the console
        @param filename The file where the comm config is stored in
        @retval A CommConfig object for the type entered on the console
        """
        print("\nDriver Comm Configuration")

        # Currently there is only one connection type so let's just default to that

        type = prompt.text('Type [' + CommConfig.valid_type_string() + ']',
                           default_type)
        #type=ConfigTypes.ETHERNET
        #print "Type: ethernet"

        config = CommConfig.get_config_from_type(filename, type)

        if (config):
            return config
        else:
            return CommConfig.get_config_from_console(filename, default_type)
예제 #37
0
    def get_from_console(self):
        """
        @brief Read metadata from the console and initialize the object.  Continue to do this until we get valid input.
        """
        self.driver_make = prompt.text('Driver Make', self.driver_make)
        self.driver_model = prompt.text('Driver Model', self.driver_model)
        self.driver_name = prompt.text('Driver Name', self.driver_name)
        self.version = prompt.text('Driver Version', self.version)
        self.author = prompt.text('Author', self.author)
        self.email = prompt.text('Email', self.email)
        self.notes = prompt.multiline('Release Notes', self.notes)

        if (self.confirm_metadata()):
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #38
0
    def get_from_console(self):
        """
        @brief Read metadata from the console and initialize the object.  Continue to do this until we get valid input.
        """
        self.driver_make = prompt.text( 'Driver Make', self.driver_make )
        self.driver_model = prompt.text( 'Driver Model', self.driver_model )
        self.driver_name = prompt.text( 'Driver Name', self.driver_name )
        self.version = prompt.text( 'Driver Version', self.version )
        self.author = prompt.text( 'Author', self.author )
        self.email = prompt.text( 'Email', self.email )
        self.notes = prompt.multiline( 'Release Notes', self.notes )

        if( self.confirm_metadata() ):
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #39
0
    def get_from_console(self):
        self.device_os_port = prompt.text( 'Device OS Port', self.device_os_port )
        self.device_baud = prompt.text( 'Device Baud', self.device_baud )
        if int(self.device_baud) not in [1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]:
            raise InvalidCommType(str(self.device_baud) + " is not an allowed value for device baud. " +\
                                  "[1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]")
        self.device_data_bits = prompt.text( 'Device Data Bits', self.device_data_bits )
        if int(self.device_data_bits) not in [5, 6, 7, 8]:
            raise InvalidCommType(str(self.device_data_bits) +\
                                  " is not an allowed value for device data bits [5, 6, 7, 8].")
        self.device_parity = prompt.text( 'Device Parity', self.device_parity )
        if 'n' == self.device_parity.lower() or 'none' == self.device_parity.lower():
            self.device_parity = 0
        elif 'o' == self.device_parity.lower() or 'odd' == self.device_parity.lower():
            self.device_parity = 1
        elif 'e' == self.device_parity.lower() or 'even' == self.device_parity.lower():
            self.device_parity = 2
        elif 0 <= self.device_parity <= 2:
            """
            acceptable
            """
        else:
            raise InvalidCommType(str(self.device_parity) + \
                                  " is not an allowed value for device parity. [none, odd, even]")
        self.device_stop_bits = prompt.text( 'Device Stop Bits', self.device_stop_bits )
        if int(self.device_stop_bits) not in [0, 1, 2]:
            raise InvalidCommType(str(self.device_stop_bits) + \
                                  " is not an allowed value for device stop bits [0, 1, 2].")
        self.device_flow_control = prompt.text( 'Device Flow Control', self.device_flow_control )

        if 'n' == self.device_flow_control.lower() or 'none' == self.device_flow_control.lower():
            self.device_flow_control = 0
        elif 'h' == self.device_flow_control.lower() or 'hardware' == self.device_flow_control.lower():
            self.device_flow_control = 1
        elif 's' == self.device_flow_control.lower() or 'software' == self.device_flow_control.lower():
            self.device_flow_control = 2
        elif 0 <= self.device_flow_control <= 2:
            """
            acceptable
            """
        else:
            raise InvalidCommType(str(self.device_flow_control) + \
                                  " is not an allowed value for device flow control. [none, hardware, software]")


        CommConfig.get_from_console(self)
예제 #40
0
    def get_from_console(self):
        """
        @brief Read metadata from the console and initialize the object.  Continue to do this until we get valid input.
        """
        self.driver_path = prompt.text('Driver Path', self.driver_path)
        self.driver_name = prompt.text('Driver Name', self.driver_name)
        self.full_instrument_name = prompt.text(
            'Full Instrument Name (Class and Series)',
            self.full_instrument_name)
        self.version = prompt.text('Driver Version', self.version)
        self.author = prompt.text('Author', self.author)
        self.email = prompt.text('Email', self.email)
        self.notes = prompt.multiline('Release Notes', self.notes)
        # constructor must match driver class constructor name in driver.py
        self.constructor = prompt.text('Driver Constructor', self.constructor)
        self._generate_versioned_metadata()

        if (self.confirm_metadata()):
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #41
0
    def get_repackage_version(self, tag_base):
        """
        Get the driver version the user wants to repackage
        """
        if self.test_mode:
            repkg_version = self.metadata.version
        else:
            # suggest the current driver version as default
            repkg_version = prompt.text("Driver Version to re-package", self.metadata.version)

        # confirm this version has the correct format
        self._verify_version(repkg_version)
        # check to make sure this driver version exists
        tag_name = "release_" + tag_base + "_" + repkg_version.replace(".", "_")
        cmd = "git tag -l " + tag_name
        # find out if this tag name exists
        output = subprocess.check_output(cmd, shell=True)
        if len(output) > 0:
            # this tag exists, check it out
            os.system("git checkout tags/" + tag_name)
        else:
            log.error("No driver version %s found", tag_name)
            raise InvalidParameters("No driver version %s found", tag_name)
예제 #42
0
    def get_from_console(self):
        """
        @brief Read metadata from the console and initialize the object.  Continue to do this until we get valid input.
        """
        self.driver_path = prompt.text( 'Driver Path', self.driver_path )
        self.driver_name = prompt.text( 'Driver Name', self.driver_name )
        self.version = prompt.text( 'Driver Version', self.version )
        self.author = prompt.text( 'Author', self.author )
        self.email = prompt.text( 'Email', self.email )
        self.notes = prompt.multiline( 'Release Notes', self.notes )
        # constructor must match driver class constructor name in driver.py
        self.constructor = prompt.text( 'Driver Constructor', self.constructor )
        self._generate_versioned_metadata()

        if( self.confirm_metadata() ):
            self.store_to_file()
        else:
            return self.get_from_console()
예제 #43
0
 def get_from_console(self):
     self.device_addr = prompt.text('Device Address', self.device_addr)
     self.device_tx_port = prompt.text('Device TX Port', self.device_tx_port)
     self.device_rx_port = prompt.text('Device RX Port', self.device_rx_port)
     CommConfig.get_from_console(self)
예제 #44
0
 def fetch_driver_class(self):
     self.driver_class = prompt.text('Driver Class', self.driver_class)
예제 #45
0
    def get_user_command(self, text='Enter command'):

        command = prompt.text(text)
        return command
예제 #46
0
    def get_user_command(self, text='Enter command'):

        command = prompt.text(text)
        return command
예제 #47
0
 def fetch_driver_class(self):
     self.driver_class = prompt.text( 'Driver Class', self.driver_class )
예제 #48
0
 def get_from_console(self):
     self.device_addr = prompt.text("Device Address", self.device_addr)
     self.device_port = prompt.text("Device Port", self.device_port)
     CommConfig.get_from_console(self)