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 — plexxi-v2.3.2 ( 5d46fe )
by
unknown
06:59
created

PackSearch.run()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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
# limitations under the License.
15
16
import os
17
18
from st2common.runners.base_action import Action
19
from st2common.services.packs import search_pack_index
20
21
22
class PackSearch(Action):
23
    def __init__(self, config=None, action_service=None):
24
        super(PackSearch, self).__init__(config=config, action_service=action_service)
25
        self.https_proxy = os.environ.get('https_proxy', self.config.get('https_proxy', None))
26
        self.http_proxy = os.environ.get('http_proxy', self.config.get('http_proxy', None))
27
        self.proxy_ca_bundle_path = os.environ.get(
28
            'proxy_ca_bundle_path',
29
            self.config.get('proxy_ca_bundle_path', None)
30
        )
31
        self.no_proxy = os.environ.get('no_proxy', self.config.get('no_proxy', None))
32
33
        self.proxy_config = None
34
35
        if self.http_proxy or self.https_proxy:
36
            self.logger.debug('Using proxy %s',
37
                              self.http_proxy if self.http_proxy else self.https_proxy)
38
            self.proxy_config = {
39
                'https_proxy': self.https_proxy,
40
                'http_proxy': self.http_proxy,
41
                'proxy_ca_bundle_path': self.proxy_ca_bundle_path,
42
                'no_proxy': self.no_proxy
43
            }
44
45
        if self.https_proxy and not os.environ.get('https_proxy', None):
46
            os.environ['https_proxy'] = self.https_proxy
47
48
        if self.http_proxy and not os.environ.get('http_proxy', None):
49
            os.environ['http_proxy'] = self.http_proxy
50
51
        if self.no_proxy and not os.environ.get('no_proxy', None):
52
            os.environ['no_proxy'] = self.no_proxy
53
54
        if self.proxy_ca_bundle_path and not os.environ.get('proxy_ca_bundle_path', None):
55
            os.environ['no_proxy'] = self.no_proxy
56
57
    """"Search for packs in StackStorm Exchange and other directories."""
0 ignored issues
show
Unused Code introduced by
This string statement has no effect and could be removed.
Loading history...
58
    def run(self, query):
59
        """
60
        :param query: A word or a phrase to search for
61
        :type query: ``str``
62
        """
63
        self.logger.debug('Proxy config: %s', self.proxy_config)
64
        return search_pack_index(query, proxy_config=self.proxy_config)
65