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
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
def get_fortune(): try: out = px("fortune",universal_newlines=True) except: return None return out
def get_pom(self): if not self.pom: return None try: out = px("pom",universal_newlines=True) except: return None return out
def get_fortune(self): if not self.fortune: return None try: out = px("fortune",universal_newlines=True) except: return None return out
def get_pom(self): if not self.pom: return None try: out = px("pom", universal_newlines=True) except: return None return out
def get_fortune(self): if not self.fortune: return None try: out = px("fortune", universal_newlines=True) except: return None return out.rstrip()
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
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
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]
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
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
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
def init(): global cow_enabled try: px(["cowsay", "test"]) except: cow_enabled = False
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