Exemplo n.º 1
0
	def screenTake(self):
		self.screenClear()
		try:
			self.shot.take()
			if self.shot.img is not None:
				self.lb_screen.setPixmap(self.shot.img.scaled(400, 200, Qt.KeepAspectRatioByExpanding))
				self.ver_thumb = self.shot.fname
		except Exception as err:
			wapp.error(u"Unable to take screenshot: {0}".format(utils.error_unicode(err)))
Exemplo n.º 2
0
	def execute(self, func, args):
		res = None
		try:
			res = func(*args)
		except Exception as err:
			self.log.error('EXCEPTION', exc_info=1)
			wapp.error(utils.error_unicode(err))

		return res
Exemplo n.º 3
0
	def z_open(self, task, filepath, linked_task):
		self.log.info('Load file started...')		
		self.log.info('Task: %s. Path original file: %s', task["path"] + task["name"], filepath)

		orig_ext = os.path.splitext(filepath)[1]
		task_paths = self.config.translate(task)
		fvers = vfile.VFile(task_paths, orig_ext)
		res = False

		if task["name_editable"] or len(task_paths["name_list"]) > 1:
			custom_name = u""
			if linked_task:
				custom_name = wapp.string("Enter valid file name", task_paths["name_list"], task["name_editable"])
			else:
				custom_name = fvers.file_name(filepath)
			if len(custom_name) > 0:
				self.config.set_task_filename(task["id"], custom_name)
				task_paths = self.config.translate(task)
				fvers.setConfig(task_paths, orig_ext)
			else:
				return False

		try:
			processdata = {}
			processdata["original_file_path"] = filepath
			processdata["local_file_path"] = fvers.local_path()

			ret = self.z_processor(task, "open_pre", processdata)
			if ret[0] is None: return False
			for k in processdata: processdata[k] = ret[0][k]
			ret = self.z_processor(task, "open_replace", processdata)

			if ret[0] is not None and not ret[1]:
				for k in processdata: processdata[k] = ret[0][k]
				if utils.np(processdata["original_file_path"]) != utils.np(processdata["local_file_path"]):
					self.log.info('Copy file to working directory: %s', processdata["local_file_path"])	
					if not os.path.exists(os.path.dirname(processdata["local_file_path"])):
						os.makedirs(os.path.dirname(processdata["local_file_path"]))

					shutil.copy(processdata["original_file_path"], processdata["local_file_path"])

				if capp.save_query(self.log):
					processdata["local_file_path"] = capp.open_file(self.log, processdata["local_file_path"], processdata["original_file_path"])
					self.config.save_task_file(task, processdata["local_file_path"], fvers.file_version(processdata["original_file_path"]))
					res = True

			self.z_processor(task, "open_post", processdata)

			if res:
				self.log.info('Load %s file has been successfull.', processdata["local_file_path"])
			else:
				self.log.info('Load file has been aborted.')
		except Exception as err:
			self.log.error('EXCEPTION', exc_info=1)
			wapp.error(utils.error_unicode(err))

		return res
Exemplo n.º 4
0
	def at_logon(self, account):
		
		try:
			self.cargo = cargo.Cargo(self.log)
			self.cargo.init_host(self.db)
		except Exception as err:
			wapp.error(utils.error_unicode(err))

		self.set_profile(account)
		self.save_config()
Exemplo n.º 5
0
	def sendReport(self):
		if self.task is None:
			self.log.error('No select task to publish')
			return False

		res = False

		opname = 'Save as New Version'
		if self.to_publish:
			opname = 'Publish'	

		self.log.info('%s started...', opname)
		self.log.info('Task: %s', self.task["path"] + self.task["name"])

		# Status
		status = None
		if self.cb_status.currentIndex() >= 0:
			status = self.statuses[self.cb_status.currentIndex()][1]
		# Text
		text = utils.string_unicode(self.te_report.toPlainText())
		# Time
		h, m = self.cb_time.currentText().split("h ")
		h = int(h) if len(h) > 0 else 0
		m = m.split("m")[0]
		m = int(m) if len(m) > 0 else 0
		work_time = h * 60 + m
		try:
			processdata = {"local_file_path": u"", "version_file_path": u"", "publish_file_path": u"", "report": {}, "attachments": {}, "links": {}}
			processdata["report"]["plain_text"] = text
			processdata["report"]["work_time"] = work_time

			for fpath, as_link in self.attachments.items():
				fpath = os.path.normpath(fpath)

				if as_link:
					processdata["links"][fpath] = []
				else:
					processdata["attachments"][fpath] = []

			version_file = None
			if self.to_publish and self.fvers.publish_path() is not None:
				version_file = self.fman.publish(self.task, processdata, status, self.ver_thumb, self.hashtags, self.cb_version.isChecked())
			else:
				version_file = self.fman.version(self.task, processdata, status, self.ver_thumb, self.hashtags)

			if version_file:
				self.log.info('%s has been successfully.', opname)
				res = True

			self.conn.refresh_task(self.task_id)
			if res: self.stop()
		except Exception as err:
			self.log.error('EXCEPTION', exc_info=1)
			wapp.error(utils.error_unicode(err))
		return res
Exemplo n.º 6
0
def send_message(message):
	response = {}
	
	try:
		server_address = ('localhost', SERVER_PORT + 1)
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

		sock.connect(server_address)
		sock.sendall(message)

		response = recvall(sock)
		sock.close()
	except Exception as err:
		wapp.error(utils.error_unicode(err), "TCP connection error")

	return response
Exemplo n.º 7
0
	def z_create(self, task):
		self.log.info('Create file started...')	
		self.log.info('Task: %s', task["path"] + task["name"])
		
		res = False
		task_paths = self.config.translate(task)
		if task["name_editable"] or len(task_paths["name_list"]) > 1:
			task_paths["name"] = wapp.string("Enter valid file name", task_paths["name_list"], task["name_editable"])

		if len(task_paths["name"]) != 0:
			try:
				self.config.set_task_filename(task["id"], task_paths["name"])
				fvers = vfile.VFile(task_paths)

				processdata = {}
				processdata["original_file_path"] = fvers.publish_path()
				processdata["local_file_path"] = fvers.local_path()

				ret = self.z_processor(task, "new_pre", processdata)
				if ret[0] is None: return False
				processdata["local_file_path"] = ret[0]["local_file_path"]
				ret = self.z_processor(task, "new_replace", processdata)

				if ret[0] is not None and not ret[1]:
					processdata["local_file_path"] = ret[0]["local_file_path"]
					if not os.path.exists(os.path.dirname(processdata["local_file_path"])):
						os.makedirs(os.path.dirname(processdata["local_file_path"]))

					if capp.save_query(self.log):
						processdata["local_file_path"] = capp.create_file(self.log, processdata["local_file_path"], processdata["original_file_path"])
						self.config.save_task_file(task, processdata["local_file_path"])
						res = True

				self.z_processor(task, "new_post", processdata)

				if res:
					self.log.info('File %s has been successfully created.', processdata["local_file_path"])
				else:
					self.log.info('File creation has been aborted.')
			except Exception as err:
				self.log.error('EXCEPTION', exc_info=1)
				wapp.error(utils.error_unicode(err))
		else:
			self.log.warning('Valid file name is required!')
		
		return res
Exemplo n.º 8
0
	def execute(self, func, args):
		if self.forbid_client: return None

		with self.lock_execute:
			res = None
			try:
				res = func(*args)
			except Exception as err:
				self.log.debug('EXCEPTION', exc_info=1)
				# Client connection expired
				if "#0" in str(err):
					self.disconnect(True)
					self.login_action.trigger()
					return None
				# Try to relogin and repeat
				try:
					if self.login(): res = func(*args)
				except Exception as err:
					self.log.debug('EXCEPTION', exc_info=1)
					wapp.error(utils.error_unicode(err))

			return res