def test_list_profiles_in(): # No need to remove these directories and files, as they will get nuked in # the module-level teardown. td = tempfile.mkdtemp(dir=TMP_TEST_DIR) td = py3compat.str_to_unicode(td) for name in ('profile_foo', 'profile_hello', 'not_a_profile'): os.mkdir(os.path.join(td, name)) if dec.unicode_paths: os.mkdir(os.path.join(td, 'profile_ünicode')) with open(os.path.join(td, 'profile_file'), 'w') as f: f.write("I am not a profile directory") profiles = list_profiles_in(td) # unicode normalization can turn u'ünicode' into u'u\0308nicode', # so only check for *nicode, and that creating a ProfileDir from the # name remains valid found_unicode = False for p in list(profiles): if p.endswith('nicode'): pd = ProfileDir.find_profile_dir_by_name(td, p) profiles.remove(p) found_unicode = True break if dec.unicode_paths: nt.assert_true(found_unicode) nt.assert_equal(set(profiles), set(['foo', 'hello']))
def update_profiles(self): """List all profiles in the ipython_dir and cwd. """ try: from IPython.paths import get_ipython_dir from IPython.core.profileapp import list_profiles_in except ImportError as e: self.log.info("IPython not available: %s", e) return stale = set(self.profiles) for path in [get_ipython_dir(), py3compat.getcwd()]: for profile in list_profiles_in(path): if profile in stale: stale.remove(profile) pd = self.get_profile_dir(profile, path) if profile not in self.profiles: self.log.debug("Adding cluster profile '%s'", profile) self.profiles[profile] = { 'profile': profile, 'profile_dir': pd, 'status': 'stopped' } for profile in stale: # remove profiles that no longer exist self.log.debug("Profile '%s' no longer exists", profile) self.profiles.pop(profile)
def update_profiles(self): """List all profiles in the ipython_dir and cwd. """ try: from IPython.paths import get_ipython_dir from IPython.core.profileapp import list_profiles_in except ImportError as e: self.log.info("IPython not available: %s", e) return stale = set(self.profiles) for path in [get_ipython_dir(), py3compat.getcwd()]: if not os.path.isdir(path): continue for profile in list_profiles_in(path): if profile in stale: stale.remove(profile) pd = self.get_profile_dir(profile, path) if profile not in self.profiles: self.log.debug("Adding cluster profile '%s'", profile) self.profiles[profile] = { 'profile': profile, 'profile_dir': pd, 'status': 'stopped' } for profile in stale: # remove profiles that no longer exist self.log.debug("Profile '%s' no longer exists", profile) self.profiles.pop(profile)
def test_list_profiles_in(): # No need to remove these directories and files, as they will get nuked in # the module-level teardown. td = Path(tempfile.mkdtemp(dir=TMP_TEST_DIR)) for name in ("profile_foo", "profile_hello", "not_a_profile"): Path(td / name).mkdir(parents=True) if dec.unicode_paths: Path(td / u"profile_ünicode").mkdir(parents=True) with open(td / "profile_file", "w", encoding="utf-8") as f: f.write("I am not a profile directory") profiles = list_profiles_in(td) # unicode normalization can turn u'ünicode' into u'u\0308nicode', # so only check for *nicode, and that creating a ProfileDir from the # name remains valid found_unicode = False for p in list(profiles): if p.endswith('nicode'): pd = ProfileDir.find_profile_dir_by_name(td, p) profiles.remove(p) found_unicode = True break if dec.unicode_paths: assert found_unicode is True assert set(profiles) == {"foo", "hello"}
def list_profiles(self): try: from IPython.paths import get_ipython_dir from IPython.core.profileapp import list_profiles_in except ImportError as e: self.log.info("IPython not available: %s", e) return [ 'default', ] return list_profiles_in(get_ipython_dir())
def update_profiles(self): """List all profiles in the ipython_dir and cwd. """ for path in [get_ipython_dir(), os.getcwdu()]: for profile in list_profiles_in(path): pd = self.get_profile_dir(profile, path) if profile not in self.profiles: self.log.debug("Adding cluster profile '%s'" % profile) self.profiles[profile] = { 'profile': profile, 'profile_dir': pd, 'status': 'stopped' }
def update_profiles(self): """List all profiles in the ipython_dir and cwd. """ stale = set(self.profiles) for path in [get_ipython_dir(), py3compat.getcwd()]: for profile in list_profiles_in(path): if profile in stale: stale.remove(profile) pd = self.get_profile_dir(profile, path) if profile not in self.profiles: self.log.debug("Adding cluster profile '%s'", profile) self.profiles[profile] = { 'profile': profile, 'profile_dir': pd, 'status': 'stopped' } for profile in stale: # remove profiles that no longer exist self.log.debug("Profile '%s' no longer exists", profile) self.profiles.pop(stale)