Monitor without parser that doesn't trigger a test
198330
static public String createMonitor(String monitorUrl, TECore core) {
        return createMonitor(monitorUrl, null, "", core);
    }
523421
def _run(command, quiet=False, timeout=None):
    """"""
    try:
        with _spawn(command, quiet, timeout) as child:
            command_output = child.read().strip().replace("\r\n", "\n")
    except pexpect.TIMEOUT:
        logger.info(f"command {command} timed out")
        raise Error()

    return command_output
63841
def main(args, prog_name):
  """"""
  # get options and arguments
  ui = getUI(prog_name, args)

  if ui.optionIsSet("test"):
    # just run unit tests
    unittest.main(argv=[sys.argv[0]])
  elif ui.optionIsSet("help"):
    # just show help
    ui.usage()
  else:
    verbose = (ui.optionIsSet("verbose") is True) or DEFAULT_VERBOSITY

    # get output handle
    out_fh = sys.stdout
    if ui.optionIsSet("output"):
      out_fh = open(ui.getValue("output"), "w")

    # get window size...
    window_size = DEFAULT_WINDOW_SIZE
    if ui.optionIsSet("window"):
      window_size = ui.getValue("window")

    # get the window anchoring location
    windowCentre = DEFAULT_WINDOW_CENTRE
    if ui.optionIsSet("centre"):
      windowCentre = ui.getValue("centre")
      if windowCentre not in WINDOW_CENTRE_OPTIONS:
        sys.stderr.write("un-recognised window anchor position: " +
                         str(windowCentre) + "\n")
        sys.exit(1)

    args = ui.getAllArguments()
    assert(len(args) == 3 or len(args) == 4)
    region_fn = ui.getArgument(0)
    ga_path = ui.getArgument(1)
    index_fn = None
    if len(args) == 3:
      spec = ui.getArgument(2)
    else:
      index_fn = ui.getArgument(2)
      spec = ui.getArgument(3)

    extensions = (ui.getValue("extensions").strip().split(",") if
                  ui.optionIsSet("extensions") else None)
    index_extensions = (ui.getValue("index-extensions").strip().split(",") if
                        ui.optionIsSet("index-extensions") else None)
    fail_no_index = ui.optionIsSet("fail-no-index")
    mi_seqs = (MissingSequenceHandler[ui.getValue("missing")]
               if ui.optionIsSet("missing")
               else MissingSequenceHandler.TREAT_AS_ALL_GAPS)
    species = ([x.strip() for x in ui.getValue("species").split(",")] if
               ui.optionIsSet("species") else None)

    # build the genome alignment
    alig = (load_just_in_time_genome_alignment(ga_path, spec, extensions,
                                               index_extensions, fail_no_index,
                                               verbose)
            if os.path.isdir(ga_path)
            else build_genome_alignment_from_file(ga_path, spec, index_fn,
                                                  verbose))

    # get the profile and write it to the output stream
    profile = processBED(open(region_fn), alig, window_size, CENTRE,
                         mi_seqs, species, verbose)
    out_fh.write("\n\n" + ", ".join(str(x) for x in profile) + "\n")
