def get_ipc_file_path(): global _IPC_FILE if _IPC_FILE: return _IPC_FILE from thonny import misc_utils if platform.system() == "Windows": base_dir = misc_utils.get_local_appdata_dir() else: base_dir = os.environ.get("XDG_RUNTIME_DIR") if not base_dir or not os.path.exists(base_dir): base_dir = os.environ.get("TMPDIR") if not base_dir or not os.path.exists(base_dir): base_dir = THONNY_USER_DIR for name in ("LOGNAME", "USER", "LNAME", "USERNAME"): if name in os.environ: username = os.environ.get(name) break else: username = os.path.basename(os.path.expanduser("~")) ipc_dir = os.path.join(base_dir, "thonny-%s" % username) os.makedirs(ipc_dir, exist_ok=True) if not platform.system() == "Windows": os.chmod(ipc_dir, 0o700) _IPC_FILE = os.path.join(ipc_dir, "ipc.sock") return _IPC_FILE
def _get_ipc_file_path(): from thonny import misc_utils import getpass if platform.system() == "Windows": base_dir = misc_utils.get_local_appdata_dir() else: base_dir = os.environ.get("XDG_RUNTIME_DIR") if not base_dir or not os.path.exists(base_dir): base_dir = os.environ.get("TMPDIR") if not base_dir or not os.path.exists(base_dir): base_dir = THONNY_USER_DIR try: username = getpass.getuser() except: # https://github.com/thonny/thonny/issues/1146 # https://bugs.python.org/issue32731 username = os.path.basename(os.path.expanduser("~")) ipc_dir = os.path.join(base_dir, "thonny-%s" % username) os.makedirs(ipc_dir, exist_ok=True) if not platform.system() == "Windows": os.chmod(ipc_dir, 0o700) return os.path.join(ipc_dir, "ipc.sock")
def _get_ipc_file_path(): from thonny import misc_utils import getpass if platform.system() == "Windows": base_dir = misc_utils.get_local_appdata_dir() else: base_dir = os.environ.get("XDG_RUNTIME_DIR") if not base_dir or not os.path.exists(base_dir): base_dir = os.environ.get("TMPDIR") if not base_dir or not os.path.exists(base_dir): base_dir = THONNY_USER_DIR ipc_dir = os.path.join(base_dir, "thonny-%s" % getpass.getuser()) os.makedirs(ipc_dir, exist_ok=True) if not platform.system() == "Windows": os.chmod(ipc_dir, 0o700) return os.path.join(ipc_dir, "ipc.sock")