当前位置: 首页>>代码示例>>Python>>正文


Python HardwareRepository.setHardwareRepositoryServer方法代码示例

本文整理汇总了Python中HardwareRepository.HardwareRepository.setHardwareRepositoryServer方法的典型用法代码示例。如果您正苦于以下问题:Python HardwareRepository.setHardwareRepositoryServer方法的具体用法?Python HardwareRepository.setHardwareRepositoryServer怎么用?Python HardwareRepository.setHardwareRepositoryServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HardwareRepository.HardwareRepository的用法示例。


在下文中一共展示了HardwareRepository.setHardwareRepositoryServer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setHardwareRepositoryServer [as 别名]

#.........这里部分代码省略.........
        pass
    
    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
开发者ID:IvarsKarpics,项目名称:BlissFramework,代码行数:69,代码来源:Qt4_startGUI.py

示例2: run

# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setHardwareRepositoryServer [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:
开发者ID:IvarsKarpics,项目名称:mxcube,代码行数:70,代码来源:startGUI.py

示例3: run

# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setHardwareRepositoryServer [as 别名]

#.........这里部分代码省略.........
        logging.getLogger().exception(\
          "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
开发者ID:MartinSavko,项目名称:mxcube,代码行数:70,代码来源:Qt4_startGUI.py

示例4: TestException

# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setHardwareRepositoryServer [as 别名]
import os
import sys
import unittest
from HardwareRepository import HardwareRepository
from HardwareRepository.BaseHardwareObjects import HardwareObject


__credits__ = ["MXCuBE colaboration"]

cwd = os.getcwd()
hwr_server = cwd +  "/HardwareRepository/configuration/xml-qt"

print "==============================================================="
print "MXCuBE home directory: %s" % cwd
print "Hardware repository: %s" % hwr_server
HardwareRepository.setHardwareRepositoryServer(hwr_server)
hardware_repository = HardwareRepository.HardwareRepository()
hardware_repository.connect()
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):
开发者ID:IvarsKarpics,项目名称:mxcube,代码行数:33,代码来源:mxcube_unittest.py

示例5: run

# 需要导入模块: from HardwareRepository import HardwareRepository [as 别名]
# 或者: from HardwareRepository.HardwareRepository import setHardwareRepositoryServer [as 别名]

#.........这里部分代码省略.........
    hoDirs = filter(None, hoDirs)

    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:
开发者ID:IvarsKarpics,项目名称:mxcube,代码行数:70,代码来源:startGUI.py


注:本文中的HardwareRepository.HardwareRepository.setHardwareRepositoryServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。