當前位置: 首頁>>代碼示例>>Python>>正文


Python sys.exit方法代碼示例

本文整理匯總了Python中sys.exit方法的典型用法代碼示例。如果您正苦於以下問題:Python sys.exit方法的具體用法?Python sys.exit怎麽用?Python sys.exit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sys的用法示例。


在下文中一共展示了sys.exit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _tests

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def _tests(self):
        settings.configure(
            DEBUG=True,
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                }
            },
            INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
            MIDDLEWARE=self.MIDDLEWARE,
            ROOT_URLCONF='django_classified.tests.urls',
            STATIC_URL='/static/',
            TEMPLATES=self.TEMPLATES,
            SITE_ID=1
        )

        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner()
        django.setup()

        failures = test_runner.run_tests(self.apps)
        if failures:
            sys.exit(failures) 
開發者ID:slyapustin,項目名稱:django-classified,代碼行數:26,代碼來源:quicktest.py

示例2: retrieve_top_tor_exit_ips

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def retrieve_top_tor_exit_ips(limit=CLOUDFLARE_ACCESS_RULE_LIMIT):
    """
    Retrieve exit information from Onionoo sorted by consensus weight
    """
    exits = {}
    params = {
        'running': True,
        'flag': 'Exit',
        'fields': 'or_addresses,exit_probability',
        'order': '-consensus_weight',
        'limit': limit
    }
    r = requests.get("https://onionoo.torproject.org/details", params=params)
    r.raise_for_status()
    res = r.json()
    for relay in res.get('relays'):
        or_address = relay.get('or_addresses')[0].split(':')[0]
        exit_probability = relay.get('exit_probability', 0.0)
        # Try calculate combined weight for all relays on each IP
        exits[or_address] = exits.get(or_address, 0.0) + exit_probability
    return sorted(exits, key=exits.get, reverse=True) 
開發者ID:DonnchaC,項目名稱:cloudflare-tor-whitelister,代碼行數:23,代碼來源:whitelist.py

示例3: run

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def run(self):
        try:
            self.status('Removing previous builds…')
            rmtree(os.path.join(here, 'dist'))
        except OSError:
            pass

        self.status('Building Source and Wheel (universal) distribution…')
        os.system('{0} setup.py sdist bdist_wheel --universal'.format(
            sys.executable
        ))

        self.status('Uploading the package to PyPi via Twine…')
        os.system('twine upload dist/*')

        sys.exit() 
開發者ID:apirobot,項目名稱:django-rest-polymorphic,代碼行數:18,代碼來源:setup.py

示例4: checkRequirements

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def checkRequirements(args):
    if not remap.check_swalign():
        print("ERROR: check that svviz is correctly installed -- the 'ssw' Smith-Waterman alignment module does not appear to be functional")
        sys.exit(1)
    if args.export:
        exportFormat = export.getExportFormat(args)
        converter = export.getExportConverter(args, exportFormat)
        if converter is None and exportFormat != "svg":
            if args.converter is not None:
                logging.error("ERROR: unable to run SVG converter '{}'. Please check that it is "
                    "installed correctly".format(args.converter))
            else:
                logging.error("ERROR: unable to export to PDF/PNG because at least one of the following "
                    "programs must be correctly installed: webkitToPDF, librsvg or inkscape")

            sys.exit(1) 
開發者ID:svviz,項目名稱:svviz,代碼行數:18,代碼來源:app.py

示例5: getExportConverter

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def getExportConverter(args, exportFormat):
    if args.converter == "webkittopdf" and exportFormat=="png":
        logging.error("webkitToPDF does not support export to PNG; use librsvg or inkscape instead, or "
            "export to PDF")
        sys.exit(1)

    if exportFormat == "png" and args.converter is None:
        return "librsvg"

    if args.converter == "rsvg-convert":
        return "librsvg"

    if args.converter in [None, "webkittopdf"]:
        if checkWebkitToPDF():
            return "webkittopdf"

    if args.converter in [None, "librsvg"]:
        if checkRSVGConvert():
            return "librsvg"

    if args.converter in [None, "inkscape"]:
        if checkInkscape():
            return "inkscape"

    return None 
開發者ID:svviz,項目名稱:svviz,代碼行數:27,代碼來源:export.py

示例6: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def __init__(self):

        self._logger = Util.get_logger('SPOT.COMMON.KERBEROS')
        principal, keytab, sasl_mech, security_proto = config.kerberos()

        if os.getenv('KINITPATH'):
            self._kinit = os.getenv('KINITPATH')
        else:
            self._kinit = "kinit"

        self._kinitopts = os.getenv('KINITOPTS')
        self._keytab = "-kt {0}".format(keytab)
        self._krb_user = principal

        if self._kinit == None or self._keytab == None or self._krb_user == None:
            self._logger.error("Please verify kerberos configuration, some environment variables are missing.")
            sys.exit(1)

        if self._kinitopts is None:
            self._kinit_cmd = "{0} {1} {2}".format(self._kinit, self._keytab, self._krb_user)
        else:
            self._kinit_cmd = "{0} {1} {2} {3}".format(self._kinit, self._kinitopts, self._keytab, self._krb_user) 
開發者ID:apache,項目名稱:incubator-spot,代碼行數:24,代碼來源:kerberos.py

示例7: validate_parameters_values

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def validate_parameters_values(args,logger):

    logger.info("Validating input parameter values")

    #date.
    is_date_ok = True if len(args.date) == 8 else False

    # type
    dirs = os.walk(script_path).next()[1]
    is_type_ok = True if args.type in dirs else False

    #limit
    try:
        int(args.limit)
        is_limit_ok = True
    except ValueError:
        is_limit_ok = False

    if not is_date_ok: logger.error("date parameter is not correct, please validate it")
    if not is_type_ok: logger.error("type parameter is not supported, please select a valid type")
    if not is_limit_ok: logger.error("limit parameter is not correct, please select a valid limit")
    if not is_date_ok or not is_type_ok or not is_limit_ok: sys.exit(1) 
