Beispiel #1
0
class CommandPad(Pad):
	def __init__(self, stdscr):
		super(CommandPad, self).__init__(stdscr)
		self.tb = Titlebar(self.stdscr)
		self.sb = Statusbar(self.stdscr, "(Status)", "", "")
		self.usage()
	
	def active(self):
		super(CommandPad, self).active()
		try:
			self.tb.draw()
			self.sb.draw("")
		except:
			raise
		
	def inactive(self):
		super(CommandPad, self).inactive()
	
	def usage(self):
		self.dlog.msg(str(self.get_position()) + "\n")
		self.addstr("__   __   _   _    \n")
		self.addstr("\ \ / /__| |_| |_ _  _\n")
		self.addstr(" \ V / _ \  _|  _| || |\n")
		self.addstr("  |_|\___/\__|\__|\_,_|\n")
		self.addstr("Yottu v.0.1 - https://github.com/yottu/yottu\n", curses.A_BOLD)
		self.addstr("\n")
		self.addstr("Set board context: /board <board>\n")
		self.addstr("Display Threads in current board context: /list <board> [not implemented]\n")
		self.addstr("Open a thread in current board context: /join <thread number>\n")
		self.addstr("Show settings: /set\n")
		self.addstr("Save settings: /save\n")
		
Beispiel #2
0
class ThreadFetcher(threading.Thread):
	def __init__(self, threadno, stdscr, board, bp, nickname):
		self.threadno = threadno
		self.stdscr = stdscr
		self.board = board
		self.bp = bp
		self.nickname = nickname		
		self.sb = Statusbar(self.stdscr, self.nickname, self.board, self.threadno)
		self.tb = Titlebar(self.stdscr)
		Thread.__init__(self)
		self._stop = threading.Event()
		self._active = False # BoardPad the ThreadFetcher runs in is active
		
	def stop(self):
		self._stop.set()
		
	def active(self):
		self._active = True
		self.tb.draw()
		
	def inactive(self):
		self._active = False

	def run(self):
		dlog = DebugLog()
		dlog.msg("ThreadFetcher: Running on /" + self.board + "/" + self.threadno + "\n", 3)
		
		try:
			dictOutput = DictOutput(self.bp)
			getThread = Autism(self.threadno, self.board)
		except Exception as e:
			dlog.excpt(e)
			self.stdscr.addstr(0, 0, str(e), curses.A_REVERSE)
			self.stdscr.refresh()
				
		self.tb.draw()
		
		while True:
			
			dlog.msg("ThreadFetcher: Fetching for /" + self.board + "/" + self.threadno + "\n", 3)
			if self._stop.is_set():
				dlog.msg("ThreadFetcher: Stop signal for /" + self.board + "/" + self.threadno + "\n", 3)
				break
	
			try:
				getThread.setstdscr(self.stdscr)
				getThread.get()
				thread = getattr(getThread, "threadjson")
				dictOutput.refresh(thread)
				self.tb.set_title(dictOutput.getTitle())
			except Exception as e:
				self.sb.setStatus(str(e))
				dlog.excpt(e)
				pass
				
			for update_n in range (9, -1, -1):
				if self._stop.is_set():
					break
				
				try:
					if self._active:
						self.sb.draw(update_n)
				except Exception as e:
					dlog.excpt(e)
					pass
				

				time.sleep(1)