main program loop
496332
def main():
    '''  '''
    conn = symphony.Config('example-bot.cfg')
    # connect to pod
    agent, pod, symphony_sid = conn.connect()
    agent.test_echo('test')
    # main loop
    msgFormat = 'MESSAGEML'
    message = '<messageML> hello world. </messageML>'
    # send message
    agent.send_message(symphony_sid, msgFormat, message)
1349850
public function main() {
        $this->stdout->styles('success', array('text' => 'green'));

        $this->hr(1);
        $this->out(sprintf('%s Steps:', $this->name));

        $counter = 1;

        foreach ($this->steps as $method) {
            $this->steps($counter);

            try {
                if (!call_user_func(array($this, $method))) {
                    $this->err('<error>Process aborted!</error>');
                    break;
                }
            } catch (Exception $e) {
                $this->err(sprintf('<error>Unexpected error has occurred; %s</error>', $e->getMessage()));
                break;
            }

            $counter++;
        }
    }
506996
def main():
    

    logging.basicConfig(level=logging.INFO)

    example_sync_client(SyncAPIClient())
    example_async_client(AsyncAPIClient())

    io_loop = ioloop.IOLoop.current()
    io_loop.start()
1060462
function main(options) {
    function markInterval(list, first, last, step, value) {
        if (step > 0) {
            for (var i = first; i <= last; i += step) {
                if (i >= 0 && i < list.length) {
                    list[i] = value;
                }
            }
        }
    }

    /*
     * Parse an expression and mark the corresponding frames with the given value.
     *
     * expr ::= interval ("," interval)*
     *
     * interval ::=
     *      INT                     // frame number
     *    | INT? ":" INT?           // first:last
     *    | INT? ":" INT? ":" INT?  // first:second:last
     *
     * If first is omitted, it is set to 1.
     * If second is omitted, it is set to first + 1.
     * If last is omitted, it is set to list.length.
     */
    function markFrames(list, expr, value) {
        switch (expr) {
            case "all":
                markInterval(list, 0, list.length - 1, 1, value);
                break;
            case "none":
                break;
            default:
                expr.split(",").forEach(function (intervalDef) {
                    var interval = intervalDef.split(":").map(function (s) { return s.trim(); });
                    if (interval.length > 0) {
                        var first = interval[0] !== "" ? parseInt(interval[0]) - 1 : 0;
                        var last = interval[interval.length - 1] !== "" ? parseInt(interval[interval.length - 1]) - 1 : list.length - 1;
                        var second = interval.length > 2 && interval[1] !== "" ? parseInt(interval[1]) - 1 : first + 1;
                        if (!isNaN(first) && !isNaN(second) && !isNaN(last)) {
                            markInterval(list, first, last, second - first, value);
                        }
                    }
                });
        }
    }

    function zeroPadded(value, digits) {
        var result = value.toString();
        while(result.length < digits) {
            result = "0" + result;
        }
        return result;
    }

    var frameCount = sozi.presentation.frames.length;

    var frameSelection = new Array(frameCount);
    markInterval(frameSelection, 0, frameCount - 1, 1, false);
    markFrames(frameSelection, options.include, true);
    markFrames(frameSelection, options.exclude, false);

    var digits = frameCount.toString().length;

    sozi.player.addListener("frameChange", function () {
        var frameIndex = sozi.player.currentFrameIndex; // Sozi < 18
        if (typeof frameIndex !== "number") {
            frameIndex = sozi.player.currentFrame.index; // Sozi 18
        }
        window.callPhantom(zeroPadded((frameIndex + 1).toString(), digits));
    });

    document.querySelector(".sozi-blank-screen").style.display = "none";
    
    frameSelection.forEach(function (frameIsSelected, frameIndex) {
        if (frameIsSelected) {
            console.log("Exporting frame: " + (frameIndex + 1));
            sozi.player.jumpToFrame(frameIndex);
        }
    });
}
960210
public void run() {
        int length;
        char cs[] = new char[256];
        int ioErrorCount = 0;
        Reader reader = pair.getReader();

        logger.trace("Starting primary loop");
        while ( !stopRequested && !foundEOF && ioErrorCount < 4) {
            try {
                logger.trace("Checking ready");
                boolean ready = false;
                try {
                    ready = reader.ready(); // will not block
                    if( reader.markSupported() ) logger.trace("Mark Supported");
                } catch(Exception ioe) {
                    // The Pipe most likely closed on us.
                    logger.debug("Exception in PollingConsumer: " + ioe);
                    foundEOF = true;
                    break;
                }

                //if( !ready ) { ready = true; log.fine("Faking ready"); }

                if ( ready ) {
                    logger.trace("Is Ready");


                    // don't modify the buffer while processing is happening
                    // written as while loop to prevent spurious interrupts
                    synchronized(this) {
                        while( callerProcessing.booleanValue() ) {
                            logger.trace("Waiting for caller to finish");
                            try {
                                wait();
                            } catch(InterruptedException ie) {
                                logger.trace("Woken up early");
                                continue;
                            }
                        }

                        logger.trace("About to wait for buffer lock");
                        synchronized(buffer) {
                            length = reader.read(cs);

                            if( length == -1 ) { //EOF
                                logger.trace("Found the EOF");
                                logger.trace("Current buffer: " + buffer.toString() );
                                foundEOF = true;
                                dirtyBuffer = true;
                                break;
                            }

                            String print = new String(cs, 0, length);
                            print = print.replaceAll("\n", "\\\\n");
                            print = print.replaceAll("\r", "\\\\r");
                            logger.trace("Appending >>>" + print + "<<<");
                            buffer.append( cs, 0, length ); // thread safe

                            logger.trace("Current Buffer: " + buffer.toString() );
                            dirtyBuffer = true;

                            /**
                             * TODO Trim down buffer.  This current method won't work if a resume comes in, since it's offset
                             * will be invalid once this delete method runs
                             *
                             * // since we only added one char, we should only have to remove one
                             * if( buffer.length() > BUFFERMAX )
                             * buffer.delete(0, BUFFERMAX - buffer.length() );
                             */

                            logger.trace("Waking up who ever if listening");
                            buffer.notify(); // seeing that we read something, wait people up

                            // We explicitly call this after appending to the
                            // buffer, just in case one of the BufferChangeLoggers
                            // accidentally modifies the character buffer.
                            notifyBufferChange(cs, length);
                        }
                    }

                } else {
                    logger.trace("Not Ready, sleeping");
                    try { Thread.sleep(500); } catch(InterruptedException ie) { }
                    logger.trace("Done sleeping");
                    //continue;
                }
            }catch(IOException ioe) {
                logger.warn("Exception in loop body: " + ioe);
                ioErrorCount++;
                //continue;
            }
        } // end while loop


        synchronized(buffer) {
            buffer.notify();
        }
        if( stopRequested ) {
            logger.debug("Stop Requested");
            pair.close();
        }
        if ( foundEOF )
            logger.debug("Found EOF to stop while loop");
        if( ioErrorCount >= 4 )
            logger.debug("ioErrorCount at " + ioErrorCount );
        logger.trace("Leaving primary loop");
    }
