<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2014-2017 <NAME> (<EMAIL>)
#
# This file is part of libSigNetSim.
#
# libSigNetSim is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# libSigNetSim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libSigNetSim.  If not, see <http://www.gnu.org/licenses/>.

""" optimizations.py

	This file ...

"""

from os.path import isdir, join, exists, getsize, isfile
from os import kill, getcwd, setpgrp
from shutil import rmtree
from django.conf import settings
from subprocess import check_call, check_output
from glob import glob


def deleteOptimization(optimization):

	subdirectory = "optimization_%s" % optimization.optimization_id
	directory = join(settings.MEDIA_ROOT, optimization.project.folder, "optimizations", subdirectory)
	if isdir(directory):
		rmtree(directory)
	optimization.delete()


def getOptimizationStatus(optim_path):

	optimization_status = None

	if not exists(optim_path):
		optimization_status = "Not found"

	elif isfile(optim_path + "/logs/score/score"):
		optimization_status = "Finished"

	elif isfile(optim_path + "/err_optim") and getsize(optim_path + "/err_optim") > 0:

		non_docker_err = False
		f_err_sim = open(join(optim_path, "err_sim"), 'r')
		for line in f_err_sim:
			if not line.startswith("Unexpected end of /proc/mounts"):
				non_docker_err = True

		if non_docker_err:
			optimization_status = "Failed"
		else:
			try:
				with open(join(optim_path, "pid")) as f:
					pid = f.read()
					check_output(['pwdx', pid])  # , stdout=None, stderr=None)
					optimization_status = "Ongoing"

			except:
				optimization_status = "Interrupted"
	else:
		try:
			with open(join(optim_path, "pid")) as f:
				pid = f.read()
				check_output(['pwdx', pid])#, stdout=None, stderr=None)
				optimization_status = "Ongoing"

		except:
			optimization_status = "Interrupted"

	return optimization_status

<commit_msg>Fixed error filename<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2014-2017 <NAME> (<EMAIL>)
#
# This file is part of libSigNetSim.
#
# libSigNetSim is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# libSigNetSim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libSigNetSim.  If not, see <http://www.gnu.org/licenses/>.

""" optimizations.py

	This file ...

"""

from os.path import isdir, join, exists, getsize, isfile
from os import kill, getcwd, setpgrp
from shutil import rmtree
from django.conf import settings
from subprocess import check_call, check_output
from glob import glob


def deleteOptimization(optimization):

	subdirectory = "optimization_%s" % optimization.optimization_id
	directory = join(settings.MEDIA_ROOT, optimization.project.folder, "optimizations", subdirectory)
	if isdir(directory):
		rmtree(directory)
	optimization.delete()


def getOptimizationStatus(optim_path):

	optimization_status = None

	if not exists(optim_path):
		optimization_status = "Not found"

	elif isfile(optim_path + "/logs/score/score"):
		optimization_status = "Finished"

	elif isfile(optim_path + "/err_optim") and getsize(optim_path + "/err_optim") > 0:

		non_docker_err = False
		f_err_sim = open(join(optim_path, "err_optim"), 'r')
		for line in f_err_sim:
			if not line.startswith("Unexpected end of /proc/mounts"):
				non_docker_err = True

		if non_docker_err:
			optimization_status = "Failed"
		else:
			try:
				with open(join(optim_path, "pid")) as f:
					pid = f.read()
					check_output(['pwdx', pid])  # , stdout=None, stderr=None)
					optimization_status = "Ongoing"

			except:
				optimization_status = "Interrupted"
	else:
		try:
			with open(join(optim_path, "pid")) as f:
				pid = f.read()
				check_output(['pwdx', pid])#, stdout=None, stderr=None)
				optimization_status = "Ongoing"

		except:
			optimization_status = "Interrupted"

	return optimization_status


{'fraction_non_alphanumeric': 0.10217437196537893, 'fraction_numerical': 0.004644289634789952, 'mean_word_length': 4.390216154721275, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7539625', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1479, 'n_words': 482}