Пример #1
0
	def startLog(self,filename=None,endlog=False):
		""" start logging the session, starting with a base image of it in it's current state, if no file name is provided use make a name up based on current time
		"""
		if not filename:
			filename=os.path.join('logs',getTimeString() + '.slg')

		locks=[]
		self.filename=filename

		logfile=qtcore.QFile(self.filename)
		logfile.open(qtcore.QIODevice.WriteOnly)
		log=SketchLogWriter(logfile)

		# lock for reading the size of the document
		sizelocker=qtcore.QReadLocker(self.docsizelock)
		log.logResyncStart(self.docwidth,self.docheight,0)
		# log everything to get upto this point
		pos=0
		for layer in self.layers:
			locks.append(qtcore.QWriteLocker(layer.imagelock))
			log.logLayerAdd(pos,layer.key, layer.image)
			#log.logRawEvent(0,0,layer.key,layer.image)
			pos+=1

		if endlog:
			self.endLog(log)
		else:
			self.log=log
Пример #2
0
class HiveClientWriter(qtcore.QThread):
	def __init__(self,parent,socket,master,id):
		qtcore.QThread.__init__(self)
		self.setParent(self)

		self.socket=socket
		self.master=master
		self.id=id

		self.master.registerWriterThread(id,self)

		self.buffer=qtcore.QBuffer()
		self.buffer.open(qtcore.QIODevice.ReadWrite)

		# add to list of writing threads
		lock=qtcore.QReadLocker(self.master.clientslistmutex)
		self.queue=self.master.clientwriterqueues[id]

		# create custom QXmlStreamWriter
		#self.xmlgenerator=SketchLogWriter(self.socket)

		self.xmlgenerator=SketchLogWriter(self.buffer)

		#print "attempting to connect signal"
		#self.connect(self.queue,qtcore.SIGNAL("datainqueue()"),self,qtcore.SIGNAL("datainqueue()"))
		#print "attempted to connect signal"

	def run(self):
		while 1:
			if not self.socket.isConnected():
				self.master.unregisterClient(self.id)
				return

			#print "Hive Client Writer is ready to read from queue:", self.queue
			# block until item is available from thread safe queue
			data=self.queue.get()
			if data[0]==DrawingCommandTypes.quit:
				self.master.unregisterClient(self.id)
				print_debug("exiting client writer thread")
				return
			#print "Hive Client Writer got command from Queue:", data
			# write xml data to socket
			self.xmlgenerator.logCommand(data)

			datastr="%s" % qtcore.QString(self.buffer.data())
			#print_debug("client writer wrote to sending buffer: %s" % datastr)
			self.socket.write(datastr)
			self.buffer.buffer().resize(0)
			self.buffer.seek(0)
Пример #3
0
	def __init__(self,window,socket):
		qtcore.QThread.__init__(self)
		self.socket=socket
		self.gen=SketchLogWriter(self.socket)

		self.window=window
		self.queue=window.remoteoutputqueue
Пример #4
0
class NetworkWriterThread (qtcore.QThread):
	def __init__(self,window,socket):
		qtcore.QThread.__init__(self)
		self.socket=socket
		self.gen=SketchLogWriter(self.socket)

		self.window=window
		self.queue=window.remoteoutputqueue

	def run(self):
		while 1:
			print "attempting to get item from queue"
			command=self.queue.get()
			if command[0]==DrawingCommandTypes.quit:
				return
			self.gen.logCommand(command)
Пример #5
0
class HiveClientWriter(qtcore.QThread):
	def __init__(self,parent,socket,master,id):
		#qtcore.QThread.__init__(self,parent)
		qtcore.QThread.__init__(self)
		self.setParent(self)

		self.socket=socket
		self.master=master
		self.id=id

		self.queue=self.master.clientwriterqueues[id]
		self.xmlgenerator=SketchLogWriter(self.socket)

	def run(self):
		self.xmlgenerator.logCreateDocument(self.master.window.docwidth,self.master.window.docheight)
		while 1:
			data=self.queue.get()
			self.xmlgenerator.logCommand(data)
Пример #6
0
	def __init__(self,parent,socket,master,id):
		#qtcore.QThread.__init__(self,parent)
		qtcore.QThread.__init__(self)
		self.setParent(self)

		self.socket=socket
		self.master=master
		self.id=id

		self.queue=self.master.clientwriterqueues[id]
		self.xmlgenerator=SketchLogWriter(self.socket)
