def get_package_path(self, name): #return os.getcwd () cmd = 'cmt -use=' + name + ' run pwd' status, output = getstatusoutput(cmd) if status != 0: print output sys.exit(-1) lines = output.split('\n') for line in lines: if line[0] != '#' and line[:5] != "#CMT>": print line return line
def get_current_package(self): cmd = 'cmt show macro package' status, output = getstatusoutput(cmd) if status != 0: print output sys.exit(-1) lines = output.split('\n') for line in lines: if line[0] != '#': start = line.find("'") end = line[start + 1:len(line)].find("'") return line[start + 1:start + end + 1]
def instanciate_packages(self, filename=None): # We create the schedule of the work units print '# First, we initialize the DAG by parsing "cmt show uses"' if filename is None: cmd = 'cmt show uses' else: cmd = 'cat ' + filename status, output = getstatusoutput(cmd) if status != 0: print output sys.exit(-1) self.get_uses(output) self.get_paths(output)
def check_cycles(self): cmd = 'cmt -private show cycles' status, output = getstatusoutput(cmd) if status != 0: print output sys.exit(-1) lines = output.split('\n') cycles = list() for line in lines: if line != '' and line[0] != '#': cycles.append(line.split()) cercles = list() for cycle in cycles: cycleInProject = True for package in cycle: if not self.packages.has_key(package): cycleInProject = False if cycleInProject: cercles.append(cycle) if len(cercles): if not self.ignore_cycles: print "# Error: cycles found, not possible to execute broadcast with threads. Please correct the following cycles:" for cycle in cercles: loop = "" for package in cycle: loop = loop + package + ' -> ' print loop + '...' sys.exit(-1) else: print "# Warning: There are cycles and you have selected the automatic suppress cycles mode" for cycle in cercles: loop = "" for package in cycle: loop = loop + package + ' -> ' if cycle[0] in self.packages[cycle[len(cycle) - 1]]['uses']: print '## In cycle: ' + loop + '..., we suppress the dependency ' + cycle[ len(cycle) - 1] + '->' + cycle[0] self.packages[cycle[len(cycle) - 1]]['uses'].remove( cycle[0])
def get_current_project(self): cmd = 'cmt show projects | grep current' status, output = getstatusoutput(cmd) if status != 0: print output sys.exit(-1) lines = output.split('\n') for line in lines: if line != '' and line[0] != '#': item = line.split(' ') self.current_project['name'] = item[0] self.current_project['version'] = item[1] self.current_project['path'] = item[3][:-1] version = self.current_project[ 'path'][len(self.current_project['path']) - len(self.current_project['version']):] if self.current_project['version'] and self.current_project[ 'version'] == version: self.current_project['path'] = self.current_project[ 'path'][:-len(self.current_project['version'])] self.current_project['path'] = os.path.normpath( self.current_project['path']) return