Called at exit. Delete the context file to signal there is no active notebook.

    We don't delete the whole file, but leave it around for debugging purposes. Maybe later we want to pass some information back to the web site.
176793
def clear_context(pid_file):
    
    return
    raise RuntimeError("Should not happen")
    fname = get_context_file_name(pid_file)
    shutil.move(fname, fname.replace("context.json", "context.old.json"))

    data = {}
    data["terminated"] = str(datetime.datetime.now(datetime.timezone.utc))
    set_context(pid_file, data)
500698
public void deleteInactiveContent() throws PatchingException {
        List<File> dirs = getInactiveHistory();
        if (!dirs.isEmpty()) {
            for (File dir : dirs) {
                deleteDir(dir, ALL);
            }
        }
        dirs = getInactiveOverlays();
        if (!dirs.isEmpty()) {
            for (File dir : dirs) {
                deleteDir(dir, ALL);
            }
        }
    }
696147
def delete_if_exists(file)
      # Windows cannot delete open files, but we only have a path at this point
      # so it's too late to close the file. report failure to delete files but
      # otherwise continue without failing test.
      begin
        File.delete(file) if File.file?(file)
      rescue Exception => e
        puts "\nWARNING: #{e.message}"
      end
    end
1347117
void purge() {

        uncommittedCache.clear();

        try {
            if (cacheReadonly) {
                close(false);
            } else {
                if (dataFile != null) {
                    dataFile.close();

                    dataFile = null;
                }

                FileUtil.getDefaultInstance().delete(fileName);
            }
        } catch (Exception e) {
            throw Error.error(ErrorCode.FILE_IO_ERROR,
                              ErrorCode.M_TextCache_purging_file_error,
                              new Object[] {
                fileName, e
            });
        }
    }
1080166
function onRemove( error ) {
		if ( error ) {
			debug( 'Error encountered while attempting to delete a temporary input file %s: %s', inFile, error.message );
			return done( error );
		}
		debug( 'Successfully deleted temporary input file: %s', inFile );
		if ( dest === void 0 ) {
			debug( 'Reading temporary output file: %s', outFile );
			return readFile( outFile, {'encoding':'utf8'}, onFile );
		}
		done();
	}
555993
def start_notebook_on_demand(self, name, context):
        
        if self.is_running(name):

            last_context = self.get_context(name)
            logger.info("Notebook context change detected for %s", name)
            if not self.is_same_context(context, last_context):
                self.stop_notebook(name)
                # Make sure we don't get race condition over context.json file
                time.sleep(2.0)
            else:
                return last_context, False

        err_log = os.path.join(self.get_work_folder(name), "notebook.stderr.log")
        logger.info("Launching new Notebook named %s, context is %s", name, context)
        logger.info("Notebook log is %s", err_log)

        self.start_notebook(name, context)
        time.sleep(1)
        context = self.get_context(name)
        if "notebook_name" not in context:
            # Failed to launch within timeout
            raise RuntimeError("Failed to launch IPython Notebook, see {}".format(err_log))

        return context, True
49494
function () {
      var fileContent = self._readFileSync();

      if (fileContent.instances && fileContent.instances[this._id]) {
        delete fileContent.instances[this._id];

        self._writeFileSync(fileContent);
      }
      else {
        debug('deleteSync instance %s not exists for app: %s', this._id, self._app);
      }
    }
