<commit_before>package gr.ntua.cslab.celar.slipstreamClient;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.StringTokenizer;

import javax.net.ssl.*;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;

import com.sixsq.slipstream.exceptions.ValidationException;
import com.sixsq.slipstream.persistence.Authz;
import com.sixsq.slipstream.persistence.CloudImageIdentifier;
import com.sixsq.slipstream.persistence.ImageModule;
import com.sixsq.slipstream.persistence.Module;
import com.sixsq.slipstream.persistence.ModuleParameter;
import com.sixsq.slipstream.persistence.ProjectModule;
import com.sixsq.slipstream.persistence.User;
import com.sixsq.slipstream.statemachine.States;
import com.sixsq.slipstream.util.SerializationUtil;


public class SlipStreamSSService {
	private String user, password, url, cookie, cookieFile, connectorName;
	private boolean cookieAuth;
    public  Logger logger = Logger.getLogger(SlipStreamSSService.class);
    public HashMap<String,String> baseImageReferences; //imageName-reference
    public HashMap<String,HashMap<String,String>> baseImages; //imageName-cloud-flavorID
    public List<ModuleParameter> baseParameters;


	/*public Module getModule(String name) throws Exception{
		String[] command = new String[] {"ss-module-get", "-u", user, "-p", password, "--endpoint", url, name};
		String ret = executeCommand(command);
		if(ret.startsWith("<?xml")){
			System.out.println(ret);
			Module m = (Module)SerializationUtil.fromXml(ret, ImageModule.class);
			//String xml = SerializationUtil.toXmlString(m);
			System.out.println(m.getName());
			//m.
			return m;
		}
		return null;
	}*/
	public String writeToFile(String script) throws IOException{
		logger.debug(script);
		BufferedWriter writer = null;
		String file = "/tmp/script.sh";
		
		try
		{
		    writer = new BufferedWriter( new FileWriter(file));
		    writer.write( script);

		}
		catch ( IOException e)
		{
		}
		finally
		{
		    try
		    {
		        if ( writer != null)
		        writer.close( );
		    }
		    catch ( IOException e)<commit_msg>actions<commit_after>package gr.ntua.cslab.celar.slipstreamClient;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.StringTokenizer;

import javax.net.ssl.*;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;

import com.sixsq.slipstream.exceptions.ValidationException;
import com.sixsq.slipstream.persistence.Authz;
import com.sixsq.slipstream.persistence.CloudImageIdentifier;
import com.sixsq.slipstream.persistence.ImageModule;
import com.sixsq.slipstream.persistence.Module;
import com.sixsq.slipstream.persistence.ModuleParameter;
import com.sixsq.slipstream.persistence.ProjectModule;
import com.sixsq.slipstream.persistence.User;
import com.sixsq.slipstream.statemachine.States;
import com.sixsq.slipstream.util.SerializationUtil;


public class SlipStreamSSService {
	private String user, password, url, cookie, cookieFile, connectorName;
	private boolean cookieAuth;
    public  Logger logger = Logger.getLogger(SlipStreamSSService.class);
    public HashMap<String,String> baseImageReferences; //imageName-reference
    public HashMap<String,HashMap<String,String>> baseImages; //imageName-cloud-flavorID
    public List<ModuleParameter> baseParameters;


	/*public Module getModule(String name) throws Exception{
		String[] command = new String[] {"ss-module-get", "-u", user, "-p", password, "--endpoint", url, name};
		String ret = executeCommand(command);
		if(ret.startsWith("<?xml")){
			System.out.println(ret);
			Module m = (Module)SerializationUtil.fromXml(ret, ImageModule.class);
			//String xml = SerializationUtil.toXmlString(m);
			System.out.println(m.getName());
			//m.
			return m;
		}
		return null;
	}*/
	public String writeToFile(String script) throws IOException{
		logger.info("writing file:" + script);
		BufferedWriter writer = null;
		String file = "/tmp/script.sh";
		
		try
		{
		    writer = new BufferedWriter( new FileWriter(file));
		    writer.write( script);

		}
		catch ( IOException e)
		{
		}
		finally
		{
		    try
		    {
		        if ( writer != null)
		        writer.close( );
		    }
		    catch ( IOException e)
{'fraction_non_alphanumeric': 0.11584578491053311, 'fraction_numerical': 0.002213613724405091, 'mean_word_length': 4.683438155136268, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '3145901', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1685, 'n_words': 341}