GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 3743cd...0864db )
by Plexxi
05:37
created

st2common.util.is_use_debugger_flag_provided()   B

Complexity

Conditions 5

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 13
rs 8.5454
cc 5
1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
#
15
16
"""
17
Module for performing eventlet related monkey patching.
18
"""
19
20
import sys
21
22
import eventlet
23
24
__all__ = [
25
    'monkey_patch'
26
]
27
28
USE_DEBUGGER_FLAG = '--use-debugger'
29
PARENT_ARGS_FLAG = '--parent-args='
30
31
32
def monkey_patch():
33
    """
34
    Function which performs eventlet monkey patching and also takes into account "--use-debugger"
35
    argument in the command line arguments.
36
37
    If this argument is found, no monkey patching is performed for the thread module. This allows
38
    user to use remote debuggers.
39
    """
40
    patch_thread = not is_use_debugger_flag_provided()
41
    eventlet.monkey_patch(os=True, select=True, socket=True, thread=patch_thread, time=True)
42
43
44
def is_use_debugger_flag_provided():
45
    # 1. Check sys.argv directly
46
    if USE_DEBUGGER_FLAG in sys.argv:
47
        return True
48
49
    # 2. Check "parent-args" arguments. This is used for spawned processes such as sensors and
50
    # Python runner actions
51
52
    for arg in sys.argv:
53
        if arg.startswith(PARENT_ARGS_FLAG) and USE_DEBUGGER_FLAG in arg:
54
            return True
55
56
    return False
57