def _listen(self): """ read data from stdin, and interpret it as a chat message """ try: line = sys.stdin.readline() except KeyboardInterrupt: self._log("keyboard interrupt", 1) # self._invokeTextCallback("console", "Goodbye.") return False line = util.try_decode(line, self._encoding) self._invokeTextCallback("console", line) return True
def get_commits_raw(directory, range_str: str) -> List[str]: os.chdir(directory) result = subprocess.run( (f"git log --pretty=format:\"%H\" --no-patch {range_str}").split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) os.chdir(script_path) util.check_result_throw(result) decoded_stdout = util.try_decode(result.stdout) if decoded_stdout is not None: return [x.strip("'\"") for x in decoded_stdout.splitlines()] else: return []
def _listen(self): """ reads a bunch of data from the socket, splits it up in lines, and interprets them. the last line, if unfinished, is not interpreted and saved for the next _listen() call. """ # read up to 4 kB of data into the buffer. self._readBuffer += self._socket.recv(4096) # get all distinct lines from the buffer into lines. lines = self._readBuffer.split('\n') # move the last (unfinished) line back into the buffer. self._readBuffer = lines.pop() # process all lines. for line in lines: line = util.try_decode(line, self._encoding) self._log("rx: " + line, 3) # split the line up at spaces line = line.rstrip().split(' ', 3) if len(line) < 2: continue # check if the line contains a ping message (PING) if line[0] == "PING": self._sendMessage("PONG " + line[1]) if len(line) < 4: continue # check if the line contains a private message (PRIVMSG) if line[1] == "PRIVMSG": self._invokeTextCallback(line[0].split('!')[0].lstrip(': '), line[3].lstrip(': ')) if line[1] == "366": # RPL_ENDOFNAMES self._connectionEstablished() elif line[1] == "001": self.welcomemsg_received = True return True
def _listen(self): """ read data from stdin, and interpret it as a chat message """ try: line = sys.stdin.readline() if not line: self._log("stdin EOF", 1) return False if not line.strip(): # ignore empty / whitespace-only lines return True except KeyboardInterrupt: self._log("keyboard interrupt", 1) # self._invokeTextCallback("console", "Goodbye.") return False line = util.try_decode(line, self._encoding) self._invokeTextCallback("console", line) return True
def get_commit_info(cache_dir, commit): repo_info = os.path.join(cache_dir, "./repo_info") update_info_repo(cache_dir) os.chdir(repo_info) result = subprocess.run( (f"git log {commit} --date=iso --pretty=%an;%s;%ad -1").split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) os.chdir(script_path) util.check_result_throw(result) info = util.try_decode(result.stdout).splitlines()[0].split(";") # Javascript can't seem to parse the date when there is a space between time and timezone, remove it. space_index = info[2].rfind(' ') info[2] = info[2][:space_index] + info[2][space_index + 1:] return { "author": info[0], "title": info[1], "date": info[2], "ref": commit }