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.
Completed
Push — master ( c4f2c4...d85470 )
by Gonzalo
20s
created

run_checks_and_format.run_process()   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# -----------------------------------------------------------------------------
4
# Copyright (c) 2015 Yann Lanthony
5
# Copyright (c) 2017-2018 Spyder Project Contributors
6
#
7
# Licensed under the terms of the MIT License
8
# (See LICENSE.txt for details)
9
# -----------------------------------------------------------------------------
10
"""Run checks and format code."""
11
12
# yapf: disable
13
14
# Standard library imports
15
from subprocess import PIPE, Popen
16
import sys
17
18
19
# yapf: enable
20
21
# Constants
22
PY3= sys.version[0] == '3'
23
COMMANDS = [
24
    ['pydocstyle', 'qtsass'],
25
    ['pycodestyle', 'qtsass'],
26
    ['yapf', 'qtsass', '--in-place', '--recursive'],
27
    ['isort', '-y'],
28
]
29
30
31
def run_process(cmd_list):
32
    """Run popen process."""
33
    p = Popen(cmd_list, stdout=PIPE, stderr=PIPE)
34
    out, err = p.communicate()
35
    if PY3:
36
        out = out.decode()
37
        err = err.decode()
38
    return out, err
39
40
41
def repo_changes():
42
    """Check if repo files changed."""
43
    out, err = run_process(['git', 'status', '--short'])
44
    out_lines = [l for l in out.split('\n') if l.strip()]
45
    return out_lines
46
47
48
def run():
49
    """Run linters and formatters."""
50
    for cmd_list in COMMANDS:
51
        cmd_str = ' '.join(cmd_list)
52
        print('\nRunning: ' + cmd_str)
53
54
        out, err = run_process(cmd_list)
55
        if out:
56
            print(out)
57
        if err:
58
            print(err)
59
60
    out_lines = repo_changes()
61
    if out_lines:
62
        print('\nPlease run the linter and formatter script!')
63
        print('\n'.join(out_lines))
64
        code = 1
65
    else:
66
        print('\nAll checks passed!')
67
        code = 0
68
69
    print('\n')
70
    sys.exit(code)
71
72
73
if __name__ == '__main__':
74
    run()
75