<commit_before>from SCons.Environment import Environment
import SCons
import sys, os
import shutil
from marshal import load
from stat import *

def installFunc(dest, source, env):
	"""Copy file, setting sane permissions"""
	shutil.copy(source, dest)
	st = os.stat(source)
	mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
	if st[ST_MODE] & S_IXUSR:
		mode |= S_IXUSR | S_IXGRP | S_IXOTH
	os.chmod(dest, mode)
	return 0

class XMMSEnvironment(Environment):
	targets=[]
	def __init__(self, parent=None, options=None, **kw):
		Environment.__init__(self, options=options)
		apply(self.Replace, (), kw)
		self.conf = SCons.SConf.SConf(self)

		if os.path.isfile("config.cache") and self["CONFIG"] == 0:
			try:
				self.config_cache=load(open("config.cache", 'rb+'))
			except IOError:
				print "Could not load config.cache!"
				self.config_cache={}
		else:
			self.config_cache={}

		self.plugins=[]
		self.libs=[]
		self.programs=[]
		self.install_targets=[]

		self["INSTALL"] = installFunc
		self.pluginpath = self["INSTALLDIR"]+"/lib/xmms2"
		self.binpath = self["INSTALLDIR"]+"/bin"
		self.librarypath = self["INSTALLDIR"]+"/lib"
		self.sharepath = self["INSTALLDIR"]+"/share/xmms2"
		self["SHLIBPREFIX"] = "lib"

		if sys.platform == 'linux2':
			self.platform = 'linux'
		elif sys.platform.startswith("freebsd"):
			self.platform = 'freebsd'
		else:
			self.platform = sys.platform
			
		if self.platform == 'darwin':
			self["SHLINKFLAGS"] = "$LINKFLAGS -multiply_defined suppress -flat_namespace -undefined suppress"
	
	def Install(self, target, source):
		SCons.Environment.Environment.Install(self, target, source)
		self.install_targets.append(target)
			
	def tryaction(self, cmd):
		if self.config_cache.has_key(cmd):
			return self.config_cache[cmd]

		try:
			os.popen(cmd).read()
			r = True
		except:
			r = False

		if r == '':
			r = False

		self.config_cache[cmd] = r

		return r

	def run(self, cmd):
		if self.config_cache.has_key(cmd):
			return self.config_cache[cmd]

		print "Running", cmd

		try:
			r = os.popen(cmd).read()
		except:
			r = None

		self.config_cache[cmd] = r
		return r<commit_msg>fix tryaction.<commit_after>from SCons.Environment import Environment
import SCons
import sys, os
import shutil
from marshal import load
from stat import *

def installFunc(dest, source, env):
	"""Copy file, setting sane permissions"""
	shutil.copy(source, dest)
	st = os.stat(source)
	mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
	if st[ST_MODE] & S_IXUSR:
		mode |= S_IXUSR | S_IXGRP | S_IXOTH
	os.chmod(dest, mode)
	return 0

class XMMSEnvironment(Environment):
	targets=[]
	def __init__(self, parent=None, options=None, **kw):
		Environment.__init__(self, options=options)
		apply(self.Replace, (), kw)
		self.conf = SCons.SConf.SConf(self)

		if os.path.isfile("config.cache") and self["CONFIG"] == 0:
			try:
				self.config_cache=load(open("config.cache", 'rb+'))
			except IOError:
				print "Could not load config.cache!"
				self.config_cache={}
		else:
			self.config_cache={}

		self.plugins=[]
		self.libs=[]
		self.programs=[]
		self.install_targets=[]

		self["INSTALL"] = installFunc
		self.pluginpath = self["INSTALLDIR"]+"/lib/xmms2"
		self.binpath = self["INSTALLDIR"]+"/bin"
		self.librarypath = self["INSTALLDIR"]+"/lib"
		self.sharepath = self["INSTALLDIR"]+"/share/xmms2"
		self["SHLIBPREFIX"] = "lib"

		if sys.platform == 'linux2':
			self.platform = 'linux'
		elif sys.platform.startswith("freebsd"):
			self.platform = 'freebsd'
		else:
			self.platform = sys.platform
			
		if self.platform == 'darwin':
			self["SHLINKFLAGS"] = "$LINKFLAGS -multiply_defined suppress -flat_namespace -undefined suppress"
	
	def Install(self, target, source):
		SCons.Environment.Environment.Install(self, target, source)
		self.install_targets.append(target)
			
	def tryaction(self, cmd):
		if self.config_cache.has_key(cmd):
			return self.config_cache[cmd]

		r = False

		try:
			os.popen(cmd).read()
			if not r == '':
				r = True
		except:
			pass

		self.config_cache[cmd] = r

		return r

	def run(self, cmd):
		if self.config_cache.has_key(cmd):
			return self.config_cache[cmd]

		print "Running", cmd

		try:
			r = os.popen(cmd).read()
		except:
			r = None

		self.config_cache[cmd] = r
		return r
{'fraction_non_alphanumeric': 0.144640753828033, 'fraction_numerical': 0.002355712603062426, 'mean_word_length': 4.036773428232503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2422930', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1517, 'n_words': 334}