Skip to content

Commit

Permalink
fix and #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
atareao committed Sep 8, 2024
1 parent 0c28a95 commit 1ee9efa
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 57 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Depends: ${misc:Depends}, ${python:Depends},
python3-cairocffi,
gir1.2-gtk-3.0,
gir1.2-gdkpixbuf-2.0,
glxinfo,
wmctrl,
mesa-utils
Description: CPU-G shows useful information about your computer
Expand Down
50 changes: 25 additions & 25 deletions src/cpug.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import datetime
import sys
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as\
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as \
FigureCanvas
import matplotlib.ticker as ticker
from investigator import Investigator
Expand All @@ -49,7 +49,7 @@


class CPUG(Gtk.Window):
"""Description"""

def __init__(self):
Gtk.Window.__init__(self)
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
Expand Down Expand Up @@ -1054,45 +1054,45 @@ def get_battery_duration(self):
self.battery_data2.set_text('--')
current_level = bd.get_percentage()
self.battery_level_value.set_text(
locale.format('%.2f', current_level) + _(' %'))
locale.format_string('%.2f', current_level) + _(' %'))
self.battery_level.set_value(current_level)
inv = Investigator()
self.battery_capacity_level.set_text(
'%s' % inv.battery_info('capacity-level'))
self._aux_set_text(
self.battery_voltage_now,
inv.battery_info('voltage-now'),
locale.format(
locale.format_string(
'%.2f',
inv.battery_info('voltage-now')/1000000) + _(' V'))
self._aux_set_text(
self.battery_min_voltage_design,
inv.battery_info('voltage-min-design'),
locale.format(
locale.format_string(
'%.2f',
inv.battery_info('voltage-min-design')/1000000) + _(' V'))
self._aux_set_text(
self.battery_charge_now,
inv.battery_info('charge-now'),
locale.format(
locale.format_string(
'%.2f',
inv.battery_info('charge-now')/1000000) + _(' Ah'))
self._aux_set_text(
self.battery_charge_full,
inv.battery_info('charge-full'),
locale.format(
locale.format_string(
'%.2f',
inv.battery_info('charge-full')/1000000) + _(' Ah'))
self._aux_set_text(
self.battery_charge_full_design,
inv.battery_info('charge-full-design'),
locale.format(
locale.format_string(
'%.2f',
inv.battery_info('charge-full-design')/1000000) + _(' Ah'))
self._aux_set_text(
self.battery_current_now,
inv.battery_info('current-now'),
locale.format(
locale.format_string(
'%.2f',
inv.battery_info('current-now')/1000000) + _(' A'))
return True
Expand All @@ -1104,40 +1104,40 @@ def uptime_update(self):
def ram_update(self):
values = Investigator().raminfo()
self.ram_total.set_text(
locale.format('%.1f', values['total'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['total'], True) + ' ' + _('MB'))
self.ram_available.set_text(
locale.format('%.1f', values['available'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['available'], True) + ' ' + _('MB'))
self.ram_available_progress.set_value(
values['available']/values['total'])
self.ram_used.set_text(
locale.format('%.1f', values['used'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['used'], True) + ' ' + _('MB'))
self.ram_used_progress.set_value(values['used']/values['total'])
self.ram_free.set_text(
locale.format('%.1f', values['free'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['free'], True) + ' ' + _('MB'))
self.ram_free_progress.set_value(values['free']/values['total'])
self.ram_active.set_text(
locale.format('%.1f', values['active'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['active'], True) + ' ' + _('MB'))
self.ram_inactive.set_text(
locale.format('%.1f', values['inactive'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['inactive'], True) + ' ' + _('MB'))
self.ram_buffers.set_text(
locale.format('%.1f', values['buffers'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['buffers'], True) + ' ' + _('MB'))
self.ram_cached.set_text(
locale.format('%.1f', values['cached'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['cached'], True) + ' ' + _('MB'))
values = Investigator().swapinfo()
self.swap_total.set_text(
locale.format('%.1f', values['total'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['total'], True) + ' ' + _('MB'))
if values['total'] == 0:
values['total'] = 1
self.swap_used.set_text(
locale.format('%.1f', values['used'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['used'], True) + ' ' + _('MB'))
self.swap_used_progress.set_value(values['used']/values['total'])
self.swap_free.set_text(
locale.format('%.1f', values['free'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['free'], True) + ' ' + _('MB'))
self.swap_free_progress.set_value(values['free']/values['total'])
self.swap_sin.set_text(
locale.format('%.1f', values['sin'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['sin'], True) + ' ' + _('MB'))
self.swap_sout.set_text(
locale.format('%.1f', values['sout'], True) + ' ' + _('MB'))
locale.format_string('%.1f', values['sout'], True) + ' ' + _('MB'))
return True

def close_application(self, widget):
Expand Down Expand Up @@ -1266,7 +1266,7 @@ def update_info(self):
xoptions=Gtk.AttachOptions.FILL,
yoptions=Gtk.AttachOptions.FILL,
xpadding=5, ypadding=5)
entry.set_text(locale.format(
entry.set_text(locale.format_string(
'%.2f', device['total']/1024/1024, True) + ' ' + _('MB'))
label = Gtk.Label(_('Used space'))
label.set_alignment(0, 0.5)
Expand All @@ -1279,7 +1279,7 @@ def update_info(self):
xoptions=Gtk.AttachOptions.FILL,
yoptions=Gtk.AttachOptions.FILL,
xpadding=5, ypadding=5)
entry.set_text(locale.format(
entry.set_text(locale.format_string(
'%.2f', device['used']/1024/1024, True) + ' ' + _('MB'))
disk_used_progress = Gtk.LevelBar()
disk_used_progress.set_min_value(0)
Expand All @@ -1300,7 +1300,7 @@ def update_info(self):
xoptions=Gtk.AttachOptions.FILL,
yoptions=Gtk.AttachOptions.FILL,
xpadding=5, ypadding=5)
entry.set_text(locale.format(
entry.set_text(locale.format_string(
'%.2f', device['free']/1024/1024, True) + ' ' + _('MB'))
disk_free_progress = Gtk.LevelBar()
disk_free_progress.set_min_value(0)
Expand Down
64 changes: 32 additions & 32 deletions src/investigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,38 +154,38 @@ def logo(self, core):
elif vendor == 'Zhaoxin':
label = 'zhaoxin.png'
# AMDs
if re.match("AMD Athlon\(tm\) 64 X2.*", model)\
or re.match("AMD Athlon\(tm\) X2.*", model):
if re.match(r"AMD Athlon\(tm\) 64 X2.*", model)\
or re.match(r"AMD Athlon\(tm\) X2.*", model):
label = 'AMD-AthlonX2.png'
elif re.match("AMD Sempron\(tm\).*", model):
elif re.match(r"AMD Sempron\(tm\).*", model):
label = 'AMD-Sempron.png'
elif re.match("Mobile AMD Sempron\(tm\).*", model):
elif re.match(r"Mobile AMD Sempron\(tm\).*", model):
label = 'AMD-Sempron-Mobile.png'
elif re.match("Dual-Core AMD Opteron\(tm\).*", model)\
or re.match("AMD Opteron\(tm\).*", model):
elif re.match(r"Dual-Core AMD Opteron\(tm\).*", model)\
or re.match(r"AMD Opteron\(tm\).*", model):
label = 'AMD-Opteron.png'
elif re.match("AMD Athlon\(tm\) XP.*", model):
elif re.match(r"AMD Athlon\(tm\) XP.*", model):
label = 'AMD-AthlonXP.png'
elif re.match("AMD Athlon\(tm\) 64 Processor.*", model):
elif re.match(r"AMD Athlon\(tm\) 64 Processor.*", model):
label = 'AMD-Athlon64.png'
elif re.match("AMD Phenom\(tm\).*", model):
elif re.match(r"AMD Phenom\(tm\).*", model):
label = 'AMD-Phenom.png'
# Intels
elif re.match("Intel\(R\) Core\(TM\)2 Duo.*", model):
elif re.match(r"Intel\(R\) Core\(TM\)2 Duo.*", model):
label = 'Intel-Core2Duo.png'
elif re.match("Intel\(R\) Core\(TM\)2 Quad.*", model):
elif re.match(r"Intel\(R\) Core\(TM\)2 Quad.*", model):
label = 'Intel-Core2Quad.png'
elif re.match("Intel\(R\) Core\(TM\)2 CPU.*", model):
elif re.match(r"Intel\(R\) Core\(TM\)2 CPU.*", model):
label = 'Intel-Core2Quad.png'
elif re.match("Intel\(R\) Atom\(TM\) CPU.*", model):
elif re.match(r"Intel\(R\) Atom\(TM\) CPU.*", model):
label = 'Intel-Atom.png'
elif re.match("Intel\(R\) Core\(TM\)2 Extreme CPU.*", model):
elif re.match(r"Intel\(R\) Core\(TM\)2 Extreme CPU.*", model):
label = 'Intel-Core2Extreme.png'
elif re.match("Intel\(R\) Xeon\(TM\).*", model):
elif re.match(r"Intel\(R\) Xeon\(TM\).*", model):
label = 'Intel-Xeon.png'
elif re.match(".*Pentium II.*", model):
elif re.match(r".*Pentium II.*", model):
label = 'Intel-Pentium2.png'
elif re.match("Intel\(R\) Pentium\(R\) Dual CPU.*", model):
elif re.match(r"Intel\(R\) Pentium\(R\) Dual CPU.*", model):
label = 'Intel-PentiumDual.png'
return label

Expand Down Expand Up @@ -244,7 +244,7 @@ def cpuinfo(self, var, core=0):
info = self.readfile("/proc/cpuinfo")

if var == 'vendor':
vendor = re.findall("vendor_id\s*:\s*(.*)", info)
vendor = re.findall(r"vendor_id\s*:\s*(.*)", info)
if vendor[core] == 'AuthenticAMD':
vendor[core] = 'AMD'
elif vendor[core] == 'GenuineIntel':
Expand All @@ -253,26 +253,26 @@ def cpuinfo(self, var, core=0):
vendor[core] = 'Zhaoxin'
return vendor[core]
elif var == 'corespeed':
return re.findall("cpu MHz\s*:\s*(.*)", info)[core] + ' MHz'
return re.findall(r"cpu MHz\s*:\s*(.*)", info)[core] + ' MHz'
elif var == 'model':
return re.findall("model name\s*:\s*(.*)", info)[core]
return re.findall(r"model name\s*:\s*(.*)", info)[core]
elif var == 'cache':
return re.findall("cache size\s*:\s*(.*)", info)[core]
return re.findall(r"cache size\s*:\s*(.*)", info)[core]
elif var == 'modelnumber':
return re.findall("model\s*:\s*(.*)", info)[core]
return re.findall(r"model\s*:\s*(.*)", info)[core]
elif var == 'family':
return re.findall("cpu family\s*:\s*(.*)", info)[core]
return re.findall(r"cpu family\s*:\s*(.*)", info)[core]
elif var == 'stepping':
return re.findall("stepping\s*:\s*(.*)", info)[core]
return re.findall(r"stepping\s*:\s*(.*)", info)[core]
elif var == 'coresnum':
return str(len(re.findall("processor\s*:\s*(.*)", info)))
return str(len(re.findall(r"processor\s*:\s*(.*)", info)))
elif var == 'flags':
return re.findall("flags\s*:\s*(.*)", info)[core]
return re.findall(r"flags\s*:\s*(.*)", info)[core]
elif var == 'bogomips':
return re.findall("bogomips\s*:\s*(.*)", info)[core]
return re.findall(r"bogomips\s*:\s*(.*)", info)[core]
elif var == 'width':
if re.findall(' lm(?![-a-zA-Z0-9_])',
re.findall("flags\s*:(.*)", info)[core]):
re.findall(r"flags\s*:(.*)", info)[core]):
width = '64-bit'
else:
width = '32-bit'
Expand Down Expand Up @@ -391,19 +391,19 @@ def get_graphic_card_logo(self):
card_logo = self.execute('/usr/bin/lspci', 'VGA(.*)')
if card_logo is not None:
# Intel
if re.findall("Intel\s*", card_logo):
if re.findall(r"Intel\s*", card_logo):
label = 'intel.png'
# ATI
# ATI Technologies replace to ATI. See bug
# https://bugs.launchpad.net/cpug/+bug/959115
elif re.findall("ATI\s*", card_logo):
elif re.findall(r"ATI\s*", card_logo):
label = 'ati.png'
# Zhaoxin
elif re.findall("Zhaoxin\s*", card_logo):
elif re.findall(r"Zhaoxin\s*", card_logo):
label = 'zhaoxin.png'
# nVidia
# elif re.findall("nVidia\s*", card_logo):
elif re.findall("nVidia\s*", card_logo, re.I):
elif re.findall(r"nVidia\s*", card_logo, re.I):
label = 'nvidia.png'
else:
label = 'unknown.png'
Expand Down

0 comments on commit 1ee9efa

Please sign in to comment.