~feng-kylin/youker-assistant/youker-assistant

« back to all changes in this revision

Viewing changes to backends/kylin-assistant-daemon/src/cleaner/softwareconfigfile.py

  • Committer: lixiang
  • Date: 2018-03-06 03:13:06 UTC
  • Revision ID: lixiang@kylinos.cn-20180306031306-fd7qnru3vm4a1xjd
Rewrite with Qt5, and add system monitor

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
# -*- coding: utf-8 -*-
 
3
### BEGIN LICENSE
 
4
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License version 3, as published
 
7
# by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License along
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
### END LICENSE
 
17
 
 
18
import subprocess
 
19
 
 
20
from . import common
 
21
 
 
22
class SoftwareConfigfile():
 
23
    def __init__(self):
 
24
        pass
 
25
 
 
26
    def scan_configfile_packages(self):
 
27
        cache = common.get_cache_list()
 
28
        final_softwareconfigfile_list = []
 
29
 
 
30
        status, output = subprocess.getstatusoutput('dpkg -l')
 
31
        result = [(line.split()[1]).split(':')[0] for line in output.split('\n') if line.startswith('rc')]
 
32
        for one in result:
 
33
            final_softwareconfigfile_list.append(cache[one])
 
34
        return final_softwareconfigfile_list
 
35
    def get_configfile_packages(self):
 
36
        cache = common.get_cache_list()
 
37
        softwareconfigfile_list = []
 
38
 
 
39
        status, output = subprocess.getstatusoutput('dpkg -l')
 
40
        result = [(line.split()[1]).split(':')[0] for line in output.split('\n') if line.startswith('rc')]
 
41
        for one in result:
 
42
            pkg = cache[one]
 
43
            softwareconfigfile_list.append('Name:' + pkg.name + ';' + 'Summary:' + ';' + 'Size:')
 
44
        return softwareconfigfile_list
 
45
 
 
46
 
 
47
if __name__ == '__main__':
 
48
    obj = SoftwareConfigfile()
 
49
    a = obj.scan_configfile_packages()
 
50
    print(a)