def __init__(self): Clip.__init__(self) cpumodel = _('Unknown') if os.uname()[4][0:3] == "ppc": for element in file("/proc/cpuinfo"): if element.split(":")[0][0:3] == "cpu": cpumodel = element.split(":")[1].strip() else: for element in file("/proc/cpuinfo"): if element.split(":")[0] == "model name\t": cpumodel = element.split(":")[1].strip() for element in file("/proc/meminfo"): if element.split(" ")[0] == "MemTotal:": raminfo = element.split(" ")[-2] self.table = EasyTable(items=( (Gtk.Label(label=_('CPU:')), Gtk.Label(label=cpumodel)), (Gtk.Label(label=_('Memory:')), Gtk.Label(label=GLib.format_size_for_display(int(raminfo) * 1024))), ), xpadding=12, ypadding=2) self.add_content(self.table) self.show_all()
def __init__(self): Clip.__init__(self) cache_number = len(glob.glob('/var/cache/apt/archives/*.deb')) if cache_number: self.set_title(_('Some cache can be cleaned to free your disk space')) label = Gtk.Label(label=_('%s cache packages can be cleaned.') % cache_number) label.set_alignment(0, 0.5) self.add_content(label) try: size = int(os.popen('du -bs ~/.thumbnails').read().split()[0]) except: size = 0 if size: label = Gtk.Label(label=_('%s thumbnails cache can be cleaned.') % \ GLib.format_size_for_display(size)) label.set_alignment(0, 0.5) self.add_content(label) button = Gtk.Button(label=_('Start Janitor')) button.connect('clicked', self.on_button_clicked) self.add_action_button(button) self.show_all()
def _enum_dir_cb(self, fileenum, result, parent): files = fileenum.next_files_finish(result) if files is None or len(files) == 0: return for f in files: name = f.get_attribute_string(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME) path = parent.get_path() + '/' + name t = f.get_attribute_uint32(Gio.FILE_ATTRIBUTE_STANDARD_TYPE) if t == Gio.FileType.DIRECTORY: self._recursive_read(path) else: mime = f.get_attribute_string(Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE) if mime in self.valid_mimetypes: try: pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) if pixbuf is not None: width = pixbuf.get_width() height = pixbuf.get_height() resolution = "%dx%d" % (width, height) size = GLib.format_size_for_display(f.get_attribute_uint64(Gio.FILE_ATTRIBUTE_STANDARD_SIZE)) button = self._scale_image(pixbuf) button.show_all() button.connect('button_press_event', self._item_selected, [path[len(self.mainpath):], size, resolution]) except: print("Error loading %s" % path) self.stop_action = Gio.Cancellable() fileenum.next_files_async(10, GLib.PRIORITY_DEFAULT, self.stop_action, self._enum_dir_cb, parent)
def get_hardwareinfo(self): # CPU with open('/proc/cpuinfo') as f: for line in f: if line.strip(): if line.rstrip('\n').startswith('model name'): model_name = line.rstrip('\n').split(':')[1] # Memory with open('/proc/meminfo') as f: for line in f: if line.strip(): if line.rstrip('\n').startswith('MemTotal'): MemTotal = line.rstrip('\n').split(':')[1] MemTotal1 = MemTotal.split(' ')[8] MemTotal2 = GLib.format_size_for_display(int(MemTotal1) * 1024) return model_name,MemTotal2
def get_hardwareinfo(self): # CPU with open('/proc/cpuinfo') as f: for line in f: if line.strip(): if line.rstrip('\n').startswith('model name'): model_name = line.rstrip('\n').split(':')[1] # Memory with open('/proc/meminfo') as f: for line in f: if line.strip(): if line.rstrip('\n').startswith('MemTotal'): MemTotal = line.rstrip('\n').split(':')[1] MemTotal1 = MemTotal.split(' ')[8] MemTotal2 = GLib.format_size_for_display( int(MemTotal1) * 1024) return model_name, MemTotal2
def _enum_dir_cb(self, fileenum, result, parent): files = fileenum.next_files_finish(result) if files is None or len(files) == 0: return for f in files: name = f.get_attribute_string( Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME) path = parent.get_path() + '/' + name t = f.get_attribute_uint32(Gio.FILE_ATTRIBUTE_STANDARD_TYPE) if t == Gio.FileType.DIRECTORY: self._recursive_read(path) else: mime = f.get_attribute_string( Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE) if mime in self.valid_mimetypes: try: pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) if pixbuf is not None: width = pixbuf.get_width() height = pixbuf.get_height() resolution = "%dx%d" % (width, height) size = GLib.format_size_for_display( f.get_attribute_uint64( Gio.FILE_ATTRIBUTE_STANDARD_SIZE)) button = self._scale_image(pixbuf) button.show_all() button.connect( 'button_press_event', self._item_selected, [path[len(self.mainpath):], size, resolution]) except: print("Error loading %s" % path) self.stop_action = Gio.Cancellable() fileenum.next_files_async(10, GLib.PRIORITY_DEFAULT, self.stop_action, self._enum_dir_cb, parent)