How to use the zencad.util.print_to_stderr function in zencad

To help you get started, we’ve selected a few zencad examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirmik / zencad / zencad / gui / retransler.py View on Github external
def run(self):
		try:
			self.pid = os.getpid()
			self.readFile = os.fdopen(self.r)
		except Exception as ex:
			sys.stderr.write("console_retransler::rdopen error: ", ex, self.ipipe)
			sys.stderr.write("\r\n")
			sys.stderr.flush()
			exit(0)
		
		while(True):
			if self.stop_token:
				if __RETRANSLER_TRACE__:
					print_to_stderr("finish console retransler... ok")
				return
			try:
				inputdata = self.readFile.readline()
			except:
				if __RETRANSLER_TRACE__:
					print_to_stderr("finish console retransler... except")
				return
			
			zencad.gui.application.MAIN_COMMUNICATOR.send({"cmd":"console","data":inputdata})
github mirmik / zencad / zencad / __main__.py View on Github external
retrans_out_file = zencad.gui.application.CONSOLE_RETRANS_THREAD.new_file

	if pargs.sleeped:
		# Эксперементальная функциональность для ускорения обновления модели. 
		# Процесс для обновления модели создаётся заранее и ждёт, пока его пнут со стороны сервера.
		zencad.util.PROCNAME = f"sl({os.getpid()})"
		readFile = os.fdopen(zencad.gui.application.STDIN_FILENO)

		while 1:
			trace("SLEEPED THREAD: read")
			rawdata = readFile.readline()
			try:
				data = pickle.loads(base64.b64decode(bytes(rawdata, "utf-8")))
				trace("SLEEPED THREAD RECV:", data)
			except:
				print_to_stderr("Unpickle error", rawdata)
				sys.exit(0)			
	
			if "cmd" in data and data["cmd"] == "stopworld":
				sys.exit(0)
				return
	
			if "cmd" in data and data["cmd"] == "set_opposite_pid":
				OPPOSITE_PID_SAVE = data["data"]
				continue

			break

		try:
			pargs.prescale = data["need_prescale"]
			pargs.size = data["size"]
			pargs.paths = [data["path"]]
github mirmik / zencad / zencad / gui / mainwindow.py View on Github external
def bind_window(self, winid, pid, session_id):
		if __TRACE__:
			print_to_stderr("bind_window")
		with self.openlock:
			try:
				if session_id != self.session_id:
					return
		
				if __TRACE__:
					print_to_stderr("bind window")
				container = QWindow.fromWinId(winid)
				self.cc = QWidget.createWindowContainer(container)
				#self.cc.setAttribute( Qt.WA_TransparentForMouseEvents )
	
				self.cc_window = winid
				if __TRACE__:
					print_to_stderr("replace widget")
				self.vsplitter.replaceWidget(0, self.cc)
				#self.client_communicator.send("unwait")
				self.client_pid = pid
				self.setWindowTitle(self.current_opened)
		
				#info("window bind success: winid:{} file:{}".format(winid, self.current_opened))
				info("window bind success")
				if not self.need_prescale and self.last_location is not None:
					self.client_communicator.send({"cmd":"location", "dct": self.last_location})
github mirmik / zencad / zencad / gui / retransler.py View on Github external
def do_retrans(self, old=1, new=3):
		if __RETRANSLER_TRACE__:
			print_to_stderr("do_retrans old:{} new:{}".format(old, new))

		os.dup2(old, new)
		r, w = os.pipe()
		self.r = r
		self.w = w
		self.old = old
		self.new = new
		os.close(old)
		os.dup2(w, old)

		sys.stdout = os.fdopen(old, "w", 1)
github mirmik / zencad / zencad / gui / mainwindow.py View on Github external
print_to_stderr("replace widget")
				self.vsplitter.replaceWidget(0, self.cc)
				#self.client_communicator.send("unwait")
				self.client_pid = pid
				self.setWindowTitle(self.current_opened)
		
				#info("window bind success: winid:{} file:{}".format(winid, self.current_opened))
				info("window bind success")
				if not self.need_prescale and self.last_location is not None:
					self.client_communicator.send({"cmd":"location", "dct": self.last_location})
					info("restore saved eye location")
		
				self.open_in_progress = False
				self.client_communicator.send({"cmd":"redraw"})
			except Exception as ex:
				print_to_stderr("exception on window bind", ex)
github mirmik / zencad / zencad / gui / mainwindow.py View on Github external
print_to_stderr("closeEvent")
		if self.cc:
			self.cc.close()

		if self.client_communicator and self.client_communicator is not zencad.gui.application.MAIN_COMMUNICATOR:
			if __TRACE__:
				print_to_stderr("send stopworld")
			self.client_communicator.send({"cmd": "stopworld"})
		else:
			if __TRACE__:
				print_to_stderr("send smooth_stopworld")
			self.client_communicator.send({"cmd": "smooth_stopworld"})

		if SLEEPED_OPTIMIZATION and self.sleeped_client:
			if __TRACE__:
				print_to_stderr("send sleeped optimization stopworld")
			self.sleeped_client.send({"cmd":"stopworld"})
github mirmik / zencad / zencad / gui / infolabel.py View on Github external
def trace(*args):
	if zencad.configure.CONFIGURE_MAINWINDOW_TRACE:
		print_to_stderr("MAINWINDOW:", *args)
github mirmik / zencad / zencad / gui / texteditor.py View on Github external
def trace(*args):
	if zencad.configure.CONFIGURE_MAINWINDOW_TRACE:
		print_to_stderr("MAINWINDOW:", *args)
github mirmik / zencad / zencad / gui / mainwindow.py View on Github external
if __TRACE__:
			print_to_stderr("bind_window")
		with self.openlock:
			try:
				if session_id != self.session_id:
					return
		
				if __TRACE__:
					print_to_stderr("bind window")
				container = QWindow.fromWinId(winid)
				self.cc = QWidget.createWindowContainer(container)
				#self.cc.setAttribute( Qt.WA_TransparentForMouseEvents )
	
				self.cc_window = winid
				if __TRACE__:
					print_to_stderr("replace widget")
				self.vsplitter.replaceWidget(0, self.cc)
				#self.client_communicator.send("unwait")
				self.client_pid = pid
				self.setWindowTitle(self.current_opened)
		
				#info("window bind success: winid:{} file:{}".format(winid, self.current_opened))
				info("window bind success")
				if not self.need_prescale and self.last_location is not None:
					self.client_communicator.send({"cmd":"location", "dct": self.last_location})
					info("restore saved eye location")
		
				self.open_in_progress = False
				self.client_communicator.send({"cmd":"redraw"})
			except Exception as ex:
				print_to_stderr("exception on window bind", ex)