本文整理汇总了Python中mi.idk.prompt.text函数的典型用法代码示例。如果您正苦于以下问题:Python text函数的具体用法?Python text怎么用?Python text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了text函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _set_param
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)
开发者ID:swarbhanu,项目名称:marine-integrations,代码行数:30,代码来源:run_instrument.py
示例2: _set_param
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)
开发者ID:ccenter,项目名称:marine-integrations,代码行数:30,代码来源:run_instrument.py
示例3: fetch_comm_config
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"
开发者ID:ccenter,项目名称:marine-integrations,代码行数:26,代码来源:run_instrument.py
示例4: get_from_console
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)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:8,代码来源:comm_config.py
示例5: fetch_metadata
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)
开发者ID:sfoley,项目名称:marine-integrations,代码行数:9,代码来源:switch_driver.py
示例6: fetch_metadata
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)
开发者ID:s-pearce,项目名称:marine-integrations,代码行数:10,代码来源:switch_driver.py
示例7: get_from_console
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()
开发者ID:ccenter,项目名称:marine-integrations,代码行数:14,代码来源:comm_config.py
示例8: update_version
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
开发者ID:sfoley,项目名称:marine-integrations,代码行数:30,代码来源:package_driver.py
示例9: send_agent_command
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
开发者ID:ccenter,项目名称:marine-integrations,代码行数:25,代码来源:run_instrument.py
示例10: parser_test_filename
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
开发者ID:cwingard,项目名称:marine-integrations,代码行数:9,代码来源:driver_generator.py
示例11: _store_resource_files
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)
开发者ID:newbrough,项目名称:marine-integrations,代码行数:10,代码来源:package_driver.py
示例12: _store_resource_files
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...")
开发者ID:lytlej,项目名称:marine-integrations,代码行数:15,代码来源:package_driver.py
示例13: update_version
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')
开发者ID:s-pearce,项目名称:marine-integrations,代码行数:17,代码来源:package_driver.py
示例14: _store_resource_files
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...")
开发者ID:sfoley,项目名称:marine-integrations,代码行数:17,代码来源:package_driver.py
示例15: get_from_console
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)
开发者ID:lytlej,项目名称:marine-integrations,代码行数:53,代码来源:comm_config.py
示例16: _get_param
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)
开发者ID:ccenter,项目名称:marine-integrations,代码行数:18,代码来源:run_instrument.py
示例17: get_repackage_version
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)
开发者ID:cwingard,项目名称:marine-integrations,代码行数:19,代码来源:package_driver.py
示例18: get_repackage_version
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)
开发者ID:s-pearce,项目名称:marine-integrations,代码行数:19,代码来源:package_driver.py
示例19: get_config_from_console
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)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:20,代码来源:comm_config.py
示例20: get_from_console
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()
开发者ID:cwingard,项目名称:marine-integrations,代码行数:19,代码来源:metadata.py
注:本文中的mi.idk.prompt.text函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论