def dumpNames(cls, store, os): """ Write all scripts to outstream os """ idx = 0 scripts = cls.getIndexedListing(store) counter_len = counter_length(len(scripts)) arr = [ ['idx ','name',' duration'] ] if not scripts: os(" No scripts - use the import-scripts command\n") return for pack in scripts: dur = None # pack.metadata.get('duration',None) if dur: dur = ':'.join(str(dur).split(':')[1:]) else: dur = " -" arr2 = [] arr2.append(str(idx).rjust(counter_len,'0')) arr2.append(" " * (pack.depth() * 3) + pack.name) arr2.append(" %s" % (str(dur).split('.')[0],)) #arr2.append("%i" % pack.depth()) arr.append(arr2) idx += 1 os(table_layout(arr, True, " "))
def dumpScriptNames(self, os): """ write list of scripts to logger """ store = Store.of(self) pks = store.find(buildset_script, buildset_script.buildset_id == self.id) scripts = pks.order_by(Asc(buildset_script.idx)) counter_len = counter_length(scripts.count()) arr = [ ['idx ', 'name', ' duration'] ] idx = 0 def scriptPath(_pack): """ """ res = [] cur = _pack.script while cur.parent: res.insert(0, cur.parent) cur = cur.parent return res def new(depth, pack_name, pack_idx, dur = None): if dur is None: dur = " -" arr2 = [] arr2.append(pack_idx) arr2.append(" " * (depth * 3) + pack_name) arr2.append(" %s" % (str(dur).split('.')[0],)) return arr2 last_path = [] for pack in scripts: path = scriptPath(pack) depth = len(path) if last_path != path and depth: arr.append(new(depth - 1, path[-1].name, ' '.rjust(counter_len,' '))) last_path = path dur = None # Lookup last duration of script run prevrun = store.find(build_script_status, build_script_status.buildset_script_id == pack.id, build_script_status.exit_code == 0 ).order_by(Desc(build_script_status.id)).first() dur = " -" if prevrun and prevrun.end_time and prevrun.start_time: dur = prevrun.end_time - prevrun.start_time dur = utils.sec2str(dur.seconds) arr.append(new(depth, pack.script.name, str(pack.idx).rjust(counter_len,'0'), dur)) idx += 1 os(table_layout(arr, True, " ", False))
def getIndexedListing(cls, store): """ Return a list of all scripts sorted by script grouping """ scripts = store.find(cls, cls.is_parent == 0).order_by(Asc(cls.parent_id)) counter_len = counter_length(scripts.count()) res = [] last = None for s in scripts: common, diff = s.getPathChange(last) last = s res.extend(diff) return res
def dumpNames(cls, store, os): """ Write all scripts to outstream os """ buildsets = store.find(cls).order_by(cls.id) counter_len = counter_length(buildsets.count()) arr = [ ['idx ', 'name', ' duration'] ] idx = 0 if not buildsets.count(): os(" No buildsets - use 'addscript' command to add script to a new buildset\n") return for buildset in buildsets: dur = None # buildsets[i].metadata.get('duration',None) if dur: dur = ':'.join(str(dur).split(':')[1:]) else: dur = " -" arr2 = [] arr2.append(str(idx).rjust(counter_len,'0')) arr2.append(buildset.name) arr2.append(" %s" % (str(dur).split('.')[0],)) arr.append(arr2) idx += 1 os(table_layout(arr, True, " "))