1196888
def main(arguments=None):
    
    # setup the command-line util settings
    su = tools(
        arguments=arguments,
        docString=__doc__,
        logLevel="WARNING",
        options_first=False,
        projectName="transientNamer"
    )
    arguments, settings, log, dbConn = su.setup()

    # tab completion for raw_input
    readline.set_completer_delims(' \t\n;')
    readline.parse_and_bind("tab: complete")
    readline.set_completer(tab_complete)

    # unpack remaining cl arguments using `exec` to setup the variable names
    # automatically
    for arg, val in arguments.iteritems():
        if arg[0] == "-":
            varname = arg.replace("-", "") + "Flag"
        else:
            varname = arg.replace("<", "").replace(">", "")
        if isinstance(val, str) or isinstance(val, unicode):
            exec(varname + " = '%s'" % (val,))
        else:
            exec(varname + " = %s" % (val,))
        if arg == "--dbConn":
            dbConn = val
        log.debug('%s = %s' % (varname, val,))

    ## START LOGGING ##
    startTime = times.get_now_sql_datetime()
    log.info(
        '--- STARTING TO RUN THE cl_utils.py AT %s' %
        (startTime,))

    if search or new or cone:
        if ra:
            tns = transientNamer.search(
                log=log,
                ra=ra,
                dec=dec,
                radiusArcsec=arcsecRadius,
                comments=withCommentsFlag
            )
        if name:
            tns = transientNamer.search(
                log=log,
                name=name,
                comments=withCommentsFlag
            )
        if discInLastDays:
            tns = transientNamer.search(
                log=log,
                discInLastDays=discInLastDays,
                comments=withCommentsFlag
            )

        # Recursively create missing directories
        if outputFlag and not os.path.exists(outputFlag):
            os.makedirs(outputFlag)

        if tableNamePrefix:
            sources, phot, spec, files = tns.mysql(
                tableNamePrefix=tableNamePrefix, dirPath=outputFlag)
            numSources = len(sources.split("\n")) - 1
        elif not render or render == "table":
            sources, phot, spec, files = tns.table(dirPath=outputFlag)
            numSources = len(sources.split("\n")) - 4
        elif render == "csv":
            sources, phot, spec, files = tns.csv(dirPath=outputFlag)
            numSources = len(sources.split("\n")) - 1
        elif render == "json":
            sources, phot, spec, files = tns.json(dirPath=outputFlag)
            numSources = len(sources.split("{")) - 1
        elif render == "yaml":
            sources, phot, spec, files = tns.yaml(dirPath=outputFlag)
            numSources = len(sources.split("\n-"))
        elif render == "markdown":
            sources, phot, spec, files = tns.markdown(dirPath=outputFlag)
            numSources = len(sources.split("\n")) - 2

        if numSources == 1:
            print "%(numSources)s transient found" % locals()
        elif numSources > 1:
            print "%(numSources)s transients found" % locals()

        if not outputFlag:
            print "\n# Matched Transients"
            print sources
            print "\n# Transient Photometry"
            print phot
            print "\n# Transient Spectra"
            print spec
            print "\n# Transient Supplementary Files"
            print files
            print "\n# Original TNS Search URL"
            print tns.url
        # CALL FUNCTIONS/OBJECTS

    if "dbConn" in locals() and dbConn:
        dbConn.commit()
        dbConn.close()
    ## FINISH LOGGING ##
    endTime = times.get_now_sql_datetime()
    runningTime = times.calculate_time_difference(startTime, endTime)
    log.info('-- FINISHED ATTEMPT TO RUN THE cl_utils.py AT %s (RUNTIME: %s) --' %
             (endTime, runningTime, ))

    return
1071062
def monitor(name):
    '''
    
    '''
    ret = {'result': None,
           'name': name,
           'comment': '',
           'changes': {}
           }
    result = __salt__['monit.summary'](name)

    try:
        for key, value in result.items():
            if 'Running' in value[name]:
                ret['comment'] = ('{0} is being being monitored.').format(name)
                ret['result'] = True
            else:
                if __opts__['test']:
                    ret['comment'] = 'Service {0} is set to be monitored.'.format(name)
                    ret['result'] = None
                    return ret
                __salt__['monit.monitor'](name)
                ret['comment'] = ('{0} started to be monitored.').format(name)
                ret['changes'][name] = 'Running'
                ret['result'] = True
                break
    except KeyError:
        ret['comment'] = ('{0} not found in configuration.').format(name)
        ret['result'] = False

    return ret
1121341
function() {
      var t = this;

      // Test an app directory to see if it's a monitor app
      var testAppDir = function(dir) {

        // Load the package.json if it exists (and remove relative refs)
        var pkg;
        dir = Path.resolve(dir);
        try {
          pkg = JSON.parse(FS.readFileSync(dir + '/package.json', 'utf-8'));
        } catch (e) {
          // Report an error if the package.json has a parse problem.  This is
          // good during app development to show why we didn't discover the app.
          if (e.code !== "ENOENT") {
             console.error("Problem parsing " + dir + "/package.json");
          }
          return false;
        }

        // Is this a monitor-dashboard app?
        var isMonitorApp = pkg.dependencies && _.find(_.keys(pkg.dependencies), function(keyword){ return keyword === 'monitor-dashboard'; });
        if (!isMonitorApp) {
          return false;
        }

        // This is a monitor-dashboard app.
        return t.loadApp(dir, pkg);
      };

      // Process all apps under a node_modules directory
      var loadNodeModulesDir = function(dir) {

        // Return if the node_modules directory doesn't exist.
        try {
          FS.statSync(dir);
        } catch (e) {return;}

        // Check each direcory for a monitor-dashboard app
        FS.readdirSync(dir).forEach(function(moduleName) {

          // See if this is a monitor app, and load if it is
          // then load sub-modules
          var moduleDir = dir + '/' + moduleName;
          if (testAppDir(moduleDir) || moduleName === 'monitor') {

            // If it is a monitor-app, process any sub node_modules
            loadNodeModulesDir(moduleDir + '/node_modules');
          }
        });
      };

      // Test this app as a monitor app
      t.thisAppName = testAppDir('.');

      // Process all possible node_module directories in the require path.
      process.mainModule.paths.forEach(loadNodeModulesDir);

    }
935325
def run_with_fixture(monitor, *flags, &block)
      fixture do |f|
        run(monitor, f, *flags, &block)
      end
    end
41287
function() {
      var t = this;

      // Append a monitor picker
      t.monitorPicker = new UI.MonitorPicker({
        el: t.$el,
        hideProbe: true,  // Set false for the user to select the probe class
        model: t.options.monitor
      });
      t.monitorPicker.render();
    }
1189318
public static base_response disable(nitro_service client, String monitorname) throws Exception {
		lbmonitor disableresource = new lbmonitor();
		disableresource.monitorname = monitorname;
		return disableresource.perform_operation(client,"disable");
	}
7277
def monitor(self, target):
        
        if 'monitor-notify' in self._capabilities and not self.is_monitoring(target):
            yield from self.rawmsg('MONITOR', '+', target)
            self._monitoring.add(target)
            return True
        else:
            return False
973976
def main(raw_args=None):
    

    if raw_args is None:
        raw_args = sys.argv[1:]

    parser = build_parser()
    args = parser.parse_args(raw_args)

    if args.firmware_image is None and args.gdb is None:
        print("You must specify either a firmware image or attach a debugger with --gdb <PORT>")
        return 1

    test_args = ['qemu-system-gnuarmeclipse', '-verbose', '-verbose', '-board', 'STM32F0-Discovery',
                 '-nographic', '-monitor', 'null', '-serial', 'null', '--semihosting-config',
                 'enable=on,target=native', '-d', 'unimp,guest_errors']

    if args.firmware_image:
        test_args += ['-image', args.firmware_image]

    if args.gdb:
        test_args += ['--gdb', 'tcp::%d' % args.gdb]

    proc = subprocess.Popen(test_args, stdout=sys.stdout, stderr=sys.stderr)

    try:
        proc.communicate()
    except KeyboardInterrupt:
        proc.terminate()

    return 0
785840
def p_command(p):
    """"""
    #print("COMMAND:", p[1], p[2], p[3])
    tests = p[2].get('tests')
    block = None
    if p[3] != ';': block = p[3]
    handler = sifter.handler.get('command', p[1])
    if handler is None:
        print("No handler registered for command '%s' on line %d" %
            (p[1], p.lineno(1)))
        raise SyntaxError
    p[0] = handler(arguments=p[2]['args'], tests=tests, block=block)
278437
def get_monitor(host=PINBA_SERVER, port=PINBA_PORT, *args, **kwargs):
    
    kwargs['servername'] = PINBA_SERVER_NAME
    kwargs['scriptname'] = __file__

    for item in inspect.stack():
        if item and __file__ not in item:
            kwargs['scriptname'] = item[3]
            break

    return ScriptMonitor((host, port), *args, **kwargs)
981981
def main():
    """"""
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--url', help='QSUSB URL [http://127.0.0.1:2020]',
                        default='http://127.0.0.1:2020')
    parser.add_argument('--file', help='a test file from /&devices')
    parser.add_argument('--test_ids', help='List of test IDs',
                        default='@0c2700,@0ac2f0')
    args = parser.parse_args()

    if args.file:
        with open(args.file) as data_file:
            data = json.load(data_file)
        qsusb = pyqwikswitch.QSDevices(
            print_devices_change_callback, print_devices_change_callback)
        print_bad_data(data)
        qsusb.set_qs_values(data)
        return

    print('Execute a basic test on server: {}\n'.format(args.url))

    def qs_to_value(key, new):
        print(" --> New value: {}={}".format(key, new))

    qsusb = QSUsb(args.url, 1, qs_to_value)
    print('Version: ' + qsusb.version())
    qsusb.set_qs_values()

    qsusb.listen(print_item_callback, timeout=5)
    print("Started listening")
    try:
        # Do some test while listening
        if args.test_ids and len(args.test_ids) > 0:
            test_devices_set(qsusb.devices, args.test_ids.split(','))

        print("\n\nListening for 60 seconds (test buttons now)\n")
        sleep(60)
    except KeyboardInterrupt:
        pass
    finally:
        qsusb.stop()  # Close all threads
        print("Stopped listening")
791406
def monitor(self, name, ip, port, quorum):
        """"""
        fut = self.execute(b'MONITOR', name, ip, port, quorum)
        return wait_ok(fut)
595343
def monitor(self):
        """"""
        if self._monitor_api is None:
            self._monitor_api = self.get_monitor_api()
        return self._monitor_api
