本文整理匯總了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: