aboutsummaryrefslogtreecommitdiffstats
path: root/.pylintrc
blob: 78f656269c7adb0b3bac17285f759c93e26e5feb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
[MASTER]

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=

# Use multiple processes to speed up Pylint.
jobs=1

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=


[MESSAGES CONTROL]

# --disable=W"
disable=
# "F" Fatal errors that prevent further processing
 import-error,
# "I" Informational noise
 locally-disabled,
# "E" Error for important programming issues (likely bugs)
 access-member-before-definition,
 no-member,
 no-method-argument,
 no-self-argument,
 not-an-iterable,
# "W" Warnings for stylistic problems or minor programming issues
 abstract-method,
 arguments-differ,
 attribute-defined-outside-init,
 bad-builtin,
 bad-indentation,
 dangerous-default-value,
 deprecated-lambda,
 expression-not-assigned,
 fixme,
 global-statement,
 literal-comparison,
 no-init,
 non-parent-init-called,
 not-callable,
 protected-access,
 redefined-builtin,
 redefined-outer-name,
 signature-differs,
 star-args,
 super-init-not-called,
 super-on-old-class,
 unpacking-non-sequence,
 useless-super-delegation,
 nonstandard-exception,
# "C" Coding convention violations
 bad-continuation,
 consider-iterating-dictionary,
 consider-using-enumerate,
 invalid-name,
 len-as-condition,
 misplaced-comparison-constant,
 missing-docstring,
 singleton-comparison,
 superfluous-parens,
 ungrouped-imports,
 wrong-import-order,
# "R" Refactor recommendations
 abstract-class-little-used,
 abstract-class-not-used,
 consider-merging-isinstance,
 consider-using-ternary,
 duplicate-code,
 inconsistent-return-statements,
 interface-not-implemented,
 no-else-return,
 no-self-use,
 redefined-argument-from-local,
 simplifiable-if-statement,
 too-few-public-methods,
 too-many-ancestors,
 too-many-arguments,
 too-many-branches,
 too-many-instance-attributes,
 too-many-lines,
 too-many-locals,
 too-many-nested-blocks,
 too-many-public-methods,
 too-many-return-statements,
 too-many-statements

[BASIC]
# Variable names can be 1 to 31 characters long, with lowercase and underscores
variable-rgx=[a-z_][a-z0-9_]{0,30}$

# Argument names can be 2 to 31 characters long, with lowercase and underscores
argument-rgx=[a-z_][a-z0-9_]{1,30}$

# Method names should be at least 3 characters long
# and be lowercased with underscores
method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$

# Module names matching neutron-* are ok (files in bin/)
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Don't require docstrings on tests.
no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$

dummy-variables-rgx=(_+[a-zA-Z0-9]*?$)|dummy|args

[FORMAT]
# Maximum number of characters on a single line.
max-line-length=99

# String used as indentation unit. This is usually "    " (4 spaces) or "\t" (1
# tab).
indent-string='    '


