Uextras-开源

  • p4_908754
    了解作者
  • 423.7KB
    文件大小
  • gz
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-08 02:53
    上传日期
一个方便的工具来管理Ubuntu。 Uextras允许管理,清理和改善您的系统性能。
uextras_0.3.3.orig.tar.gz
内容介绍
#!/usr/bin/python ## # Project: uextras - A simple tool to manage Debian systems # Author: Francesco Muriana <f.muriana@hotmail.it> # Copyright: 2010-2011 Francesco Muriana # License: GPL-2+ # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # On Debian GNU/Linux systems, the full text of the GNU General Public License # can be found in the file /usr/share/common-licenses/GPL-2. ## import os, os.path, sys, gzip import gtk, gtk.glade, pygtk, gettext from gettext import gettext as _ class ChangelogViewer(): def __init__(self): # Signals Handler signals = { 'on_winMain_delete_event': self.on_winMain_delete_event, 'on_winMain_destroy_event': self.on_winMain_destroy_event, 'on_entrySearch_changed': self.on_entrySearch_changed, 'on_cmbData_changed' : self.on_cmbData_changed, 'on_cmbPackage_changed' : self.on_cmbPackage_changed, } for module in (gettext, gtk.glade): module.bindtextdomain('uextras', '/usr/share/locale') module.textdomain('uextras') gladeUI = 'changelogViewer.glade' gladeFile = gtk.glade.XML(fname=gladeUI) gladeFile.signal_autoconnect(signals) gw = gladeFile.get_widget # Main Window self.winMain = gw('winMain') self.lblPackage = gw('lblPackage') self.cmbPackage = gw('cmbPackage') self.cmbData = gw('cmbData') self.entryView = gw('entryView') # Combo Box Results self.cmbModelPackage = gtk.ListStore(str) self.cmbModelData = gtk.ListStore(str) cellPackage = gtk.CellRendererText() cellData = gtk.CellRendererText() self.cmbPackage.pack_start(cellPackage, True) self.cmbPackage.add_attribute(cellPackage, 'text',0) self.cmbData.pack_start(cellData, True) self.cmbData.add_attribute(cellData, 'text',0) # Set Stats and Variables self.winMain.set_title(_('Changelog Viewer')) self.docPath = '/usr/share/doc' self.listInfo = [] # Text View self.bufferText = gtk.TextBuffer() self.entryView.set_buffer(self.bufferText) # Start self.winMain.show() gtk.main() def on_winMain_delete_event(self, widget, event = None): self.exit() def on_winMain_destroy_event(self, widget, event = None): self.exit() def exit(self): self.winMain.destroy() gtk.main_quit() def on_entrySearch_changed (self, widget): tempText = widget.get_text() if tempText: lastChar = tempText[-1] if not lastChar in map(chr, range(97, 123)) and not lastChar in range(1,0) and not lastChar == '-' and not lastChar == '_' and not lastChar == ' ': widget.set_text(tempText.replace(tempText[-1], '')) else: self.cmbModelPackage.clear() if len(tempText) >= 3: self.search (tempText) else: self.clearFields() def search (self, text): text = text.replace(' ', '-').lower() listDir = [] for file in os.listdir(self.docPath): if text in file: if os.path.isfile(self.docPath+'/'+file+'/changelog.Debian.gz') or os.path.isfile(self.docPath+'/'+file+'/changelog.gz'): listDir.append(file) if len(listDir) == 0: self.clearFields() else: self.lblPackage.set_text(_('Result(s)')+' ['+str(len(listDir))+']: ') for value in listDir: iter = self.cmbModelPackage.append() self.cmbModelPackage.set_value(iter, 0, value) self.cmbPackage.set_model(self.cmbModelPackage) self.cmbPackage.set_active(0) def clearFields(self): self.lblPackage.set_text(_('Result(s) [0]: ')) self.cmbModelData.clear() self.cmbModelPackage.clear() self.bufferText.set_text('') def on_cmbPackage_changed (self, widget): selection = self.cmbPackage.get_active_text() if selection: if os.path.isfile(self.docPath+'/'+selection+'/changelog.Debian.gz'): tempFile = gzip.open(self.docPath+'/'+selection+'/changelog.Debian.gz') else: tempFile = gzip.open(self.docPath+'/'+selection+'/changelog.gz') print selection+ 'has not a changelog.Debian.gz' line = tempFile.readline() key = line.split(' ')[0] listData = [] self.listInfo = [] listChanges = '' while line: while not line.startswith(key) and line: if '--' in line and '>' in line: username = line.split('-- ')[1].split(' <')[0] mail = line.split('<')[1].split('>')[0] emailInfo = {'username':username, 'mail':mail} username = '' mail = '' tempData = line.replace(' ', ' ').split('> ')[1].split(' ') count = 0 for item in tempData: if not item: tempData.pop(count) count += 1 fuse = tempData[5] if '0000' in fuse: time = tempData[4] else: tempTime = tempData[4].split(':') if fuse[0] == '-': tempTimeHour = (int(tempTime[0]) - (int(fuse[1])*10 + int(fuse[2]))) % 24 else: tempTimeHour = (int(tempTime[0]) + (int(fuse[1])*10 + int(fuse[2]))) % 24 time = str(tempTimeHour)+':'+tempTime[1]+':'+tempTime[2] data = tempData[1]+' '+tempData[2]+' '+tempData[3]+' '+time listData.append(data+' ('+header['version']+')') self.listInfo.append({'data':data, 'changes':listChanges, 'header':header, 'emailInfo':emailInfo}) else: listChanges = listChanges+'\t'+line line = tempFile.readline() if '(' in line and '(' in line: version = line.split('(')[1].split(')')[0] else: version = None if ')' in line and ';' in line: distribution = line.split(') ')[1].split(';')[0] else: distribution = None if 'urgency=' in line: urgency = line.split('=')[1].replace('\n', '') else: urgency = None header = {'version':version, 'distribution':distribution, 'urgency':urgency} version = '' distribution = '' urgency = '' listChanges = '' line = tempFile.readline() if len(listData) > 0: self.cmbModelData.clear() for value in listData: iter = self.cmbModelData.append() self.cmbModelData.set_value(iter, 0, value) self.cmbData.set_model(self.cmbModelData) self.cmbData.set_active(0) def on_cmbData_changed (self, widget): selectedData = self.cmbData.get_active_text() if selected
评论
    相关推荐
    • ubuntu主题
      ubuntu 主题,12.04
    • ubuntu卸载
      提供ubuntu 卸载的方法 十分简单卸载干净
    • Ubuntu Wubi
      Ubuntu Wubi简化Ubuntu安装过程
    • ubuntu PPS
      ubuntu PPS ubuntu PPS
    • ubuntu
      ubuntu
    • ubuntu netkeeper
      ubuntu netkeeper 只要在xkin文档上输入相应的帐号和密码就可以链接外网。好用。
    • ubuntu apktool
      ubuntu apktool 反编译工具。解压后把 aapt apktool apktool.jar /usr/bin/目录下即可。 apktool d xxx.apk
    • ubuntu入门
      ubuntu入门介绍,基本操作以及开发环境等
    • Ubuntu Server
      包含:ubuntu server最佳方案.pdf Ubuntu10.04下安装gcc4.1_g++4.1.pdf Ubuntu软件安装方法完全指南.doc 完美应用Ubuntu.pdf
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档