Useful method for calling in main method after network and simulation are 
    generated, to handle some standard export options like -jnml, -graph etc.
163599
def check_to_generate_or_run(argv, sim):
    
    
    print_v("Checking arguments: %s to see whether anything should be run in simulation %s (net: %s)..." % 
               (argv, sim.id, sim.network))
    
    if len(argv)==1:
        print_v("No arguments found. Currently supported export formats:")
        print_v("   -nml |  -nmlh5 | -jnml | -jnmlnrn | -jnmlnetpyne | -netpyne | -pynnnrn "+\
                "| -pynnnest | -pynnbrian | -pynnneuroml | -sonata | -matrix[1-2] | -graph[1-6 n/d/f/c]")
        
    if '-pynnnest' in argv:
        generate_and_run(sim, simulator='PyNN_NEST')

    elif '-pynnnrn' in argv:
        generate_and_run(sim, simulator='PyNN_NEURON')

    elif '-pynnbrian' in argv:
        generate_and_run(sim, simulator='PyNN_Brian')

    elif '-jnml' in argv:
        generate_and_run(sim, simulator='jNeuroML')

    elif '-jnmlnrn' in argv:
        generate_and_run(sim, simulator='jNeuroML_NEURON')

    elif '-netpyne' in argv:
        generate_and_run(sim, simulator='NetPyNE')

    elif '-pynnneuroml' in argv:
        generate_and_run(sim, simulator='PyNN_NeuroML')

    elif '-sonata' in argv:
        generate_and_run(sim, simulator='sonata')
        
    elif '-nml' in argv or '-neuroml' in argv:
        
        network = load_network_json(sim.network)
        generate_neuroml2_from_network(network, validate=True)
        
    elif '-nmlh5' in argv or '-neuromlh5' in argv:
        
        network = load_network_json(sim.network)
        generate_neuroml2_from_network(network, validate=True, format='hdf5')
        
    else:
        for a in argv:
            
            if '-jnmlnetpyne' in a:
                num_processors = 1
                if len(a)>len('-jnmlnetpyne'):
                    num_processors = int(a[12:])
                generate_and_run(sim, simulator='jNeuroML_NetPyNE',num_processors=num_processors)
            elif 'graph' in a: # e.g. -graph3c
                generate_and_run(sim, simulator=a[1:]) # Will not "run" obviously...
            elif 'matrix' in a: # e.g. -matrix2
                generate_and_run(sim, simulator=a[1:])
446149
private void process() {
    if (hasExternsRoot()) {
      sourceKind = SourceKind.EXTERN;
      NodeTraversal.traverse(compiler, externsRoot, new BuildGlobalNamespace());
    }
    sourceKind = SourceKind.CODE;

    NodeTraversal.traverse(compiler, root, new BuildGlobalNamespace());
    generated = true;
    externsScope = null;
  }
1178837
public static void main(String[] args) throws IOException {
		ExampleHelpers.configureLogging();
		EntityStatisticsProcessor.printDocumentation();

		EntityStatisticsProcessor entityStatisticsProcessor = new EntityStatisticsProcessor();
		ExampleHelpers
				.processEntitiesFromWikidataDump(entityStatisticsProcessor);
		entityStatisticsProcessor.writeFinalResults();
	}
1354306
public static void main(String[] args) throws Exception {
    int exitCode = ToolRunner.run(new gen_flatfile(), args);
    System.exit(exitCode);
  }
