def createImageFromOrgViz(self): errors = list(); body = cherrypy.request.body.read().decode('utf-8') dotOutput = False if len(body) == 0: errors.append("Error: No content") else: opts = ModelOptions() opts.skipDrawingLegend = True opts.skipDrawingTitle = True conv = ModelToGraphVizConverter(opts=opts) mdl = parseModel(body) body = conv.getModelAsDot(mdl) f = open("/tmp/orgfile", "w") f.write(body); f.close() dotOutput = runDot("/tmp/orgfile", args.outputDirectoryLocal + "/orgviz.png") if dotOutput and len(errors) == 0: print("Dot ran okay") return { "errors": list(), "filename": args.outputDirectoryPublic + "orgviz.png" } else: return { "errors": errors, "filename": None }
def test_influence(self): opts = ModelOptions() mdl = parseModel( self.readOrgFile("tests/badOrgFiles/emptyAttributeValues.org")) conv = ModelToGraphVizConverter(opts) conv.getModelAsDot(mdl)
def test_influence(self): opts = ModelOptions() opts.vizType = "inf" mdl = parseModel( self.readOrgFile("tests/badOrgFiles/simpleInfluence.org")) conv = ModelToGraphVizConverter(opts) conv.getModelAsDot(mdl)
def test_parse_and_generate_example_org(self): opts = ModelOptions() conv = ModelToGraphVizConverter(opts) mdl = parseModel(self.readOrgFile("examples/ExampleCompany.org")) self.assertTrue(mdl is not None) dot = conv.getModelAsDot(mdl) self.assertTrue(dot is not None)
def createImageFromWebservice(self): key = cherrypy.request.body.read().decode('utf-8') logging.info("createImageFromWebservice, Key is " + key) logging.info("createImageFromWebservice, Webservice Base URL is " + args.webserviceUrl) url = args.webserviceUrl + "/" + key logging.info("createImageFromWebservice, Webservice Full URL is " + url) r = requests.get(url=url, timeout=30) logging.info("createImageFromWebservice, HTTP res is " + str(r.status_code)) errors = list() if (r.status_code == 200): orgFileFromWebservice = r.content.decode('utf-8') opts = ModelOptions() opts.skipDrawingLegend = True opts.skipDrawingTitle = True conv = ModelToGraphVizConverter(opts=opts) mdl = parseModel(orgFileFromWebservice) body = conv.getModelAsDot(mdl) dotOutput = self.orgStringToDot(body, errors) else: try: errorOutput = r.content.decode('utf-8') logging.info("createImageFromWebservicem, errorOutput is: " + str(errorOutput)) errorJson = r.json() if "errorMessage" in errorJson: errors.append(errorJson["errorMessage"]) else: errors.append("Upstream status code is: " + str(r.status_code)) except: errors.append( "Upstream status code is: " + str(r.status_code) + ", and could not determine the error message either!") dotOutput = "" return self.dotReturn(dotOutput, errors)
def main(): global args args = getArgumentParser().parse_args() logging.getLogger().setLevel(args.logging) logging.basicConfig(format="[%(levelname)s] %(message)s ") logging.debug("Teams: %s", str(args.teams)) opts = ModelOptions() opts.skipDrawingLegend = args.skipDrawingLegend opts.skipDrawingTitle = args.skipDrawingTitle opts.skipDrawingTeams = args.skipDrawingTeams opts.vizType = args.vizType opts.outputType = args.outputType opts.teams = args.teams opts.attributeMatches = args.attributeMatches opts.influence = args.influence opts.profilePictures = args.profilePictures opts.profilePictureDirectory = args.profilePictureDirectory opts.dpi = args.dpi out = None try: mdl = parseModel(getFileContents()) converter = ModelToGraphVizConverter(opts) out = converter.getModelAsDot(mdl) except Exception as exception: logging.error(str(exception)) if args.dotout: logging.warning("Outputting graph to stdout, not running Dot") print(out) elif out is not None: with tempfile.NamedTemporaryFile( delete=args.keepDotfile) as temporaryGraphvizFile: temporaryGraphvizFile.write(bytes(out, "UTF-8")) temporaryGraphvizFile.flush() logging.debug("Wrote DOT file to: %s", str(temporaryGraphvizFile.name)) outputImageFilename = args.output + "/orgviz." + args.outputType runDot(str(temporaryGraphvizFile.name), outputImageFilename, args.outputType) temporaryGraphvizFile.close( ) # will delege the org file if !args.keepDotFile
def createImageFromOrgViz(self): errors = list() body = cherrypy.request.body.read().decode('utf-8') dotOutput = False if len(body) == 0: errors.append("Error: No content") else: opts = ModelOptions() opts.skipDrawingLegend = True opts.skipDrawingTitle = True conv = ModelToGraphVizConverter(opts=opts) mdl = parseModel(body) body = conv.getModelAsDot(mdl) dotOutput = self.orgStringToDot(body, errors) return self.dotReturn(dotOutput, errors)
def test_lines_no_colon(self): mdl = parseModel( self.readOrgFile("tests/badOrgFiles/linesNoColon.org")) self.assertTrue(mdl is not None)
def test_unknown_attributes(self): mdl = parseModel( self.readOrgFile("tests/badOrgFiles/unknownAttributes.org")) self.assertTrue(mdl is not None)