本文整理汇总了Python中HardwareRepository.HardwareRepository.addHardwareObjectsDirs方法的典型用法代码示例。如果您正苦于以下问题:Python HardwareRepository.addHardwareObjectsDirs方法的具体用法?Python HardwareRepository.addHardwareObjectsDirs怎么用?Python HardwareRepository.addHardwareObjectsDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareRepository.HardwareRepository
的用法示例。
在下文中一共展示了HardwareRepository.addHardwareObjectsDirs方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _connect_hwserver
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
def _connect_hwserver(self):
print self.hwr_directory
self.hwr_server = HardwareRepository.HardwareRepository(self.hwr_directory)
self.hwr_server.connect()
hwo_path = os.path.join(self.mxcube_dir, "HardwareObjects")
sc_hwo_path = os.path.join(hwo_path, "sample_changer")
if self.institute:
inst_hwo_path = os.path.join(hwo_path, self.institute)
HardwareRepository.addHardwareObjectsDirs([hwo_path, inst_hwo_path, sc_hwo_path])
示例2: run
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
#.........这里部分代码省略.........
try:
hoDirs += os.environ['CUSTOM_HARDWARE_OBJECTS_PATH'].split(os.path.pathsep)
except KeyError:
pass
bricksDirs = filter(None, bricksDirs)
hoDirs = filter(None, hoDirs)
app = QtGui.QApplication([])
lockfile = None
if not opts.designMode and GUIConfigFile:
lock_filename=os.path.join(tempfile.gettempdir(), '.%s.lock' % os.path.basename(GUIConfigFile or "unnamed"))
try:
lockfile = open(lock_filename, "w")
except:
logging.getLogger().exception("Cannot create lock file (%s), exiting" % lock_filename)
sys.exit(1)
else:
os.chmod(lock_filename,0666)
try:
fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
logging.getLogger().exception("Cannot acquire lock (%s), exiting (hint: maybe the same application is already running ?)" % lock_filename)
sys.exit(1)
#
# configure modules
#
HardwareRepository.setHardwareRepositoryServer(hwrServer)
HardwareRepository.addHardwareObjectsDirs(hoDirs)
BlissFramework.addCustomBricksDirs(bricksDirs)
#
# set log name and log file
#
if GUIConfigFile:
BlissFramework.setLoggingName(os.path.basename(GUIConfigFile))
log_lockfile = None
if len(logFile) > 0:
log_lock_filename=os.path.join(tempfile.gettempdir(), '.%s.lock' % os.path.basename(logFile))
log_ok=True
try:
log_lockfile = open(log_lock_filename, "w")
except:
log_ok=False
else:
try:
os.chmod(log_lock_filename,0666)
except:
pass
try:
fcntl.lockf(log_lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
log_ok=False
try:
log_lockfile.close()
except:
pass
if not log_ok:
示例3: run
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
#.........这里部分代码省略.........
main_application.setStyle(app_style)
if len(args) >= 1:
if len(args) == 1:
gui_config_file = os.path.abspath(args[0])
else:
parser.error("Too many arguments.")
sys.exit(1)
if (
len(
os.popen(
"ps -aef | grep 'python' -i | grep 'hardwareRepository'" +\
" | grep -v 'grep' | awk '{ print $3 }'"
)
.read()
.strip()
.split("\n")
)
> 1
):
QtImport.QMessageBox.warning(
None,
"Warning",
"Another instance of MXCuBE is running.\n",
QtImport.QMessageBox.Ok,
)
#sys.exit(1)
# configure modules
HardwareRepository.setHardwareRepositoryServer(hwr_path)
HardwareRepository.setUserFileDirectory(user_file_dir)
if hwobj_directories:
HardwareRepository.addHardwareObjectsDirs(hwobj_directories)
if custom_bricks_directories:
gui.add_custom_bricks_dirs(custom_bricks_directories)
log_lockfile = None
if len(log_file) > 0:
if gui_config_file:
gui.set_logging_name(os.path.basename(gui_config_file), log_template)
log_lock_filename = os.path.join(
tempfile.gettempdir(), ".%s.lock" % os.path.basename(log_file)
)
log_ok = True
try:
log_lockfile = open(log_lock_filename, "w")
except BaseException:
log_ok = False
else:
try:
os.chmod(log_lock_filename, 0o666)
except BaseException:
pass
try:
fcntl.lockf(log_lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except BaseException:
log_ok = False
try:
log_lockfile.close()
except BaseException:
pass
if not log_ok:
示例4: getStdHardwareObjectsPath
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
#
def getStdHardwareObjectsPath():
import HardwareObjects # first looks in containing package
return os.path.dirname(HardwareObjects.__file__)
sys.path.insert(0, getStdHardwareObjectsPath())
hwobj_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "HardwareObjects")
hwobj_dir_list = [hwobj_dir]
for subdir in ("sample_changer", "mockup"):
hwobj_dir_list.append(os.path.join(hwobj_dir, subdir))
HardwareRepository.addHardwareObjectsDirs(hwobj_dir_list)
#
# create the HardwareRepository logger
#
_hwr_logger = logging.getLogger("HWR")
_hwr_logger.setLevel(logging.DEBUG)
_oldLevel = logging.DEBUG
_hwr_formatter = logging.Formatter("%(asctime)s |%(levelname)-7s| %(message)s")
if len(logging.root.handlers) == 0:
#
# log to stdout
#
_hdlr = logging.StreamHandler(sys.stdout)
_hdlr.setFormatter(_hwr_formatter)
示例5: Session
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
app.register_error_handler(Exception, exception_handler)
sess = Session()
sess.init_app(app)
app.debug = False
# this line important for socketio msg, otherwise no msg is sent...
socketio.init_app(app)
# the following test prevents Flask from initializing twice
# (because of the Reloader)
if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
###Initialization of the HardwareObjects
# this is to allow Hardware Objects to do
# 'from HardwareRepository import ...'
sys.path.insert(0, os.path.dirname(__file__))
from HardwareRepository import HardwareRepository as hwr, setLogFile
hwr.addHardwareObjectsDirs([os.path.join(os.path.dirname(__file__), 'HardwareObjects')])
hwr_directory = cmdline_options.hwr_directory
hwr = hwr.HardwareRepository(os.path.abspath(os.path.expanduser(hwr_directory)))
hwr.connect()
log_file = cmdline_options.log_file
if log_file:
setLogFile(log_file)
# installs logging handler to send messages to clients
import logging_handler
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
custom_log_handler = logging_handler.MX3LoggingHandler()
custom_log_handler.setLevel(logging.DEBUG)
root_logger.addHandler(custom_log_handler)
示例6: TestException
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
from HardwareRepository.BaseHardwareObjects import HardwareObject
__credits__ = ["MXCuBE colaboration"]
__version__ = "2.2."
cwd = os.getcwd()
hwr_server = cwd + "/ExampleFiles/HardwareObjects.xml"
print "==============================================================="
print "MXCuBE home directory: %s" % cwd
print "Hardware repository: %s" % hwr_server
HardwareRepository.setHardwareRepositoryServer(hwr_server)
hardware_repository = HardwareRepository.HardwareRepository()
hardware_repository.connect()
HardwareRepository.addHardwareObjectsDirs([cwd + "/HardwareObjects"])
unittest_hwobj = hardware_repository.getHardwareObject("unittest")
if unittest_hwobj is not None:
print "UnitTest hardware object loaded"
else:
print "Unable to load UnitTest hardware object!"
print "Check if unittest.xml is in %s" % hwr_server
print "==============================================================="
class TestException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
示例7: run
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
#.........这里部分代码省略.........
"Unable to create user files directory: %s" % user_file_dir)
custom_bricks_directory = [_directory for _directory in \
custom_bricks_directory if _directory]
hwobj_directory = [_directory for _directory in \
hwobj_directory if _directory]
main_application = QApplication([])
if app_style:
main_application.setStyle(app_style)
lockfile = None
if not opts.designMode and gui_config_file:
lock_filename = os.path.join(tempfile.gettempdir(), '.%s.lock' % \
os.path.basename(gui_config_file or "unnamed"))
try:
lockfile = open(lock_filename, "w")
except:
logging.getLogger().exception(\
"Cannot create lock file (%s), exiting" % lock_filename)
sys.exit(1)
else:
os.chmod(lock_filename, 0o666)
try:
fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
logging.getLogger().exception("Cannot acquire " + \
"lock (%s), exiting " % lock_filename + \
"(hint: maybe the same application is already running ?)")
sys.exit(1)
# configure modules
HardwareRepository.setHardwareRepositoryServer(hwr_server)
HardwareRepository.addHardwareObjectsDirs(hwobj_directory)
HardwareRepository.setUserFileDirectory(user_file_dir)
BlissFramework.addCustomBricksDirs(custom_bricks_directory)
# set log name and log file
if gui_config_file:
BlissFramework.setLoggingName(os.path.basename(gui_config_file),
log_template)
log_lockfile = None
if len(logFile) > 0:
log_lock_filename = os.path.join(tempfile.gettempdir(),
'.%s.lock' % os.path.basename(logFile))
log_ok = True
try:
log_lockfile = open(log_lock_filename, "w")
except:
log_ok = False
else:
try:
os.chmod(log_lock_filename, 0o666)
except:
pass
try:
fcntl.lockf(log_lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
log_ok = False
try:
log_lockfile.close()
except:
pass
示例8: OptionParser
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
import gevent
from optparse import OptionParser
from flask import Flask, request
from flask_socketio import SocketIO
from flask_session import Session
# To make "from HardwareRepository import ..." possible
fname = os.path.dirname(__file__)
sys.path.insert(0, fname)
from HardwareRepository import HardwareRepository as hwr
hwr.addHardwareObjectsDirs([os.path.join(fname, 'HardwareObjects')])
import app as mxcube
sys.modules["Qub"] = mock.Mock()
sys.modules["Qub.CTools"] = mock.Mock()
XML_DIR = os.path.join(os.path.join(os.path.dirname(__file__), os.pardir),
"test/HardwareObjectsMockup.xml/")
opt_parser = OptionParser()
opt_parser.add_option("-r", "--repository",
dest="hwr_directory",
help="Hardware Repository XML files path",
default=XML_DIR)
示例9: run
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import addHardwareObjectsDirs [as 别名]
#.........这里部分代码省略.........
app = QApplication([])
lockfile = None
if not opts.designMode and GUIConfigFile:
lock_filename = os.path.join(
tempfile.gettempdir(),
".%s.lock" % os.path.basename(GUIConfigFile or "unnamed"),
)
try:
lockfile = open(lock_filename, "w")
except BaseException:
logging.getLogger().exception(
"Cannot create lock file (%s), exiting" % lock_filename
)
sys.exit(1)
else:
os.chmod(lock_filename, 0o666)
try:
fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except BaseException:
logging.getLogger().exception(
"Cannot acquire lock (%s), exiting (hint: maybe the same application is already running ?)"
% lock_filename
)
sys.exit(1)
#
# configure modules
#
HardwareRepository.setHardwareRepositoryServer(hwrServer)
HardwareRepository.addHardwareObjectsDirs(hoDirs)
BlissFramework.addCustomBricksDirs(bricksDirs)
#
# set log name and log file
#
if GUIConfigFile:
BlissFramework.setLoggingName(os.path.basename(GUIConfigFile))
log_lockfile = None
if len(logFile) > 0:
log_lock_filename = os.path.join(
tempfile.gettempdir(), ".%s.lock" % os.path.basename(logFile)
)
log_ok = True
try:
log_lockfile = open(log_lock_filename, "w")
except BaseException:
log_ok = False
else:
try:
os.chmod(log_lock_filename, 0o666)
except BaseException:
pass
try:
fcntl.lockf(log_lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except BaseException:
log_ok = False
try:
log_lockfile.close()
except BaseException:
pass