841434
public static void main(String[] args) throws IOException, InterruptedException {
    // Register the view. It is imperative that this step exists,
    // otherwise recorded metrics will be dropped and never exported.
    View view =
        View.create(
            Name.create("task_latency_distribution"),
            "The distribution of the task latencies.",
            LATENCY_MS,
            Aggregation.Distribution.create(LATENCY_BOUNDARIES),
            Collections.<TagKey>emptyList());

    // Create the view manager
    ViewManager viewManager = Stats.getViewManager();

    // Then finally register the views
    viewManager.registerView(view);

    // [START setup_exporter]
    // Enable OpenCensus exporters to export metrics to Stackdriver Monitoring.
    // Exporters use Application Default Credentials to authenticate.
    // See https://developers.google.com/identity/protocols/application-default-credentials
    // for more details.
    StackdriverStatsExporter.createAndRegister();
    // [END setup_exporter]

    // Record 100 fake latency values between 0 and 5 seconds.
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      long ms = (long) (TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS) * rand.nextDouble());
      System.out.println(String.format("Latency %d: %d", i, ms));
      STATS_RECORDER.newMeasureMap().put(LATENCY_MS, ms).record();
    }

    // The default export interval is 60 seconds. The thread with the StackdriverStatsExporter must
    // live for at least the interval past any metrics that must be collected, or some risk being
    // lost if they are recorded after the last export.

    System.out.println(
        String.format(
            "Sleeping %d seconds before shutdown to ensure all records are flushed.",
            EXPORT_INTERVAL));
    Thread.sleep(TimeUnit.MILLISECONDS.convert(EXPORT_INTERVAL, TimeUnit.SECONDS));
  }
673352
public static void main(String[] args) {

    	PluginUtilityConsole console = new PluginUtilityConsole(System.console(), System.out,System.err);
    
        // This is only needed for the GenerateFromServerPluginsTask so comment out for now.
        //IGeneratePluginConfigMBeanConnection pluginUtilityMBeanConn = new GeneratePluginConfigMBeanConnection(System.out, System.err, fileUtil);

        WebServerPluginUtility util = new WebServerPluginUtility(console);

        // Initially we are only going to deliver the function for MergePluginFilesTask
        //util.registerTask(new GenerateFromServerPluginTask(SCRIPT_NAME, fileUtil, pluginUtilityMBeanConn));
        util.registerTask(new MergePluginFilesTask(SCRIPT_NAME));
        util.registerTask(new GeneratePluginTask(SCRIPT_NAME,console));
       // util.registerTask(new DynamicRoutingPluginTask(SCRIPT_NAME, fileUtil));

        int rc = util.runProgram(args);

        System.exit(rc);
    }
400903
private void deployNetwork(final NetworkContext context, final Handler<AsyncResult<NetworkContext>> doneHandler) {
    log.debug(String.format("%s - Deploying network", NetworkManager.this));
    final CountingCompletionHandler<Void> complete = new CountingCompletionHandler<Void>(context.components().size());
    complete.setHandler(new Handler<AsyncResult<Void>>() {
      @Override
      public void handle(AsyncResult<Void> result) {
        if (result.failed()) {
          new DefaultFutureResult<NetworkContext>(result.cause()).setHandler(doneHandler);
        } else {
          new DefaultFutureResult<NetworkContext>(context).setHandler(doneHandler);
        }
      }
    });
    deployComponents(context.components(), complete);
  }
173559
@Benchmark
  public void createCallLatency(OutputStreamWriter results) throws Exception {
    results.write(new MeanDevAccumulator().addResults(new TimedCallable() {
      private int i = 0;

      @Override
      public void callTimed() throws Exception {
        proxyTClientProxyProtocol.create(new CreateRequest(metaInfo, ROOT + "newfilea-" + i++,
            metaInfo.getOrigCaller().getUserName(), FsPermission.getDefault(), true, true,
            (short) 1, 1024));
      }
    }, WARMUP_SAMPLES, MEASURED_SAMPLES).report());
    results.write("  |  ");

    results.write(new MeanDevAccumulator().addResults(new TimedCallable() {
      private int i = 0;

      @Override
      public void callTimed() throws Exception {
        proxyClientProxyProtocol.create(new CreateRequest(metaInfo, ROOT + "newfileb-" + i++,
            metaInfo.getOrigCaller().getUserName(), FsPermission.getDefault(), true, true,
            (short) 1, 1024));
      }
    }, WARMUP_SAMPLES, MEASURED_SAMPLES).report());
    results.write("  |  ");

    results.write(new MeanDevAccumulator().addResults(new TimedCallable() {
      private int i = 0;

      @Override
      public void callTimed() throws Exception {
        directClientProxyProtocol.create(new CreateRequest(metaInfo, ROOT + "newfilec-" + i++,
            metaInfo.getOrigCaller().getUserName(), FsPermission.getDefault(), true, true,
            (short) 1, 1024));
      }
    }, WARMUP_SAMPLES, MEASURED_SAMPLES).report());
    results.write("  |  ");

    results.write(new MeanDevAccumulator().addResults(new TimedCallable() {
      private int i = 0;

      @Override
      public void callTimed() throws Exception {
        directClientProtocol.create(ROOT + "newfiled-" + i++, FsPermission.getDefault(),
            metaInfo.getOrigCaller().getUserName(), true, true, (short) 1, 1024);
      }
    }, WARMUP_SAMPLES, MEASURED_SAMPLES).report());
  }