[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
# _ is used by our localization
additional-builtins=_


[CLASSES]
# List of interface methods to ignore, separated by a comma.
ignore-iface-methods=


[TYPECHECK]
# List of module names for which member attributes should not be checked
ignored-modules=six.moves,_MovedItems


[REPORTS]
# Tells whether to display a full report or only the messages
reports=no

# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html. You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=colorized

# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)


[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
pan class="n">build_parser = argparse.ArgumentParser() build_parser.add_argument('--debug', action='store_true', default=False, help="Turn on debug messages") build_parser.add_argument('-l', '--log-file', default=BUILD_LOG_FILE, dest='log_file', help="Log file to log to") build_parser.add_argument('-c', '--cache-dir', dest='cache_dir', default=None, help='Directory to store cache') build_parser.add_argument('--iso', action='store_true', default=False, help='Build ISO image') build_parser.add_argument('--rpms', action='store_true', default=False, help='Build RPMs') build_parser.add_argument('-r', '--release', dest='build_version', help='Version to apply to build ' 'artifact label') return build_parser def get_journal(cache_dir): """ Search for the journal file and returns its contents :param cache_dir: cache storage directory where journal file is :return: content of journal file """ journal_file = "{}/{}".format(cache_dir, CACHE_JOURNAL) if os.path.isfile(journal_file) is False: logging.info("Journal file not found {}, skipping cache search".format( journal_file)) else: with open(journal_file, 'r') as fh: cache_journal = yaml.safe_load(fh) assert isinstance(cache_journal, list) return cache_journal def get_cache_file(cache_dir): """ Searches for a valid cache entry in the cache journal :param cache_dir: directory where cache and journal are located :return: name of valid cache file """ cache_journal = get_journal(cache_dir) if cache_journal is not None: valid_cache = cache_journal[-1] if os.path.isfile(valid_cache): return valid_cache def unpack_cache(cache_dest, cache_dir=None): if cache_dir is None: logging.info("Cache directory not provided, skipping cache unpack") return elif os.path.isdir(cache_dir) is False: logging.info("Cache Directory does not exist, skipping cache unpack") return else: logging.info("Cache Directory Found: {}".format(cache_dir)) cache_file = get_cache_file(cache_dir) if cache_file is None: logging.info("No cache file detected, skipping cache unpack") return logging.info("Unpacking Cache {}".format(cache_file)) if not os.path.exists(cache_dest): os.makedirs(cache_dest) try: subprocess.check_call(["tar", "xvf", cache_file, "-C", cache_dest]) except subprocess.CalledProcessError: logging.warning("Cache unpack failed") return logging.info("Cache unpacked, contents are: {}".format( os.listdir(cache_dest))) def build(build_root, version, iso=False, rpms=False): if iso: make_targets = ['iso'] elif rpms: make_targets = ['rpms'] else: make_targets = ['images', 'rpms-check'] if version is not None: make_args = ['RELEASE={}'.format(version)] else: make_args = [] logging.info('Running make clean...') try: subprocess.check_call(['make', '-C', build_root, 'clean']) except subprocess.CalledProcessError: logging.error('Failure to make clean') raise logging.info('Building targets: {}'.format(make_targets)) try: output = subprocess.check_output(["make"] + make_args + ["-C", build_root] + make_targets) logging.info(output) except subprocess.CalledProcessError as e: logging.error("Failed to build Apex artifacts") logging.error(e.output) raise e def build_cache(cache_source, cache_dir): """ Tar up new cache with unique name and store it in cache storage directory. Also update journal file with new cache entry. :param cache_source: source files to tar up when building cache file :param cache_dir: cache storage location :return: None """ if cache_dir is None: logging.info("No cache dir specified, will not build cache") return cache_name = 'apex-cache-{}.tgz'.format(str(uuid.uuid4())) cache_full_path = os.path.join(cache_dir, cache_name) os.makedirs(cache_dir, exist_ok=True) try: subprocess.check_call(['tar', '--atime-preserve', '--dereference', '-caf', cache_full_path, '-C', cache_source, '.']) except BaseException as e: logging.error("Unable to build new cache tarball") if os.path.isfile(cache_full_path): os.remove(cache_full_path) raise e if os.path.isfile(cache_full_path): logging.info("Cache Build Complete") # update journal cache_entries = get_journal(cache_dir) if cache_entries is None: cache_entries = [cache_name] else: cache_entries.append(cache_name) journal_file = os.path.join(cache_dir, CACHE_JOURNAL) with open(journal_file, 'w') as fh: yaml.safe_dump(cache_entries, fh, default_flow_style=False) logging.info("Journal updated with new entry: {}".format(cache_name)) else: logging.warning("Cache file did not build correctly") def prune_cache(cache_dir): """ Remove older cache entries if there are more than 2 :param cache_dir: Cache storage directory :return: None """ if cache_dir is None: return cache_modified_flag = False cache_entries = get_journal(cache_dir) while len(cache_entries) > 2: logging.debug("Will remove older cache entries") cache_to_rm = cache_entries[0] cache_full_path = os.path.join(cache_dir, cache_to_rm) if os.path.isfile(cache_full_path): try: os.remove(cache_full_path) cache_entries.pop(0) cache_modified_flag = True except OSError: logging.warning("Failed to remove cache file: {}".format( cache_full_path)) break else: logging.debug("No more cache cleanup necessary") if cache_modified_flag: logging.debug("Updating cache journal") journal_file = os.path.join(cache_dir, CACHE_JOURNAL) with open(journal_file, 'w') as fh: yaml.safe_dump(cache_entries, fh, default_flow_style=False) def main(): parser = create_build_parser() args = parser.parse_args(sys.argv[1:]) if args.debug: log_level = logging.DEBUG else: log_level = logging.INFO os.makedirs(os.path.dirname(args.log_file), exist_ok=True) formatter = '%(asctime)s %(levelname)s: %(message)s' logging.basicConfig(filename=args.log_file, format=formatter, datefmt='%m/%d/%Y %I:%M:%S %p', level=log_level) console = logging.StreamHandler() console.setLevel(log_level) console.setFormatter(logging.Formatter(formatter)) logging.getLogger('').addHandler(console) # Since we only support building inside of git repo this should be fine try: apex_root = subprocess.check_output( ['git', 'rev-parse', '--show-toplevel']).decode('utf-8').strip() except subprocess.CalledProcessError: logging.error("Must be in an Apex git repo to execute build") raise apex_build_root = os.path.join(apex_root, BUILD_ROOT) if os.path.isdir(apex_build_root): cache_tmp_dir = os.path.join(apex_root, TMP_CACHE) else: logging.error("You must execute this script inside of the Apex " "local code repository") raise ApexBuildException("Invalid path for apex root: {}. Must be " "invoked from within Apex code directory.". format(apex_root)) dep_playbook = os.path.join(apex_root, 'lib/ansible/playbooks/build_dependencies.yml') utils.run_ansible(None, dep_playbook) unpack_cache(cache_tmp_dir, args.cache_dir) build(apex_build_root, args.build_version, args.iso, args.rpms) build_cache(cache_tmp_dir, args.cache_dir) prune_cache(args.cache_dir) if __name__ == '__main__': main()