本文整理汇总了Python中HardwareRepository.HardwareRepository.setUserFileDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python HardwareRepository.setUserFileDirectory方法的具体用法?Python HardwareRepository.setUserFileDirectory怎么用?Python HardwareRepository.setUserFileDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareRepository.HardwareRepository
的用法示例。
在下文中一共展示了HardwareRepository.setUserFileDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setUserFileDirectory [as 别名]
#.........这里部分代码省略.........
main_application = QtImport.QApplication([])
if app_style:
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
示例2: run
# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setUserFileDirectory [as 别名]
#.........这里部分代码省略.........
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
if not log_ok: