Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  cmd.py   Sprache: Python

 
# ***** BEGIN LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
# ***** END LICENSE BLOCK *****
import logging
from subprocess import check_call, CalledProcessError
import sys

from redo import retrying

log = logging.getLogger(__name__)


def main(argv):
    from argparse import ArgumentParser, REMAINDER

    parser = ArgumentParser()
    parser.add_argument(
        "-a""--attempts", type=int, default=5, help="How many times to retry."
    )
    parser.add_argument(
        "-s",
        "--sleeptime",
        type=int,
        default=60,
        help="How long to sleep between attempts. Sleeptime doubles after each attempt.",
    )
    parser.add_argument(
        "-m",
        "--max-sleeptime",
        type=int,
        default=5 * 60,
        help="Maximum length of time to sleep between attempts (limits backoff length).",
    )
    parser.add_argument("-v""--verbose", action="store_true", default=False)
    parser.add_argument(
        "cmd", nargs=REMAINDER, help="Command to run. Eg: wget http://blah"
    )

    args = parser.parse_args(argv[1:])

    if args.verbose:
        logging.basicConfig(level=logging.INFO)
        logging.getLogger("retry").setLevel(logging.INFO)
    else:
        logging.basicConfig(level=logging.ERROR)
        logging.getLogger("retry").setLevel(logging.ERROR)

    try:
        with retrying(
            check_call,
            attempts=args.attempts,
            sleeptime=args.sleeptime,
            max_sleeptime=args.max_sleeptime,
            retry_exceptions=(CalledProcessError,),
        ) as r_check_call:
            r_check_call(args.cmd)
    except KeyboardInterrupt:
        sys.exit(-1)
    except Exception as e:
        log.error(
            "Unable to run command after %d attempts" % args.attempts, exc_info=True
        )
        rc = getattr(e, "returncode", -2)
        sys.exit(rc)


if __name__ == "__main__":
    main(sys.argv)

Messung V0.5
C=94 H=91 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge