Пример #1
0
    def __popupAt(self, pos):
        index = self.tableWidget.indexAt(pos)
        if not index.isValid(): return

        if self.__selected_task_id is not None:
            task = self.conn.task(self.__selected_task_id)
            if task is not None:
                menu_options = [
                    "Start working on this file",
                    "Open without Starting the Task", None, "Link", "Embed",
                    None, "Show in Explorer...", "Copy file path to Clipboard"
                ]
                extra = {"file_path": self.__selected_file_path}
                res = wapp.menu(task,
                                self.tableWidget.viewport().mapToGlobal(pos),
                                menu_options, "menu_file", extra)

                if res is not None and res in menu_options:
                    if res == menu_options[0]:
                        self.startTask()
                    elif res == menu_options[1]:
                        self.openSelectedFile()
                    elif res == menu_options[3]:
                        self.importSelectedFile(True)
                    elif res == menu_options[4]:
                        self.importSelectedFile(False)
                    elif res == menu_options[6]:
                        if self.__selected_file_path is not None:
                            if not utils.show_dir(self.__selected_file_path):
                                wapp.error("File does not exist: {}".format(
                                    self.__selected_file_path))
                    elif res == menu_options[7]:
                        if self.__selected_file_path is not None:
                            capp.copyToClipboard(self.__selected_file_path)
Пример #2
0
def open_folder():
    from tentaculo.core import fmanager
    from tentaculo.gui import wapp
    man = fmanager.FManager()
    if not man.open_task_folder():
        wapp.error(
            "Cannot determine task ID. Please start working on a task to create local version."
        )
Пример #3
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)))
Пример #4
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
Пример #5
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
Пример #6
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()
Пример #7
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
Пример #8
0
def version_silent():
    from tentaculo.core import fmanager
    from tentaculo.gui import wapp
    man = fmanager.FManager()
    res = man.version_silent()
    if res is None:
        wapp.error(
            "Cannot determine task ID. Please start working on a task to create local version."
        )
    else:
        wapp.info("Current file is saved as new version: {}".format(res))
Пример #9
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
Пример #10
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
Пример #11
0
	def login(self):

		if self.connected: return True

		self.log.info('Auto-login started...')
		
		acc = self.account()
		
		connect_url = acc.get('url', '')
		self.log.info('Connection URL: %s', connect_url if len(connect_url) else 'default')
		try:
			err = 3
			if not self.forbid_client:
				menu.start_splash()
				err = self.db.connect_from_cerebro_client()
				if err == 0:
					user_id = self.db.current_user_id()
					if acc.get('id') and acc.get('id') != user_id:
						err = 1
					else:
						acc['id'] = user_id
					
			if err != 0:
				if self.cfg.get('autologin') == True and acc.get('psw'):
					menu.start_splash()
					self.db.connect(acc.get('login'), acc.get('psw'), acc.get('url', ''))
				else:
					acc = self.login_to(acc)
					if not acc:
						return False

		except Exception as err:
			self.log.debug('EXCEPTION', exc_info=1)
			wapp.error('Connection failed. Please check your login and password.\nConnect URL: {0}'.format(connect_url if len(connect_url) else 'default'))
			acc = self.login_to(acc)
			if not acc:
				return False

		self.connected = True
		self.forbid_client = False
		if not self.is_current_account(acc):
			self.at_logon(acc)
		
		self.log.info('Auto-login %s has been successfully.', self.user_name)
		return True
Пример #12
0
	def login_as(self, acc):
		connect_url = ''
		try:
			if not self.is_current_account(acc):
				self.disconnect()
				connect_url = acc.get('url', '')
				#address = acc.get('address')
				#dbaddress = address.split(':')
				#self.db = database.Database(dbaddress[0], dbaddress[1])

			self.db.connect(acc.get('login'), acc.get('psw'), acc.get('url', ''))
			menu.start_splash()
		except Exception as err:
			self.log.debug('EXCEPTION', exc_info=1)
			wapp.error('Connection failed. Please check your login and password.\nConnect URL: {0}'.format(connect_url if len(connect_url) else 'default'))
			return False
			
		return True
Пример #13
0
    def __popupAt(self, pos):
        index = self.tableWidget.indexAt(pos)
        if not index.isValid(): return

        taskPath = None
        taskCerebro = None
        if self.task_id is not None:
            task = self.conn.task(self.task_id)
            if task is not None:
                task_paths = self.config.translate(task)
                taskCerebro = task["path"] + task["name"]
                taskPath = task_paths["publish"] if len(
                    task_paths.get("publish", "")) > 0 else task_paths.get(
                        "version", None)

                menu_options = [
                    "Open in Cerebro...", None, "Copy local path to Clipboard",
                    "Show in Explorer..."
                ]
                res = wapp.menu(task,
                                self.tableWidget.viewport().mapToGlobal(pos),
                                menu_options, "menu_task")
                if res is not None:
                    if res in menu_options and len(taskPath) and len(
                            taskCerebro):
                        if res == menu_options[0]:
                            webbrowser.open(
                                utils.string_unicode(
                                    r"cerebro://{0}?tid={1}").format(
                                        taskCerebro, self.task_id))
                        elif res == menu_options[2]:
                            capp.copyToClipboard(taskPath)
                        elif res == menu_options[3]:
                            if not utils.show_dir(taskPath):
                                wapp.error(
                                    "Directory does not exist: {}".format(
                                        taskPath))
                    else:
                        # Hook used - update task data
                        self.refresh.emit()
Пример #14
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