開發者ID:apache,項目名稱:incubator-spot,代碼行數:24,代碼來源:start_oa.py

示例8: _get_proxy_results

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def _get_proxy_results(self):

        self._logger.info("Getting {0} Machine Learning Results from HDFS".format(self._date))
        proxy_results = "{0}/proxy_results.csv".format(self._data_path)

        # get hdfs path from conf file.
        HUSER = self._spot_conf.get('conf', 'HUSER').replace("'", "").replace('"', '')
        hdfs_path = "{0}/proxy/scored_results/{1}/scores/proxy_results.csv".format(HUSER,self._date)

        # get results file from hdfs.
        get_command = Util.get_ml_results_form_hdfs(hdfs_path,self._data_path)
        self._logger.info("{0}".format(get_command))

         # valdiate files exists
        if os.path.isfile(proxy_results):

            # read number of results based in the limit specified.
            self._logger.info("Reading {0} proxy results file: {1}".format(self._date,proxy_results))
            self._proxy_results = Util.read_results(proxy_results,self._limit,self._results_delimiter)[:]
            if len(self._proxy_results) == 0: self._logger.error("There are not proxy results.");sys.exit(1)
        else:
            self._logger.error("There was an error getting ML results from HDFS")
            sys.exit(1)

        self._proxy_scores = self._proxy_results[:] 
開發者ID:apache,項目名稱:incubator-spot,代碼行數:27,代碼來源:proxy_oa.py

示例9: main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def main(raw_args):
    import cmd_utils

    parser = cmd_utils.build_arg_parser(description='Builds LLVM for Mono')

    default_help = 'default: %(default)s'

    parser.add_argument('action', choices=['make', 'clean'])
    parser.add_argument('--target', choices=target_values, action='append', required=True)

    cmd_utils.add_base_arguments(parser, default_help)

    args = parser.parse_args(raw_args)

    opts = base_opts_from_args(args)
    targets = args.target

    try:
        for target in targets:
            action = { 'make': make, 'clean': clean }[args.action]
            action(opts, target)
    except BuildError as e:
        sys.exit(e.message) 
開發者ID:godotengine,項目名稱:godot-mono-builds,代碼行數:25,代碼來源:llvm.py

示例10: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def __init__(self, app):
        """
        Initialisation of qi framework and event detection.
        """
        super(HumanTrackedEventWatcher, self).__init__()

        try:
            app.start()
        except RuntimeError:
            print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " +
                   str(args.port) + ".\n")

            sys.exit(1)

        session = app.session
        self.subscribers_list = []
        self.is_speech_reco_started = False

        # SUBSCRIBING SERVICES
        self.tts             = session.service("ALTextToSpeech")
        self.memory          = session.service("ALMemory")
        self.motion          = session.service("ALMotion")
        self.speech_reco     = session.service("ALSpeechRecognition")
        self.basic_awareness = session.service("ALBasicAwareness") 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:26,代碼來源:human_greeter_with_awareness.py

示例11: run

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def run(self):
        """
        Loop on, wait for events until manual interruption.
        """
        # start
        print "Waiting for the robot to be in wake up position"
        self.motion.wakeUp()

        print "Starting HumanGreeter"
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            print "Interrupted by user, stopping HumanGreeter"
            self.face_detection.unsubscribe("HumanGreeter")
            #stop
            sys.exit(0)

        return 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:21,代碼來源:human_greeter.py

示例12: _moveForward

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def _moveForward(self, amnt):
        #TARGET VELOCITY
        X = 0.5  # forward
        Y = 0.0
        Theta = 0.0

        try:
            self.motion.moveToward(X, Y, Theta)
        except KeyboardInterrupt:
            print "KeyBoard Interrupt initiated"
            self.motion.stopMove()
            exit()
        except Exception, errorMsg:
            print str(errorMsg)
            print "This example is not allowed on this robot."
            exit() 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:18,代碼來源:remote_voice.py

示例13: _rotateRight

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def _rotateRight(self, amnt):
        #TARGET VELOCITY
        X = 0.0
        Y = 0.0
        Theta = -0.5

        try:
            self.motion.moveToward(X, Y, Theta)
        except KeyboardInterrupt:
            print "KeyBoard Interrupt initiated"
            self.motion.stopMove()
            exit()
        except Exception, errorMsg:
            print str(errorMsg)
            print "This example is not allowed on this robot."
            exit() 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:18,代碼來源:remote_voice.py

示例14: _rotateLeft

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def _rotateLeft(self, amnt):
        #TARGET VELOCITY
        X = 0.0
        Y = 0.0
        Theta = 0.5

        try:
            self.motion.moveToward(X, Y, Theta)
        except KeyboardInterrupt:
            print "KeyBoard Interrupt initiated"
            self.motion.stopMove()
            exit()
        except Exception, errorMsg:
            print str(errorMsg)
            print "This example is not allowed on this robot."
            exit() 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:18,代碼來源:remote_voice.py

示例15: _moveForward

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import exit [as 別名]
def _moveForward(self, amnt):
        #TARGET VELOCITY
        X = 0.5  # forward
        Y = 0.0
        Theta = 0.0

        try:
            self.motion_service.moveToward(X, Y, Theta)
        except KeyboardInterrupt:
            print "KeyBoard Interrupt initiated"
            self.motion_service.stopMove()
            exit()
        except Exception, errorMsg:
            print str(errorMsg)
            print "This example is not allowed on this robot."
            exit() 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:18,代碼來源:remote_terminal.py


注:本文中的sys.exit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。