launchdsimple.py 文件源码

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

项目:munkisuit 作者: velotraveler 项目源码 文件源码
def list(self, labelmatch="*"):
        '''
        run "launchctl list" and return list of jobs that match the shell-
        style wildcard <labelmatch>

        since all jobs have our app-specific prefix, and have their
        run time appended to their names, caller should terminate
        <labelmatch> with ".*" unless they already have an exact name.
        '''
        results = []
        try:
            output = subprocess.check_output(["sudo", "launchctl", "list"])
            for line in output.split("\n"):
                if len(line) == 0:
                    break
                fields= line.split(None,3)
                if len(fields) < 3:
                    self.bomb("unexpected output from 'sudo launchctl list: %s'" % line)
                job= fields[2]
                if fnmatch(job, self.prefix + labelmatch):
                    results.append(job[len(self.prefix):])
        except (subprocess.CalledProcessError) as error:
            self.bomb("running 'sudo launchctl list'", error)
        return results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号