<commit_before>package com.doos.webloc_opener.service.gui;

import org.apache.log4j.Logger;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import static com.doos.webloc_opener.service.Logging.getCurrentClassName;

/**
 * Created by <NAME> on 02.11.2016.
 * <p>
 * Maybe there is a better solution, but I didn't find in out yet. Any ideas?
 */


public class WindowFocusRequester {
    private static final Logger log = Logger.getLogger(getCurrentClassName());

    public static String requestFocusOnWindowScript(String windowTitle) {
        String script = "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n" +
                "WshShell.AppActivate(\"" + windowTitle + "\")";
        log.debug("Script created: " + script);
        return script;
    }

    public static boolean runScript(String script) {
        FileWriter fw = null;
        try {
            File file = File.createTempFile("WeblocOpenerScript", ".vbs");
            file.deleteOnExit();
            fw = new java.io.FileWriter(file);
            log.debug("Temp file created at: " + file.getAbsolutePath());
            fw.write(script);

            Process p = Runtime.getRuntime().exec("wscript " + file.getPath());
            p.waitFor();
            return (p.exitValue() == 1);
        } catch (Exception e) {
            log.warn("Can not run script: " + script, e);
            return false;
        } finally {
            try {
                fw.close();
            } catch (IOException ignore) {/*NOP*/}
        }
    }
}<commit_msg>bugfix<commit_after>package com.doos.webloc_opener.service.gui;

import org.apache.log4j.Logger;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import static com.doos.webloc_opener.service.Logging.getCurrentClassName;

/**
 * Created by <NAME> on 02.11.2016.
 * <p>
 * Maybe there is a better solution, but I didn't find in out yet. Any ideas?
 */


public class WindowFocusRequester {
    private static final Logger log = Logger.getLogger(getCurrentClassName());

    public static String requestFocusOnWindowScript(String windowTitle) {
        String script = "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n" +
                "WshShell.AppActivate(\"" + windowTitle + "\")";
        log.debug("Script created: " + script);
        return script;
    }

    public static boolean runScript(String script) {
        FileWriter fw = null;
        try {
            File file = File.createTempFile("WeblocOpenerScript", ".vbs");
            file.deleteOnExit();
            fw = new java.io.FileWriter(file);
            log.debug("Temp file created at: " + file.getAbsolutePath());
            fw.write(script);

            Process p = Runtime.getRuntime().exec("wscript " + file.getPath());
            p.waitFor();
            return (p.exitValue() == 1);
        } catch (Exception e) {
            log.warn("Can not run script: " + script, e);
            return false;
        } finally {
            try {
                if (fw != null) {
                    fw.close();
                }
            } catch (IOException ignore) {/*NOP*/}
        }
    }
}
{'fraction_non_alphanumeric': 0.12567098200189453, 'fraction_numerical': 0.006315124723713293, 'mean_word_length': 2.216243654822335, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6345624', 'n_tokens_mistral': 938, 'n_tokens_neox': 908, 'n_words': 221}