(
cls,
server_name, # type: str
cache_dir, # type: str
)
| 45 | |
| 46 | @classmethod |
| 47 | def load( |
| 48 | cls, |
| 49 | server_name, # type: str |
| 50 | cache_dir, # type: str |
| 51 | ): |
| 52 | # type: (...) -> Optional[Pidfile] |
| 53 | pidfile = cls._pidfile(cache_dir) |
| 54 | try: |
| 55 | with open(pidfile) as fp: |
| 56 | data = json.load(fp) |
| 57 | return cls(ServerInfo(url=data["url"], pid=data["pid"])) |
| 58 | except (OSError, IOError, ValueError, KeyError) as e: |
| 59 | logger.debug( |
| 60 | "Failed to load {server} pid file from {path}: {err}".format( |
| 61 | server=server_name, path=pidfile, err=e |
| 62 | ) |
| 63 | ) |
| 64 | return None |
| 65 | |
| 66 | @staticmethod |
| 67 | def _read_url( |
no test coverage detected