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 — kale/submit-debug-info ( c0cb8c...f2d693 )
by
unknown
08:15
created

BaseAction   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %
Metric Value
wmc 5
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 26 5
1
#!/usr/bin/env python
2
3
import time
4
5
from oslo_config import cfg
6
7
from st2actions.runners.pythonrunner import Action
8
from st2actions.runners.ssh.paramiko_ssh import ParamikoSSHClient
9
10
11
class BaseAction(Action):
12
    def run(self, hostname, port, username, password=None, keyfile=None, ssh_timeout=5,
13
            sleep_delay=20, retries=10):
14
        # Note: If neither password nor key file is provided, we try to use system user
15
        # key file
16
        if not password and not keyfile:
17
            keyfile = cfg.CONF.system_user.ssh_key_file
18
            self.logger.info('Neither "password" nor "keyfile" parameter provided, '
19
                             'defaulting to using "%s" key file' % (keyfile))
20
21
        client = ParamikoSSHClient(hostname=hostname, port=port, username=username,
22
                                   password=password, key_files=keyfile,
23
                                   timeout=ssh_timeout)
24
25
        for index in range(retries):
26
            attempt = index + 1
27
28
            try:
29
                self.logger.debug('SSH connection attempt: %s' % (attempt))
30
                client.connect()
31
                return True
32
            except Exception as e:
33
                self.logger.info('Attempt %s failed (%s), sleeping for %s seconds...' %
34
                                 (attempt, str(e), sleep_delay))
35
                time.sleep(sleep_delay)
36
37
        raise Exception('Exceeded max retries (%s)' % (retries))
38