558397
def close_file(self):
        

        if not self.is_modified():
            LOGGER.debug("> Closing '{0}' file.".format(self.__file))

            self.file_closed.emit()
            return True

        choice = message_box.message_box("Warning", "Warning",
                                         "'{0}' document has been modified!\nWould you like to save your changes?".format(
                                             self.get_file_short_name()),
                                         buttons=QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
        if choice == QMessageBox.Save:
            if self.save_file():
                LOGGER.debug("> Closing '{0}' file.".format(self.__file))
                return True
        elif choice == QMessageBox.Discard:
            LOGGER.debug("> Discarding '{0}' file.".format(self.__file))

            self.file_closed.emit()
            return True
        else:
            return False
1357250
static void cleanup() {
        String tempFolder = getTempDir().getAbsolutePath();
        File dir = new File(tempFolder);

        File[] nativeLibFiles = dir.listFiles(new FilenameFilter() {
            private final String searchPattern = "secp256k1-";
            public boolean accept(File dir, String name) {
                return name.startsWith(searchPattern) && !name.endsWith(".lck");
            }
        });
        if(nativeLibFiles != null) {
            for(File nativeLibFile : nativeLibFiles) {
                File lckFile = new File(nativeLibFile.getAbsolutePath() + ".lck");
                if(!lckFile.exists()) {
                    try {
                        nativeLibFile.delete();
                    }
                    catch(SecurityException e) {
                        System.err.println("Failed to delete old native lib" + e.getMessage());
                    }
                }
            }
        }
    }
1250206
public void setContext(Context context) {
        log = Log.instance(context);
        options = Options.instance(context);
        classLoaderClass = options.get("procloader");

        // Avoid initializing Lint
        boolean warn = options.isLintSet("path");
        locations.update(log, warn, FSInfo.instance(context));

        // Setting this option is an indication that close() should defer actually closing
        // the file manager until after a specified period of inactivity.
        // This is to accomodate clients which save references to Symbols created for use
        // within doclets or annotation processors, and which then attempt to use those
        // references after the tool exits, having closed any internally managed file manager.
        // Ideally, such clients should run the tool via the javax.tools API, providing their
        // own file manager, which can be closed by the client when all use of that file
        // manager is complete.
        // If the option has a numeric value, it will be interpreted as the duration,
        // in seconds, of the period of inactivity to wait for, before the file manager
        // is actually closed.
        // See also deferredClose().
        String s = options.get("fileManager.deferClose");
        if (s != null) {
            try {
                deferredCloseTimeout = (int) (Float.parseFloat(s) * 1000);
            } catch (NumberFormatException e) {
                deferredCloseTimeout = 60 * 1000;  // default: one minute, in millis
            }
        }
    }
541505
def close_first_file(self):
        

        editor = self.get_current_editor()
        if len(self.__model.list_editors()) == 1 and editor.is_untitled and not editor.is_modified():
            self.close_file(leave_first_editor=False)
            return True
676650
def actions_delete():
    

    filename = action_listlocal()

    ONTOSPY_LOCAL_MODELS = get_home_location()

    if filename:
        fullpath = ONTOSPY_LOCAL_MODELS + filename

        if os.path.exists(fullpath):
            var = input("Are you sure you want to delete this file? (y/n)")
            if var == "y":
                os.remove(fullpath)
                printDebug("Deleted %s" % fullpath, "important")
                cachepath = ONTOSPY_LOCAL_CACHE + filename + ".pickle"
                # @todo: do this operation in /cache...
                if os.path.exists(cachepath):
                    os.remove(cachepath)
                    printDebug("---------")
                    printDebug("File deleted [%s]" % cachepath, "important")

                return True
            else:
                printDebug("Goodbye")

    return False
47114
private void cleanUp(File f) {
        if (f != null && f.getParentFile() != null) {
            if (m_absoluteTempPath.equalsIgnoreCase(f
                    .getParentFile().getAbsolutePath())) {
                f.delete();
            }
        }
    }
758234
def delete(self):
        
        self.clear()
        if os.path.isfile(self._filename):
            os.unlink(self._filename)
        else:
            LOGGER.debug('Session file did not exist: %s', self._filename)
874561
def delete(self):
        # type: (_BaseResumeManager) -> None
        
        self.close()
        if self._resume_file.exists():  # noqa
            try:
                self._resume_file.unlink()
            except OSError as e:
                logger.warning('could not unlink resume db: {}'.format(e))
        for ext in ('.bak', '.dat', '.dir'):  # noqa
            fp = pathlib.Path(str(self._resume_file) + ext)
            if fp.exists():
                try:
                    fp.unlink()
                except OSError as e:
                    logger.warning('could not unlink resume db: {}'.format(e))
519607
protected void deactivate(ComponentContext context) {
        destinationRef.deactivate(context);
        bootstrapContextRef.deactivate(context);
        rrsXAResFactorySvcRef.deactivate(context);
    }
483190
public final void contextDestroyed(final ServletContextEvent sce) {
		// Stop the TciIpServer
		if (this.tcpIpServer != null) {
			this.tcpIpServer.stop();
		}

		// Stop the JmxServer
		if (this.jmxServer != null) {
			this.jmxServer.stop();
		}

		// Stop the SshServer
		if (this.sshServer != null) {
			try {
				this.sshServer.stop();
			} catch (InterruptedException e) {
				LaunchingMessageKind.ESSH0002.format(e);
			}
		}
	}