def __init__(self, task_select=False, parent=None): super(self.__class__, self).__init__(parent=parent) self.log = clogger.CLogger().log self.conn = db.Db() self.config = config.Config() self.initUI(task_select) self.initStyle() self.clearTask()
def __init__(self, parent=None): super(self.__class__, self).__init__(parent=parent) self.conn = db.Db() self.fman = fmanager.FManager() self.config = config.Config() self.fvers = vfile.VFile(None) self.initUI() self.initStyle() self.clear()
def __init__(self, treeDisplay=False, parent=None): super(self.__class__, self).__init__(parent=parent) self.log = clogger.CLogger().log self.conn = db.Db() self.fman = fmanager.FManager() self.config = config.Config() self.__tree_display = treeDisplay self.initUI() self.initStyle()
def __call__(self): self.lock_cache = threading.RLock() self.lock_execute = threading.Lock() self.event_stop = threading.Event() self.thread = threading.Thread(target=self.thread_load, args=()) self.log = clogger.CLogger().log self.config = config.Config() self.db = database.Database() self.object = DbHelper() self.login_action = QAction(None) self.login_action.triggered.connect(self.bad_client) self.load_config() self.disconnect() self.thread.start()
def initData(self, link_mode=False, task_select=False): self.log = clogger.CLogger().log self.conn = db.Db() self.config = config.Config() self.fman = fmanager.FManager() self.__task = None self.__selected_task_id = None self.__selected_file_id = None self.__selected_file_path = None self.__selected_file_task = None self.__task_enabled = False self.__filter_mode = 0 self.__link_mode = link_mode self.__task_select = task_select
def initData(self, taskid = None, to_publish = False): self.task_id = taskid self.to_publish = to_publish self.ver_thumb = None self.attachments = {} if self.to_publish: self.setWindowTitle("Publish") self.lb_header.setText("Publish") self.pb_publish.setText("Publish") else: self.setWindowTitle("Create Report") self.lb_header.setText("Report") self.pb_publish.setText("Report") self.cb_version.setVisible(self.to_publish) self.te_report.document().setPlainText("") if not self.conn.connected: self.conn.login() if self.conn.connected: self.config = config.Config() file_name = capp.file_name(self.log) file_time = self.config.time_for_file(file_name) if file_time is not None: td = datetime.datetime.now() - file_time if td.days == 0: # 24h mins = td.seconds // 60 if mins % 5 > 0: mins = mins // 5 * 5 + 5 self.cb_time.setEditText("{0}{1}".format(str(mins // 60).zfill(2), str(mins % 60).zfill(2))) # Set file task if self.task_id is None: self.task_id = self.config.task_for_file(file_name) self.fvers = vfile.VFile(self.config.translate(self.conn.task(self.task_id))) self.shot = shot.Shot(self) self.taskSet(self.task_id) self.screenTake() self.state_load() self.log.info("Report task selected: %s", self.task_id)
def browse(): try: from tentaculo.core import config db = connect_db() conf = config.Config() task_data = cerebro.core.current_task().data() task = db.task(task_data[cerebro.aclasses.Task.DATA_ID]) task_paths = conf.translate(task) if task_paths is not None: open_path = task_paths["publish"] if len( task_paths.get("publish", "")) > 0 else task_paths.get( "version", None) opened = utils.show_dir(open_path) if not opened: cerebro_message("Task folder does not exist!") else: cerebro_message("Task translation failed!") except Exception as e: cerebro_message(repr(e))
def make_dirs(): # Config lookup keys path_list = ["version", "publish", "local"] try: from tentaculo.core import config db = connect_db() conf = config.Config() # Additional config file for browse operations browse_cfg = jsonio.read( os.path.join(utils.plugin_dir(), "browse_config.json")) ts_cfg = [] for val in browse_cfg.get("task_structure", []): try: valid = [ i for i in val.get("structure", []) if i.get("root", None) in path_list and i.get("dirs", None) is not None ] except AttributeError as e: raise AttributeError( "Invalid structure value for [{0}, {1}]. {2}".format( val.get("folder_path", "{no path}"), val.get("task_activity", "{no activity}"), repr(e))) if len(valid) > 0: ts_cfg.append({ "folder_path": val.get("folder_path", ""), "task_activity": val.get("task_activity", ""), "structure": valid }) # Count number of folders created and errors nsuccess, nerror = 0, 0 cerebro_selected = cerebro.core.selected_tasks() for cerebro_task in cerebro_selected: # Get active task data from Cerebro #cerebro_task = cerebro.core.current_task() cerebro_task_data = cerebro_task.data() # Query all child tasks prj_ids = '{' + str( cerebro_task_data[cerebro.aclasses.Task.DATA_PROJECT_ID]) + '}' query_text = "t.flags & 0000001 = 0" query_text += " and (\"taskFlags\"(t.uid, get_usid()) & 4294967296) = 0" query_text += " and (lower(t.cc_url) like lower('%{0}%'))".format( cerebro_task.parent_url() + cerebro_task.name()) tasks_list = [ t[0] for t in db.db.execute( "select * from \"search_Tasks\"(%s::bigint[], ''::text, %s::text, 1000);", prj_ids, query_text) ] # Add current task if has not children if len(tasks_list) == 0: tasks_list.append( cerebro_task_data[cerebro.aclasses.Task.DATA_ID]) tsks = db.db.tasks(tasks_list) db.update_tasks(tsks) for t in tasks_list: task = db.task(t) task_paths = conf.translate(task) if task_paths is not None: # Create config-based folder structure for p in path_list: path = task_paths.get(p, None) if path is not None and not os.path.exists(path): os.makedirs(path) nsuccess += 1 # Create additional folder structure task_parts = [ p for p in (task["path"] + task["name"]).split('/') if len(p) > 0 ] task_path = '/'.join(task_parts) # Config specifity spec = {} for val in ts_cfg: activity, folder = val["task_activity"], val[ "folder_path"] folder = folder[1:] if folder.startswith( '/') else folder # Path substitute for i, p in enumerate(task_parts): folder = folder.replace(r"$(url[{0}])".format(i), p) if (len(folder) == 0 or task_path.startswith(folder) ) and (len(activity) == 0 or task["activity"] == activity): for ts in val["structure"]: if task_paths.get(ts["root"], None) is not None: spec[len([ i for i in folder.replace( '\\', '/').split('/') if len(i) > 0 ]) + (1 if len(activity) > 0 else 0)] = ts if len(spec) > 0: ts = spec[max(spec)] for p in ts["dirs"] if isinstance( ts["dirs"], list) else [ts["dirs"]]: path = os.path.join(task_paths[ts["root"]], p) if path is not None and not os.path.exists(path): os.makedirs(path) nsuccess += 1 else: nerror += 1 if nsuccess > 0: cerebro_message( "Successfully created {0} task(s) folders. [{1} error(s)]". format(nsuccess, nerror)) else: cerebro_message( "No task(s) folders created. [{0} error(s)]".format(nerror)) except Exception as e: cerebro_message(repr(e))
def init_manager(self): self.log = clogger.CLogger().log self.config = config.Config() self.db = db.Db() self.module_cache = {}
def __init__(self, log): self.log = log self.conf = config.Config() self.clear()