628945
def main(args=None, stdin=sys.stdin, stdout=sys.stdout, print_exception=print_exception):
    
    try:
        # Set up logging.
        logging.basicConfig(level=logging.WARN)

        kind = args is not None and args[1] or sys.argv[1]
        Runner().run(kind, stdin=stdin, stdout=stdout)
    except Exception as exc:
        # Dump encoded data that we will try to fetch using mechanize
        print_exception(exc)
        raise
796651
def main_loop(self):
        """"""

        def exit(signum, frame):
            shutdown()
            sys.exit(0)

        signal.signal(signal.SIGTERM, exit)

        while True:
            task = self._get_next_task_from_raylet()
            self._wait_for_and_process_task(task)
503428
def main():
    
    parser = argparse.ArgumentParser()
    parser.add_argument("-o", "--out", help="Output results to a file instead of stdout", default=None)
    parser.add_argument("-p", "--path", help="Specifies the target directory to search in", default=os.getcwd())
    options = parser.parse_args()

    try:
        scanner = Scanner(path=options.path, output=options.out)
        scanner.run()
        scanner.output()
        
    except ScannerException as e:
        print("[!] Error, %s" % str(e))
        exit(1)
553309
def main():
    
    args = parser.parse_args()
    try:
        function = args.func
    except AttributeError:
        parser.print_usage()
        parser.exit(1)
    function(vars(args))
1113281
def _loop_thread_main(self):
        """"""

        asyncio.set_event_loop(self.loop)
        self._loop_check.inside_loop = True

        try:
            self._logger.debug("Starting loop in background thread")
            self.loop.run_forever()
            self._logger.debug("Finished loop in background thread")
        except:  # pylint:disable=bare-except;This is a background worker thread.
            self._logger.exception("Exception raised from event loop thread")
        finally:
            self.loop.close()
1246950
def main():
    

    logging.captureWarnings(True)
    logging.basicConfig(format=('%(asctime)s - %(name)s - %(levelname)s - ' +
                                '%(message)s'), level=logging.INFO)

    print("=====================================")
    print("========   Submit and Wait   ========")
    print("=====================================")
    print("")

    functionJobs = make_jobs()

    print("sending function jobs to cluster")
    print("")

    job_outputs = process_jobs(functionJobs, max_processes=4)

    print("results from each job")
    for (i, result) in enumerate(job_outputs):
        print("Job {0}- result: {1}".format(i, result))
