bitmessagecli.py 文件源码

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

项目:PyBitmessage-CLI 作者: Lvl4Sword 项目源码 文件源码
def run_bitmessage(self):
        if self.bm_active is not True:
            try:
                if sys.platform.startswith('win'):
                    self.enable_bm = subprocess.Popen(os.path.join(self.program_dir, 'bitmessagemain.py'),
                                                      stdout=subprocess.PIPE,
                                                      stderr=subprocess.PIPE,
                                                      stdin=subprocess.PIPE,
                                                      bufsize=0,
                                                      cwd=self.program_dir)
                else:
                    self.enable_bm = subprocess.Popen(os.path.join(self.program_dir, 'bitmessagemain.py'),
                                                      stdout=subprocess.PIPE,
                                                      stderr=subprocess.PIPE,
                                                      stdin=subprocess.PIPE,
                                                      bufsize=0,
                                                      cwd=self.program_dir,
                                                      preexec_fn=os.setpgrp,
                                                      close_fds=True)
                self.bm_active = True
            except OSError as e:
                if 'Permission denied' in e:
                    print('Got "Permission denied" when trying to access bitmessagemain.py')
                    print("Please double-check the permissions on the file and ensure it can be ran.")
                    print("Otherwise, it may be a folder permission issue.")
                else:
                    print('Is the CLI in the same directory as bitmessagemain.py?')
                self.kill_program()
            for each in self.enable_bm.stdout:
                if 'Another instance' in each:
                    if self.first_run is True:
#                        print("bitmessagemain.py is already running")
#                        print("Please close it and re-run the Bitmessage CLI")
#                        self.kill_program()
                        pass
                    break
                elif each.startswith('Running as a daemon.'):
                    self.bm_active = True
                    break
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号