Пример #1
0
    def display_separately(self, save=True) -> None:
        os.system('cls' if os.name == 'nt' else 'clear')
        ch = HorizontalBarChart()
        ch.options.graph_color = 'white'

        while True:
            cpu = psutil.cpu_freq(percpu=True)

            for n, i in enumerate(cpu, start=1):
                percent = round((i.current - self._min) / (self._max - self._min) * 100, 2)
                ch.chart(
                    title=f'CPU #{n}',
                    pre_graph_text=f'Current: {round(i.current, 1)}hz || Min: {self._min}hz || Max: {self._max}hz',
                    post_graph_text=tools.create_usage_warning(percent, 30, 15),
                    footer=None,
                    maximum=self._max - self._min,
                    current=i.current - self._min
                )

                if save:
                    cpu = {
                        'user': [getpass.getuser()],
                        'cpu': [n],
                        'time': [time.time()],
                        'current': [i.current],
                        'usage': [percent]
                    }

                    tools.save_to_csv(cpu, '~/cpus.csv')

                print()

            time.sleep(0.8)
            os.system('cls' if os.name == 'nt' else 'clear')
        tools.save_to_csv(cpu, '~/cpu.csv')
Пример #2
0
    def display_combined(self) -> None:
        os.system('cls' if os.name == 'nt' else 'clear')
        ch = HorizontalBarChart()
        ch.options.graph_color = 'white'
        while True:
            cpu = psutil.cpu_freq(percpu=False)
            ch.chart(
                title='CPU (ALL)',
                pre_graph_text=f'Current: {round(cpu.current, 1)}hz || Min: {self._min}hz || Max: {self._max}hz',
                post_graph_text=tools.create_usage_warning(
                    round((cpu.current - self._min) / (self._max - self._min) * 100, 2),
                    30, 15),
                footer=None,
                maximum=self._max - self._min,
                current=cpu.current - self._min
            )
            print()

            time.sleep(0.8)
            os.system('cls' if os.name == 'nt' else 'clear')
Пример #3
0
def main():
    self = DiskUsage()
    parts = self.grab_partitions(exclude=[], every=False)

    for partname, part in parts.items():
        ch = HorizontalBarChart()
        title = (partname,)
        pre_graph_text = self.create_stats(part)
        footer = self.create_details_text(part)
        maximum = part["total"]
        current = part["used"]
        post_graph_text = create_usage_warning(
            part['percent'], 80, 60)

        ch.chart(
            post_graph_text=post_graph_text,
            title=title[0],
            pre_graph_text=pre_graph_text,
            footer=footer,
            maximum=maximum,
            current=current,
        )
        print()
Пример #4
0
        elif file_type == 'json':
            save_to_json(data, filename)
        else:
            raise NameError("Not supported file type, please indicate " +
                            ".CSV or .JSON at the end of the filename")


if __name__ == "__main__":
    self = DiskUsage()
    parts = self.grab_partitions(exclude=[], every=False)

    for partname in parts:
        part = parts[partname]
        ch = HorizontalBarChart()
        title = (partname, )
        pre_graph_text = self.create_stats(part)
        footer = self.create_details_text(part)
        maximum = part["total"]
        current = part["used"]
        post_graph_text = create_usage_warning(part['percent'], 80, 60)

        ch.chart(
            post_graph_text=post_graph_text,
            title=title[0],
            pre_graph_text=pre_graph_text,
            footer=footer,
            maximum=maximum,
            current=current,
        )
        print()