312518
def main(argv):
    
    input_file = ""
    output_file = ""
    monitor = None
    formula = None
    trace = None
    iformula = None
    itrace = None
    isys = None
    online = False
    fuzzer = False
    l2m = False
    debug = False
    rounds = 1
    server_port = 8080
    webservice = False

    help_str_extended = "fodtlmon V 0.1 .\n" + \
                        "For more information see fodtlmon home page\n Usage : mon.py [OPTIONS] formula trace" + \
                        "\n  -h \t--help          " + "\t display this help and exit" + \
                        "\n  -i \t--input= [file] " + "\t the input file" + \
                        "\n  -o \t--output= [path]" + "\t the output file" + \
                        "\n  -f \t--formula       " + "\t the formula" + \
                        "\n     \t--iformula      " + "\t path to file that contains the formula" + \
                        "\n  -t \t--trace         " + "\t the trace" + \
                        "\n     \t--itrace        " + "\t path to file that contains the trace" + \
                        "\n  -1 \t--ltl           " + "\t use LTL monitor" + \
                        "\n     \t--l2m           " + "\t call ltl2mon also" + \
                        "\n  -2 \t--fotl          " + "\t use FOTL monitor" + \
                        "\n  -3 \t--dtl           " + "\t use DTL monitor" + \
                        "\n  -4 \t--fodtl         " + "\t use FODTL monitor" + \
                        "\n     \t--sys= [file]   " + "\t Run a system from json file" + \
                        "\n     \t--rounds= int   " + "\t Number of rounds to run in the system" + \
                        "\n  -z \t--fuzzer        " + "\t run fuzzing tester" + \
                        "\n  -d \t--debug         " + "\t enable debug mode" + \
                        "\n     \t--server        " + "\t start web service" + \
                        "\n     \t--port= int     " + "\t server port number" + \
                        "\n\nReport fodtlmon bugs to walid.benghabrit@mines-nantes.fr" + \
                        "\nfodtlmon home page: <https://github.com/hkff/fodtlmon>" + \
                        "\nfodtlmon is a free software released under GPL 3"

    # Checking options
    try:
        opts, args = getopt.getopt(argv[1:], "hi:o:f:t:1234zd",
                                   ["help", "input=", "output=", "trace=", "formula=" "ltl", "fotl", "dtl",
                                    "fodtl", "sys=", "fuzzer", "itrace=", "iformula=", "rounds=", "l2m", "debug",
                                    "server", "port="])
    except getopt.GetoptError:
        print(help_str_extended)
        sys.exit(2)

    if len(opts) == 0:
        print(help_str_extended)

    # Handling options
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            print(help_str_extended)
            sys.exit()
        elif opt in ("-i", "--input"):
            input_file = arg
        elif opt in ("-o", "--output"):
            output_file = arg
        elif opt in ("-1", "--ltl"):
            monitor = Ltlmon
        elif opt in ("-2", "--fotl"):
            monitor = Fotlmon
        elif opt in ("-3", "--dtl"):
            monitor = Dtlmon
        elif opt in ("-4", "--fodtl"):
            monitor = Fodtlmon
        elif opt in ("-f", "--formula"):
            formula = arg
        elif opt in ("-t", "--trace"):
            trace = arg
        elif opt in "--sys":
            isys = arg
        elif opt in "--rounds":
            rounds = int(arg)
        elif opt in ("-z", "--fuzzer"):
            fuzzer = True
        elif opt in "--iformula":
            iformula = arg
        elif opt in "--itrace":
            itrace = arg
        elif opt in "--l2m":
            l2m = True
        elif opt in ("-d", "--debug"):
            debug = True
        elif opt in "--server":
            webservice = True
        elif opt in "--port":
            server_port = int(arg)

    if webservice:
        Webservice.start(server_port)
        return

    if fuzzer:
        if monitor is Ltlmon:
            run_ltl_tests(monitor="ltl", alphabet=["P"], constants=["a", "b", "c"], trace_lenght=10000, formula_depth=5,
                          formula_nbr=10000, debug=debug)
        elif monitor is Dtlmon:
            run_dtl_tests()
        return

    if itrace is not None:
        with open(itrace, "r") as f:
            trace = f.read()

    if iformula is not None:
        with open(iformula, "r") as f:
            formula = f.read()

    if isys is not None:
        with open(isys, "r") as f:
            js = f.read()
            s = System.parseJSON(js)
            for x in range(rounds):
                s.run()
        return

    # print(argv)
    if None not in (monitor, trace, formula):
        tr = Trace().parse(trace)
        fl = eval(formula[1:]) if formula.startswith(":") else FodtlParser.parse(formula)
        mon = monitor(fl, tr)
        res = mon.monitor(debug=debug)
        print("")
        print("Trace        : %s" % tr)
        print("Formula      : %s" % fl)
        print("Code         : %s" % fl.toCODE())
        print("PPrint       : %s" % fl.prefix_print())
        print("TSPASS       : %s" % fl.toTSPASS())
        print("LTLFO        : %s" % fl.toLTLFO())
        print("Result       : %s" % res)
        if l2m:
            print(fl.toLTLFO())
            res = ltlfo2mon(fl.toLTLFO(), tr.toLTLFO())
            print("ltl2mon : %s" % res)