text stringlengths 0 828 |
|---|
open(self.manifest_path, ""w+"").close() |
self.new = False" |
224,"def finalize(self): |
"""""" finalize any open file handles """""" |
if self.rc_file: |
self.rc_file.close() |
if self.env_file: |
self.env_file.close()" |
225,"def remove(self): |
"""""" Removes the sprinter directory, if it exists """""" |
if self.rc_file: |
self.rc_file.close() |
if self.env_file: |
self.env_file.close() |
shutil.rmtree(self.root_dir)" |
226,"def symlink_to_bin(self, name, path): |
"""""" Symlink an object at path to name in the bin folder. """""" |
self.__symlink_dir(""bin"", name, path) |
os.chmod(os.path.join(self.root_dir, ""bin"", name), os.stat(path).st_mode | stat.S_IXUSR | stat.S_IRUSR)" |
227,"def remove_from_bin(self, name): |
"""""" Remove an object from the bin folder. """""" |
self.__remove_path(os.path.join(self.root_dir, ""bin"", name))" |
228,"def remove_from_lib(self, name): |
"""""" Remove an object from the bin folder. """""" |
self.__remove_path(os.path.join(self.root_dir, ""lib"", name))" |
229,"def remove_feature(self, feature_name): |
"""""" Remove an feature from the environment root folder. """""" |
self.clear_feature_symlinks(feature_name) |
if os.path.exists(self.install_directory(feature_name)): |
self.__remove_path(self.install_directory(feature_name))" |
230,"def clear_feature_symlinks(self, feature_name): |
"""""" Clear the symlinks for a feature in the symlinked path """""" |
logger.debug(""Clearing feature symlinks for %s"" % feature_name) |
feature_path = self.install_directory(feature_name) |
for d in ('bin', 'lib'): |
if os.path.exists(os.path.join(self.root_dir, d)): |
for link in os.listdir(os.path.join(self.root_dir, d)): |
path = os.path.join(self.root_dir, d, link) |
if feature_path in os.path.realpath(path): |
getattr(self, 'remove_from_%s' % d)(link)" |
231,"def add_to_env(self, content): |
"""""" |
add content to the env script. |
"""""" |
if not self.rewrite_config: |
raise DirectoryException(""Error! Directory was not intialized w/ rewrite_config."") |
if not self.env_file: |
self.env_path, self.env_file = self.__get_env_handle(self.root_dir) |
self.env_file.write(content + '\n')" |
232,"def add_to_rc(self, content): |
"""""" |
add content to the rc script. |
"""""" |
if not self.rewrite_config: |
raise DirectoryException(""Error! Directory was not intialized w/ rewrite_config."") |
if not self.rc_file: |
self.rc_path, self.rc_file = self.__get_rc_handle(self.root_dir) |
self.rc_file.write(content + '\n')" |
233,"def add_to_gui(self, content): |
"""""" |
add content to the gui script. |
"""""" |
if not self.rewrite_config: |
raise DirectoryException(""Error! Directory was not intialized w/ rewrite_config."") |
if not self.gui_file: |
self.gui_path, self.gui_file = self.__get_gui_handle(self.root_dir) |
self.gui_file.write(content + '\n')" |
234,"def __remove_path(self, path): |
"""""" Remove an object """""" |
curpath = os.path.abspath(os.curdir) |
if not os.path.exists(path): |
logger.warn(""Attempted to remove a non-existent path %s"" % path) |
return |
try: |
if os.path.islink(path): |
os.unlink(path) |
elif os.path.isdir(path): |
shutil.rmtree(path) |
else: |
os.unlink(path) |
# in the case we just deleted ourselves out of a valid directory, |
# we move to a valid directory. |
if curpath == path: |
os.chdir(tempfile.gettempdir()) |
except OSError: |
logger.error(""Unable to remove object at path %s"" % path) |
raise DirectoryException(""Unable to remove object at path %s"" % path)" |
235,"def __get_env_handle(self, root_dir): |
"""""" get the filepath and filehandle to the .env file for the environment """""" |
env_path = os.path.join(root_dir, '.env') |
gui_path = os.path.join(root_dir, '.gui') |
fh = open(env_path, ""w+"") |
# .env will source utils.sh if it hasn't already |
fh.write(source_template % (gui_path, gui_path)) |
fh.write(source_template % (self.shell_util_path, |
self.shell_util_path)) |
return (env_path, fh)" |
236,"def __get_rc_handle(self, root_dir): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.