Пример #7
0
	def __init__(self,windowid,socket):
		qtcore.QThread.__init__(self)
		self.socket=socket

		self.buffer=qtcore.QBuffer()
		self.buffer.open(qtcore.QIODevice.ReadWrite)
		self.gen=SketchLogWriter(self.buffer)

		window=BeeApp().master.getWindowById(windowid)

		self.queue=window.remoteoutputqueue
Пример #8
0
	def startLog(self,filename=None,endlog=False):
		""" start logging the session, starting with a base image of it in it's current state, if no file name is provided use make a name up based on current time
		"""
		if not filename:
			# make sure directory exists
			if not os.path.isdir('logs'):
				try:
					os.mkdir('logs')
				except:
					requestDisplayMessage(BeeDisplayMessageTypes.error,"Unable to create log directory","Will not be logging due to inability to to create log file directory: " + os.path.abspath('logs'),self.master)
					return

			filename=os.path.join('logs',getTimeString() + '.slg')

		locks=[]
		self.filename=filename

		logfile=qtcore.QFile(self.filename)

		if not logfile.open(qtcore.QIODevice.WriteOnly):
			requestDisplayMessage(BeeDisplayMessageTypes.error,"Unable to open log file","Will not be logging due to inability to open file: " + os.path.abspath("%s" % self.filename),self)
			return

		log=SketchLogWriter(logfile)

		# lock for reading the size of the document
		sizelocker=qtcore.QReadLocker(self.docsizelock)
		log.logResyncStart(self.docwidth,self.docheight,0)
		# log everything to get upto this point
		layerslistlocker = qtcore.QReadLocker(self.layerslistlock)
		pos=0
		for layer in self.layers:
			locks.append(qtcore.QWriteLocker(layer.imagelock))
			log.logLayerAdd(pos,layer.key, layer.image)
			pos+=1

		if endlog:
			self.endLog(log)
		else:
			self.log=log
Пример #9
0
class NetworkWriterThread (qtcore.QThread):
	""" class representing a client thread that is sending information to server
  """
	def __init__(self,windowid,socket):
		qtcore.QThread.__init__(self)
		self.socket=socket

		self.buffer=qtcore.QBuffer()
		self.buffer.open(qtcore.QIODevice.ReadWrite)
		self.gen=SketchLogWriter(self.buffer)

		window=BeeApp().master.getWindowById(windowid)

		self.queue=window.remoteoutputqueue

	def run(self):

		while 1:
			# write out initial document start tag
			datastr="%s" % qtcore.QString(self.buffer.data())
			#print "wrote to buffer: %s" % datastr
			self.socket.write(datastr)
			self.buffer.buffer().resize(0)
			self.buffer.seek(0)

			#if self.socket.state()==qtnet.QAbstractSocket.UnconnectedState:
			if not self.socket.isConnected():
				break

			#print_debug("attempting to get item from queue")
			command=self.queue.get()
			print_debug("Network Writer Thread got command from queue: %s" % str(command))
			if command[0]==DrawingCommandTypes.quit:
				return

			self.gen.logCommand(command)
Пример #10
0
	def __init__(self,parent,socket,master,id):
		qtcore.QThread.__init__(self)
		self.setParent(self)

		self.socket=socket
		self.master=master
		self.id=id

		self.master.registerWriterThread(id,self)

		self.buffer=qtcore.QBuffer()
		self.buffer.open(qtcore.QIODevice.ReadWrite)

		# add to list of writing threads
		lock=qtcore.QReadLocker(self.master.clientslistmutex)
		self.queue=self.master.clientwriterqueues[id]

		# create custom QXmlStreamWriter
		#self.xmlgenerator=SketchLogWriter(self.socket)

		self.xmlgenerator=SketchLogWriter(self.buffer)
Пример #11
0
	def startLog(self,filename=None):
		if not filename:
			filename=os.path.join('logs',str(datetime.now()) + '.slg')

		locks=[]
		self.filename=filename

		self.logfile=qtcore.QFile(self.filename)
		self.logfile.open(qtcore.QIODevice.WriteOnly)
		log=SketchLogWriter(self.logfile)

		log.logCreateDocument(self.docwidth,self.docheight)
		# log everything to get upto this point
		pos=0
		for layer in self.layers:
			locks.append(ReadWriteLocker(layer.imagelock,True))
			log.logLayerAdd(pos,layer.key)
			log.logRawEvent(0,0,layer.key,layer.image)
			pos+=1

		self.log=log