本文整理汇总了Python中server_common.utilities.print_and_log函数的典型用法代码示例。如果您正苦于以下问题:Python print_and_log函数的具体用法?Python print_and_log怎么用?Python print_and_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_and_log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: execute_command
def execute_command(self, command, is_query):
"""Executes a command on the database, and returns all values
Args:
command (string): the SQL command to run
is_query (boolean): is this a query (i.e. do we expect return values)
Returns:
values (list): list of all rows returned. None if not is_query
"""
conn = None
curs = None
values = None
try:
conn = self._get_connection()
curs = conn.cursor()
curs.execute(command)
if is_query:
values = curs.fetchall()
# Commit as part of the query or results won't be updated between subsequent transactions. Can lead
# to values not auto-updating in the GUI.
conn.commit()
except Exception as err:
print_and_log("Error executing command on database: %s" % err.message, "MAJOR")
finally:
if curs is not None:
curs.close()
if conn is not None:
conn.close()
return values
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:30,代码来源:mysql_abstraction_layer.py
示例2: get_active_pvs
def get_active_pvs(self):
"""Queries the database for active PVs.
Returns:
list : A list of the PVs in running IOCs
"""
values = []
sqlquery = "SELECT pvinfo.pvname, pvs.record_type, pvs.record_desc, pvs.iocname FROM pvinfo"
sqlquery += " INNER JOIN pvs ON pvs.pvname = pvinfo.pvname"
# Ensure that only active IOCs are considered
sqlquery += " WHERE (pvs.iocname in (SELECT iocname FROM iocrt WHERE running=1) AND infoname='INTEREST')"
try:
# Get as a plain list of lists
values = [list(element) for element in self._db.query(sqlquery)]
# Convert any bytearrays
for i, pv in enumerate(values):
for j, element in enumerate(pv):
if type(element) == bytearray:
values[i][j] = element.decode("utf-8")
except Exception as err:
print_and_log("issue with getting active PVs: %s" % err, "MAJOR", "DBSVR")
return values
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:25,代码来源:ioc_data.py
示例3: update_iocs_status
def update_iocs_status(self):
"""Accesses the db to get a list of IOCs and checks to see if they are currently running
Returns:
list : The names of running IOCs
"""
with self._running_iocs_lock:
self._running_iocs = list()
try:
# Get all the iocnames and whether they are running, but ignore IOCs associated with PSCTRL
sqlquery = "SELECT iocname, running FROM iocrt WHERE (iocname NOT LIKE 'PSCTRL_%')"
rows = self._db.query(sqlquery)
for row in rows:
# Check to see if running using CA and procserv
try:
if self._procserve.get_ioc_status(self._prefix, row[0]).upper() == "RUNNING":
self._running_iocs.append(row[0])
if row[1] == 0:
# This should only get called if the IOC failed to tell the DB it started
self._db.update("UPDATE iocrt SET running=1 WHERE iocname='%s'" % row[0])
else:
if row[1] == 1:
self._db.update("UPDATE iocrt SET running=0 WHERE iocname='%s'" % row[0])
except Exception as err:
# Fail but continue - probably couldn't find procserv for the ioc
print_and_log("issue with updating IOC status: %s" % err, "MAJOR", "DBSVR")
except Exception as err:
print_and_log("issue with updating IOC statuses: %s" % err, "MAJOR", "DBSVR")
return self._running_iocs
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:30,代码来源:ioc_data.py
示例4: _get_iocs
def _get_iocs(self, include_running=False):
# Get IOCs from DatabaseServer
try:
return self._db_client.get_iocs()
except Exception as err:
print_and_log("Could not retrieve IOC list: %s" % str(err), "MAJOR")
return []
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:7,代码来源:block_server.py
示例5: _start_config_iocs
def _start_config_iocs(self):
# Start the IOCs, if they are available and if they are flagged for autostart
# Note: autostart means the IOC is started when the config is loaded,
# restart means the IOC should automatically restart if it stops for some reason (e.g. it crashes)
for n, ioc in self._active_configserver.get_all_ioc_details().iteritems():
try:
# IOCs are restarted if and only if auto start is True. Note that auto restart instructs proc serv to
# restart an IOC if it terminates unexpectedly and does not apply here.
if ioc.autostart:
# Throws if IOC does not exist
running = self._ioc_control.get_ioc_status(n)
if running == "RUNNING":
# Restart it
self._ioc_control.restart_ioc(n)
else:
# Start it
self._ioc_control.start_ioc(n)
except Exception as err:
print_and_log("Could not (re)start IOC %s: %s" % (n, str(err)), "MAJOR")
# Give it time to start as IOC has to be running to be able to set restart property
sleep(2)
for n, ioc in self._active_configserver.get_all_ioc_details().iteritems():
if ioc.autostart:
# Set the restart property
print_and_log("Setting IOC %s's auto-restart to %s" % (n, ioc.restart))
self._ioc_control.set_autorestart(n, ioc.restart)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:27,代码来源:block_server.py
示例6: consume_write_queue
def consume_write_queue(self):
"""Actions any requests on the write queue.
Queue items are tuples with three values:
the method to call; the argument(s) to send (tuple); and, the description of the state (string))
For example:
self.load_config, ("configname",), "LOADING_CONFIG")
"""
while True:
while len(self.write_queue) > 0:
if self._filewatcher is not None: self._filewatcher.pause()
with self.write_lock:
cmd, arg, state = self.write_queue.pop(0)
self.update_server_status(state)
try:
if arg is not None:
cmd(*arg)
else:
cmd()
except Exception as err:
print_and_log(
"Error executing write queue command %s for state %s: %s" % (cmd.__name__, state, err.message),
"MAJOR")
self.update_server_status("")
if self._filewatcher is not None: self._filewatcher.resume()
sleep(1)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:27,代码来源:block_server.py
示例7: _pull
def _pull(self):
try:
self.remote.pull()
except GitCommandError as e:
# Most likely server issue
print_and_log("Unable to pull configurations from remote repo", "MINOR")
raise GitPullFailed()
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:7,代码来源:git_version_control.py
示例8: _set_rc_values
def _set_rc_values(self, bn, settings):
for key, value in settings.iteritems():
if key.upper() in TAG_RC_DICT.keys():
try:
self._channel_access.caput(self._block_prefix + bn + TAG_RC_DICT[key.upper()], value)
except Exception as err:
print_and_log("Problem with setting runcontrol for %s: %s" % (bn, err))
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:7,代码来源:runcontrol_manager.py
示例9: _clear_autosave_files
def _clear_autosave_files(self):
for fname in os.listdir(self._autosave_dir):
file_path = os.path.join(self._autosave_dir, fname)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
except Exception as err:
print_and_log("Problem deleting autosave files for the run-control IOC: %s" % str(err), "MAJOR")
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:8,代码来源:runcontrol_manager.py
示例10: delete_pv_from_db
def delete_pv_from_db(self, name):
if name in manager.pvs[self.port]:
print_and_log("Removing PV %s" % name)
fullname = manager.pvs[self.port][name].name
del manager.pvs[self.port][name]
del manager.pvf[fullname]
del self.pvDB[name]
del PVDB[name]
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:8,代码来源:block_server.py
示例11: _upload_archive_config
def _upload_archive_config(self):
f = os.path.abspath(self._uploader_path)
if os.path.isfile(f):
print_and_log("Running archiver settings uploader: %s" % f)
p = Popen(f)
p.wait()
else:
print_and_log("Could not find specified archiver uploader batch file: %s" % self._uploader_path)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:8,代码来源:archiver_manager.py
示例12: reload_current_config
def reload_current_config(self):
""" Reload the current configuration."""
current_config_name = self.get_config_name()
if current_config_name == "":
print_and_log("No current configuration defined. Nothing to reload.")
return
print_and_log("Trying to reload current configuration %s" % current_config_name)
self.load_active(current_config_name)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:9,代码来源:active_config_holder.py
示例13: restart_ioc
def restart_ioc(self, prefix, ioc):
"""Restarts the specified IOC.
Args:
prefix (string): The prefix for the instrument
ioc (string): The name of the IOC
"""
print_and_log("Restarting IOC %s" % ioc)
ChannelAccess.caput(self.generate_prefix(prefix, ioc) + ":RESTART", 1)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:9,代码来源:procserv_utils.py
示例14: start_ioc
def start_ioc(self, prefix, ioc):
"""Starts the specified IOC
Args:
prefix (string): The prefix of the instrument the IOC is being run on
ioc (string): The name of the IOC to start
"""
print_and_log("Starting IOC %s" % ioc)
ChannelAccess.caput(self.generate_prefix(prefix, ioc) + ":START", 1)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:9,代码来源:procserv_utils.py
示例15: reload_current_config
def reload_current_config(self):
"""Reload the current configuration."""
try:
print_and_log("Reloading current configuration")
self._active_configserver.reload_current_config()
# If we get this far then assume the config is okay
self._initialise_config(full_init=True)
except Exception as err:
print_and_log(str(err), "MAJOR")
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:9,代码来源:block_server.py
示例16: stop_ioc
def stop_ioc(self, prefix, ioc):
"""Stops the specified IOC.
Args:
prefix (string): The prefix for the instrument
ioc (string): The name of the IOC
"""
print_and_log("Stopping IOC %s" % ioc)
ChannelAccess.caput(self.generate_prefix(prefix, ioc) + ":STOP", 1)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:9,代码来源:procserv_utils.py
示例17: toggle_autorestart
def toggle_autorestart(self, prefix, ioc):
"""Toggles the auto-restart property.
Args:
prefix (string): The prefix for the instrument
ioc (string): The name of the IOC
"""
# Check IOC is running, otherwise command is ignored
print_and_log("Toggling auto-restart for IOC %s" % ioc)
ChannelAccess.caput(self.generate_prefix(prefix, ioc) + ":TOGGLE", 1)
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:10,代码来源:procserv_utils.py
示例18: restart
def restart(self):
""" Restarts via ProcServCtrl.
"""
try:
if self._ioc_control.get_ioc_status(BLOCKCACHE_PSC) == "RUNNING":
self._ioc_control.restart_ioc(BLOCKCACHE_PSC, force=True)
else:
self._ioc_control.start_ioc(BLOCKCACHE_PSC)
except Exception as err:
print_and_log("Problem with restarting the Block Cache: %s" % str(err), "MAJOR")
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:10,代码来源:block_cache_manager.py
示例19: start_ioc
def start_ioc(self, ioc):
"""Start an IOC.
Args:
ioc (string): The name of the IOC
"""
try:
self._proc.start_ioc(self._prefix, ioc)
except Exception as err:
print_and_log("Could not start IOC %s: %s" % (ioc, str(err)), "MAJOR")
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:10,代码来源:ioc_control.py
示例20: _unlock
def _unlock(self):
""" Removes index.lock if it exists, and it's not being used
"""
lock_file_path = os.path.join(self.repo.git_dir, "index.lock")
if os.path.exists(lock_file_path):
try:
os.remove(lock_file_path)
except Exception as err:
print_and_log("Unable to remove lock from version control repository: %s" %
lock_file_path, "MINOR")
else:
print_and_log("Lock removed from version control repository: %s" % lock_file_path, "INFO")
开发者ID:ISISComputingGroup,项目名称:EPICS-inst_servers,代码行数:12,代码来源:git_version_control.py
注:本文中的server_common.utilities.print_and_log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论