109806
public static void main(String args[])
    {
        Main main = new Main();
        args = main.processOptions(args);
        if (args == null) {
            if (main.printHelp) {
                System.out.println(ToolErrorReporter.getMessage(
                    "msg.jsc.usage", Main.class.getName()));
                System.exit(0);
            }
            System.exit(1);
        }
        if (!main.reporter.hasReportedError()) {
            main.processSource(args);
        }
    }
1141270
private void doExportToWave()
	{
		doStopPlaying();
		
		if (currentContainer==null)
	    {
	    	JOptionPane.showMessageDialog(this, "You need to load a file first!", "Ups!", JOptionPane.ERROR_MESSAGE);
	    }
	    else
	    {
	    	do
		    {
				String fileName = Helpers.createLocalFileStringFromURL(currentContainer.getFileURL(), true);
				fileName = fileName.substring(fileName.lastIndexOf(File.separatorChar)+1);
				String exportToWav = exportPath + File.separatorChar + fileName + ".WAV";
				FileChooserResult selectedFile = Helpers.selectFileNameFor(this, exportToWav, "Export to wave", fileFilterExport, 1, false, false);
				if (selectedFile!=null)
				{
					File f = selectedFile.getSelectedFile();
				    if (f!=null)
				    {
				    	if (f.exists())
				    	{
				    		int result = JOptionPane.showConfirmDialog(this, "File already exists! Overwrite?", "Overwrite confirmation", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
				    		if (result==JOptionPane.CANCEL_OPTION) return;
				    		if (result==JOptionPane.NO_OPTION) continue; // Reselect
				    		boolean ok = f.delete();
				    		if (!ok)
				    		{
		        		    	JOptionPane.showMessageDialog(MainForm.this, "Overwrite failed. Is file write protected or in use?", "Failed", JOptionPane.ERROR_MESSAGE);
		        		    	return;
				    		}
				    	}
				    	// get Export Type from selected filechooser index (find the index ;) )
				    	String modFileName = f.getAbsolutePath();
				    	int i = modFileName.lastIndexOf(File.separatorChar);
				    	exportPath = modFileName.substring(0, i);
			    		int result = JOptionPane.showConfirmDialog(this, "Continue playback while exporting?", "Playback?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

			    		Mixer mixer = createNewMixer();
				    	mixer.setPlayDuringExport(result==JOptionPane.YES_OPTION);
				    	mixer.setExportFile(f);
				    	playerThread = new PlayThread(mixer, this);
				    	playerThread.start();
			    		
				    	inExportMode = true; // Signal, that we are exporting right now...
				    }
				}
		    	return;
		    }
		    while (true);
	    }
	}
132253
static void export(String path, DbConn cnx) throws JqmXmlException
    {
        if (cnx == null)
        {
            throw new IllegalArgumentException("database connection cannot be null");
        }
        export(path, JobDef.select(cnx, "jd_select_all"), cnx);
    }
772280
public void prepareServer() {
        try {
            server = new Server(0);
            jettyHandler = new AbstractHandler() {
                public void handle(String target, Request req, HttpServletRequest request,
                                   HttpServletResponse response) throws IOException, ServletException {
                    response.setContentType("text/plain");

                    String[] operands = request.getRequestURI().split("/");

                    String name = "";
                    String command = "";
                    String value = "";

                    //operands[0] = "", request starts with a "/"

                    if (operands.length >= 2) {
                        name = operands[1];
                    }

                    if (operands.length >= 3) {
                        command = operands[2];
                    }

                    if (operands.length >= 4) {
                        value = operands[3];
                    }

                    if (command.equals("report")) { //report a number of lines written
                        response.getWriter().write(makeReport(name, value));
                    } else if (command.equals("request") && value.equals("block")) { //request a new block of work
                        response.getWriter().write(requestBlock(name));
                    } else if (command.equals("request") && value.equals("name")) { //request a new name to report with
                        response.getWriter().write(requestName());
                    } else { //non recognized response
                        response.getWriter().write("exit");
                    }

                    ((Request) request).setHandled(true);
                }
            };

            server.setHandler(jettyHandler);

            // Select any available port
            server.start();
            Connector[] connectors = server.getConnectors();
            NetworkConnector nc = (NetworkConnector) connectors[0];
            listeningPort = nc.getLocalPort();
            hostName = InetAddress.getLocalHost().getHostName();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
848565
public EndpointBuilder<T> export(Class<?>... additional) {
		this.additionalInterfaces.addAll(Arrays.asList(additional));
		return this;
	}
518772
def main():
  
  engine.Network.registerPyRegion(__name__,
                                    SerializationTestPyRegion.__name__)

  try:
    _runTest()
  finally:
    engine.Network.unregisterPyRegion(SerializationTestPyRegion.__name__)
470816
public static void main(String[] args) throws Exception {
    AlluxioFramework framework = new AlluxioFramework();
    JCommander jc = new JCommander(framework);
    try {
      jc.parse(args);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      jc.usage();
      System.exit(1);
    }
    framework.run();
  }
191688
public static void main(String[] args) throws IOException, InterruptedException {
    // Add final keyword to pass checkStyle.
    final int serverPort = getPortOrDefaultFromArgs(args, 0, 50051);
    final String cloudProjectId = getStringOrDefaultFromArgs(args, 1, null);
    final int zPagePort = getPortOrDefaultFromArgs(args, 2, 3000);
    final int prometheusPort = getPortOrDefaultFromArgs(args, 3, 9090);

    // Registers all RPC views. For demonstration all views are registered. You may want to
    // start with registering basic views and register other views as needed for your application.
    RpcViews.registerAllViews();

    // Registers logging trace exporter.
    LoggingTraceExporter.register();

    // Starts a HTTP server and registers all Zpages to it.
    ZPageHandlers.startHttpServerAndRegisterAll(zPagePort);
    logger.info("ZPages server starts at localhost:" + zPagePort);

    // Registers Stackdriver exporters.
    if (cloudProjectId != null) {
      StackdriverTraceExporter.createAndRegister(
          StackdriverTraceConfiguration.builder().setProjectId(cloudProjectId).build());
      StackdriverStatsExporter.createAndRegister(
          StackdriverStatsConfiguration.builder()
              .setProjectId(cloudProjectId)
              .setExportInterval(Duration.create(60, 0))
              .build());
    }

    // Register Prometheus exporters and export metrics to a Prometheus HTTPServer.
    PrometheusStatsCollector.createAndRegister();
    HTTPServer prometheusServer = new HTTPServer(prometheusPort, true);

    // Start the RPC server. You shouldn't see any output from gRPC before this.
    logger.info("gRPC starting.");
    final HelloWorldServer server = new HelloWorldServer(serverPort);
    server.start();
    server.blockUntilShutdown();
  }
326313
static void export(String path, List<Queue> queueList, DbConn cnx) throws JqmXmlException
    {
        // Argument tests
        if (path == null)
        {
            throw new IllegalArgumentException("file path cannot be null");
        }
        if (queueList == null || queueList.isEmpty())
        {
            throw new IllegalArgumentException("queue list cannot be null or empty");
        }
        if (cnx == null)
        {
            throw new IllegalArgumentException("database connection cannot be null");
        }

        // Create XML document
        Element root = new Element("jqm");
        Document document = new Document(root);
        Element queues = new Element("queues");
        root.addContent(queues);

        for (Queue q : queueList)
        {
            Element queue = getQueueElement(q, cnx);
            queues.addContent(queue);
        }

        // Done: save the file
        try
        {
            XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
            out.output(document, new FileOutputStream(path));
        }
        catch (java.io.IOException e)
        {
            throw new JqmXmlException("Coul npot save the XML file", e);
        }
    }