BrewPiProcess.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:fermentrack 作者: thorrak 项目源码 文件源码
def findConflicts(self, process):
        """
        Finds out if the process given as argument will conflict with other running instances of BrewPi
        Always returns a conflict if a firmware update is running

        Params:
        process: a BrewPiProcess object that will be compared with other running instances

        Returns:
        bool: True means there are conflicts, False means no conflict
        """

                # some OS's (OS X) do not allow processes to read info from other processes.
        matching = []
        try:
            matching = [p for p in psutil.process_iter() if any('python' in p.name() and 'flashDfu.py'in s for s in p.cmdline())]
        except psutil.AccessDenied:
            pass
        except psutil.ZombieProcess:
            pass

        if len(matching) > 0:
            return 1

        try:
            matching = [p for p in psutil.process_iter() if any('python' in p.name() and 'updateFirmware.py'in s for s in p.cmdline())]
        except psutil.AccessDenied:
            pass
        except psutil.ZombieProcess:
            pass


        if len(matching) > 0:
            return 1

        for p in self.list:
            if process.pid == p.pid:  # skip the process itself
                continue
            elif process.conflict(p):
                return 1
        return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号