Exemple #1
0
def run_test(files=1, lines=1, threads=1, times=10):
	os.system("rm -f idir/*")
	os.system("rm -f odir/*")
	os.system(create.format(files, lines))
	ret = []	

	for i in range(times):
		start = time.clock()
		px(["./sorter","-i","idir","-o","odir","-t",str(threads)], universal_newlines=True)
		end = time.clock()
		ret.append(end-start)

	return ret
Exemple #2
0
def run_test(files=1, lines=1, threads=1, times=10):
    os.system("rm -f idir/*")
    os.system("rm -f odir/*")
    os.system(create.format(files, lines))
    ret = []

    for i in range(times):
        start = time.clock()
        px(["./sorter", "-i", "idir", "-o", "odir", "-t",
            str(threads)],
           universal_newlines=True)
        end = time.clock()
        ret.append(end - start)

    return ret
Exemple #3
0
def get_fortune():
	try:
		out = px("fortune",universal_newlines=True)
	except:
		return None

	return out
Exemple #4
0
	def get_pom(self):
		if not self.pom:
			return None
		try:
			out = px("pom",universal_newlines=True)
		except:
			return None
		return out
Exemple #5
0
	def get_fortune(self):
		if not self.fortune:
			return None
		try:
			out = px("fortune",universal_newlines=True)
		except:
			return None
		return out
Exemple #6
0
 def get_pom(self):
     if not self.pom:
         return None
     try:
         out = px("pom", universal_newlines=True)
     except:
         return None
     return out
Exemple #7
0
 def get_fortune(self):
     if not self.fortune:
         return None
     try:
         out = px("fortune", universal_newlines=True)
     except:
         return None
     return out.rstrip()
Exemple #8
0
	def handle_morse(self, string):
		if not self.morse or not string:
			return None

		string = self.pipable_string(string)

		try:
			out = px(["morse"] + string.split(" "),universal_newlines=True)
		except:
			return None

		return '\n' + out
Exemple #9
0
    def handle_morse(self, string):
        if not self.morse or not string:
            return None

        string = self.pipable_string(string)

        try:
            out = px(["morse"] + string.split(" "), universal_newlines=True)
        except:
            return None

        return '\n' + out
Exemple #10
0
def pull_handler(string):
	remote = "origin"
	branch = "master"

	if string:
		args = string.split(" ")
		if (len(string.split(" ")) == 2):
			remote = args[0]
			branch = args[1]

	try:
		out = px(["git","pull", remote, branch], universal_newlines=True);
	except:
		return "I have failed to pull, master!"
	return out.split("\n")[-2]
Exemple #11
0
def handle_cowsay(string):
	if not cow_enabled:
		return "Cowsay not installed!"

	if string == None:
		return None

	if string == "!fortune":
		string = get_fortune()
		if string == None:
			return None

	try:
		out = px(["cowsay"] + string.split(" "),universal_newlines=True)
	except:
		return None

	return '\n' + out
Exemple #12
0
	def handle_cowsay(self, string):
		if not self.cowsay or not string:
			return None

		if string == "!fortune":
			string = self.get_fortune()
			if string == None:
				return None
		if string == "!pom":
			string = self.get_pom()
			if string == None:
				return None

		try:
			out = px(["cowsay"] + string.split(" "),universal_newlines=True)
		except:
			return None

		return '\n' + out
Exemple #13
0
	def enable_features(self):
		try:
			px(["cowsay", "test"])
			self.cowsay = True
		except:
			self.cowsday = False

		try:
			px(["fortune"])
			self.fortune = True
		except:
			self.fortune = False

		try:
			px(["pom"])
			self.pom = True
		except:
			self.pom = False
Exemple #14
0
def init():
	global cow_enabled
	try:
		px(["cowsay", "test"])
	except:
		cow_enabled = False
Exemple #15
0
	def enable_features(self):
		try:
			px(["cowsay", "test"])
			self.cowsay = True
		except:
			self.cowsay = False

		try:
			px(["bcd", "test"])
			self.bcd = True
		except:
			self.bcd = False

		try:
			px(["ppt", "test"])
			self.ppt = True
		except:
			self.ppt = False

		try:
			px(["morse", "test"])
			self.morse = True
		except:
			self.morse = False

		try:
			px(["fortune"])
			self.fortune = True
		except:
			self.fortune = False

		try:
			px(["pom"])
			self.pom = True
		except:
			self.pom = False
Exemple #16
0
    def enable_features(self):
        try:
            px(["cowsay", "test"])
            self.cowsay = True
        except:
            self.cowsay = False

        try:
            px(["bcd", "test"])
            self.bcd = True
        except:
            self.bcd = False

        try:
            px(["ppt", "test"])
            self.ppt = True
        except:
            self.ppt = False

        try:
            px(["morse", "test"])
            self.morse = True
        except:
            self.morse = False

        try:
            px(["fortune"])
            self.fortune = True
        except:
            self.fortune = False

        try:
            px(["pom"])
            self.pom = True
        except:
            self.pom = False