Conditions | 9 |
Total Lines | 62 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # -*- coding: utf-8 -*- |
||
40 | def __init__(self, config=None, args=None): |
||
41 | self.config = config |
||
42 | self.args = args |
||
43 | |||
44 | # Quiet mode |
||
45 | self._quiet = args.quiet |
||
46 | self.refresh_time = args.time |
||
47 | |||
48 | # Init stats |
||
49 | start_duration = Counter() |
||
50 | start_duration.reset() |
||
51 | self.stats = GlancesStats(config=config, args=args) |
||
52 | logger.debug("Plugins initialisation duration: {} seconds".format(start_duration.get())) |
||
53 | |||
54 | # Modules (plugins and exporters) are loaded at this point |
||
55 | # Glances can display the list if asked... |
||
56 | if args.modules_list: |
||
57 | self.display_modules_list() |
||
58 | sys.exit(0) |
||
59 | |||
60 | # If process extended stats is disabled by user |
||
61 | if not args.enable_process_extended: |
||
62 | logger.debug("Extended stats for top process are disabled") |
||
63 | glances_processes.disable_extended() |
||
64 | else: |
||
65 | logger.debug("Extended stats for top process are enabled") |
||
66 | glances_processes.enable_extended() |
||
67 | |||
68 | # Manage optionnal process filter |
||
69 | if args.process_filter is not None: |
||
70 | glances_processes.process_filter = args.process_filter |
||
71 | |||
72 | if (not WINDOWS) and args.no_kernel_threads: |
||
73 | # Ignore kernel threads in process list |
||
74 | glances_processes.disable_kernel_threads() |
||
75 | |||
76 | # Initial system informations update |
||
77 | start_duration.reset() |
||
78 | self.stats.update() |
||
79 | logger.debug("First stats update duration: {} seconds".format(start_duration.get())) |
||
80 | |||
81 | if self.quiet: |
||
82 | logger.info("Quiet mode is ON, nothing will be displayed") |
||
83 | # In quiet mode, nothing is displayed |
||
84 | glances_processes.max_processes = 0 |
||
85 | elif args.stdout: |
||
86 | logger.info("Stdout mode is ON, following stats will be displayed: {}".format(args.stdout)) |
||
87 | # Init screen |
||
88 | self.screen = GlancesStdout(config=config, args=args) |
||
89 | elif args.stdout_csv: |
||
90 | logger.info("Stdout CSV mode is ON, following stats will be displayed: {}".format(args.stdout)) |
||
91 | # Init screen |
||
92 | self.screen = GlancesStdoutCsv(config=config, args=args) |
||
93 | else: |
||
94 | # Default number of processes to displayed is set to 50 |
||
95 | glances_processes.max_processes = 50 |
||
96 | |||
97 | # Init screen |
||
98 | self.screen = GlancesCursesStandalone(config=config, args=args) |
||
99 | |||
100 | # Check the latest Glances version |
||
101 | self.outdated = Outdated(config=config, args=args) |
||
102 | |||
170 |