258403
def main_loop(self, timeout=None):
        
        if self.trigger_event.wait(timeout):
            try:
                self.func()
            except Exception as e:
                self.logger.warning("Got an exception running {func}: {e}".format(func=self.func, e=str(e)))
            finally:
                self.trigger_event.clear()
426021
public function main()
    {
        $this->validate();

        try {
            if ($this->to !== null) {
                // create a file writer to append to "to" file.
                $writer = new FileWriter($this->to, $this->append);
            } else {
                $writer = new LogWriter($this);
            }

            if ($this->text !== null) {
                // simply append the text
                if ($this->to instanceof PhingFile) {
                    $this->log("Appending string to " . $this->to->getPath());
                }

                $text = $this->text;
                if ($this->filtering) {
                    $fr = $this->getFilteredReader(new StringReader($text));
                    $text = $fr->read();
                }

                $text = $this->appendHeader($text);
                $text = $this->appendFooter($text);
                $writer->write($text);
            } else {
                // append explicitly-specified file
                if ($this->file !== null) {
                    try {
                        $this->appendFile($writer, $this->file);
                    } catch (Exception $ioe) {
                        $this->log(
                            "Unable to append contents of file " . $this->file->getAbsolutePath() . ": " . $ioe->getMessage(),
                            Project::MSG_WARN
                        );
                    }
                }

                // append any files in filesets
                foreach ($this->filesets as $fs) {
                    try {
                        if ($fs instanceof Path) {
                            $files = $fs->listPaths();
                            $this->appendFiles($writer, $files);
                        } elseif ($fs instanceof FileSet) {
                            $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();
                            $this->appendFiles($writer, $files, $fs->getDir($this->project));
                        }
                    } catch (BuildException $be) {
                        if (strpos($be->getMessage(), 'is the same as the output file') === false) {
                            $this->log($be->getMessage(), Project::MSG_WARN);
                        } else {
                            throw new BuildException($be->getMessage());
                        }
                    } catch (IOException $ioe) {
                        throw new BuildException($ioe);
                    }
                }

                foreach ($this->filelists as $list) {
                    $dir = $list->getDir($this->project);
                    $files = $list->getFiles($this->project);
                    foreach ($files as $file) {
                        $this->appendFile($writer, new PhingFile($dir, $file));
                    }
                }
            }
        } catch (Exception $e) {
            throw new BuildException($e);
        }

        $writer->close();
    }
247521
public static void main(String[] args) {
        System.exit(call(System.out, System.err, args) ? 0 : 1);
    }
738436
def _main_loop(self):
        '''
        
        '''
        while self.active:
            self.expire()
            if self.roll and self.is_expired():
                self.start_time = self.start_time + self.window
                self._set_key()
            self.purge_old()
            time.sleep(self.cycle_time)
        self._clean_up()
1187756
def loop(self, intro=None):
        
        self.fire("preloop")
        if intro is not None:
            self.intro = intro
        if self.intro is not None:
            self.stdout.write(self.intro + "\n")
            self.stdout.flush()
        stop = None
        while not stop:
            if self.use_rawinput:
                try:
                    line = self.inputter(self.prompt)
                except EOFError:
                    line = self._eof
            else:
                self.stdout.write(self.prompt)
                self.stdout.flush()
                line = self.stdin.readline()
                if not len(line):
                    line = self._eof
                else:
                    line = line.rstrip("\r\n")
            line = self.fire("precmd", line)
            stop, results = self.onecmd(line)
            stop, results = self.fire("postcmd", stop, results, line)
        self.fire("postloop")
694353
def main():
    """"""
    from six import StringIO
    import eppy.iddv7 as iddv7
    IDF.setiddname(StringIO(iddv7.iddtxt))
    idf1 = IDF(StringIO(''))
    loopname = "p_loop"
    sloop = ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4']
    dloop = ['db0', ['db1', 'db2', 'db3'], 'db4']
    # makeplantloop(idf1, loopname, sloop, dloop)
    loopname = "c_loop"
    sloop = ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4']
    dloop = ['db0', ['db1', 'db2', 'db3'], 'db4']
    # makecondenserloop(idf1, loopname, sloop, dloop)
    loopname = "a_loop"
    sloop = ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4']
    dloop = ['zone1', 'zone2', 'zone3']
    makeairloop(idf1, loopname, sloop, dloop)
    idf1.savecopy("hh1.idf")