update python2 to python3

This commit is contained in:
smiley286 2018-01-04 09:55:16 +08:00
parent fb42218642
commit 66ec917f29
63 changed files with 294 additions and 426 deletions

View File

@ -1,7 +1,7 @@
TEMPLATE = aux
inst1.files += ../backends/kylin-assistant-daemon/src/
inst1.path = /usr/lib/python2.7/dist-packages/kylin-assistant-daemon/
inst1.path = /usr/lib/python3/dist-packages/kylin-assistant-daemon/
inst2.files += ../backends/kylin-assistant-daemon/data/beautify/autostart/
inst2.path = /var/lib/kylin-assistant-daemon/
inst3.files += ../backends/kylin-assistant-daemon/data/beautify/plymouth/

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -124,7 +124,7 @@ if __name__ == "__main__":
# print mmm.get_used_memory("g")
# print mmm.get_total_memory("g")
# mmm.ttestt()
print mmm.get_memory_percent()
print mmm.get_total_memory()
print mmm.get_used_memory()
print mmm.get_free_memory()
print(mmm.get_memory_percent())
print(mmm.get_total_memory())
print(mmm.get_used_memory())
print(mmm.get_free_memory())

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -18,7 +18,7 @@
import os
import ConfigParser
import configparser
import copy
import shutil
from pprint import pprint
@ -31,10 +31,10 @@ OPTION_O = 'OnlyShowIn'
OPTION_NOT = 'NotShowIn'
OPTION_X = 'X-GNOME-Autostart-enabled'
class MyConfigParser(ConfigParser.ConfigParser):
class MyConfigParser(configparser.ConfigParser):
def __inin__(self, defaults=None):
ConfigParser.ConfigParser.__init__(self, defaults=None)
configparser.ConfigParser.__init__(self, defaults=None)
def optionxform(self, optionstr):
return optionstr
@ -175,7 +175,7 @@ class Desktop_Autostart_Manage():
notautostart_1_list = self.dic.get('notautostart', [])
if notautostart_1_list:
#backup_list = copy.deepcopy(notautostart_list)
new_notautostart_list = filter(lambda x: not x.count(single.split("/")[-1]), notautostart_1_list)
new_notautostart_list = [x for x in notautostart_1_list if not x.count(single.split("/")[-1])]
self.dic['notautostart'] = new_notautostart_list
self.dic.setdefault(OPTION_H, []).append(single)
@ -187,7 +187,7 @@ class Desktop_Autostart_Manage():
notautostart_2_list = self.dic.get('notautostart', [])
if notautostart_2_list:
#backup_list = copy.deepcopy(notautostart_list)
new_notautostart_2_list = filter(lambda x: not x.count(single.split("/")[-1]), notautostart_2_list)
new_notautostart_2_list = [x for x in notautostart_2_list if not x.count(single.split("/")[-1])]
self.dic['notautostart'] = new_notautostart_2_list
self.dic.setdefault('autostart', []).append(single)
@ -199,7 +199,7 @@ class Desktop_Autostart_Manage():
notautostart_3_list = self.dic.get('notautostart', [])
if notautostart_3_list:
#backup_list = copy.deepcopy(notautostart_list)
new_notautostart_3_list = filter(lambda x: not x.count(single.split("/")[-1]), notautostart_3_list)
new_notautostart_3_list = [x for x in notautostart_3_list if not x.count(single.split("/")[-1])]
self.dic['notautostart'] = new_notautostart_3_list
self.dic.setdefault('notautostart', []).append(single)
@ -344,7 +344,7 @@ def interface_get_status(fobj):
down_list.append('Status:' + 'false')
fobj.autostartmanage_data_signal(down_list)
except Exception, e:
except Exception as e:
fobj.autostartmanage_error_signal(str(e))
else:
fobj.autostartmanage_status_signal("complete")
@ -363,7 +363,7 @@ def interface_change_status(fobj, filename):
try:
obj = Desktop_Autostart_Manage()
obj.change_single_status(filename)
except Exception, e:
except Exception as e:
fobj.autostartmanage_error_signal(str(e))
# else:
# fobj.autostartmanage_status_signal("complete")

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -22,8 +22,8 @@
from gi.repository import Gtk
from Constants import *
from Utils import *
from .Constants import *
from .Utils import *
import locale
import gettext
@ -225,7 +225,7 @@ class FeatureRequirement(Conflict):
self.Feature = feature
self.Found = False
for plugin in context.Plugins.values():
for plugin in list(context.Plugins.values()):
if feature in plugin.Features:
self.Found = True
if not plugin.Enabled:

View File

@ -25,7 +25,7 @@ import weakref
from gi.repository import GObject, Gtk, Gdk, Pango
from Constants import *
from .Constants import *
from cgi import escape as protect_pango_markup
import operator
import itertools
@ -59,7 +59,7 @@ def getDefaultScreen():
return display.get_default_screen().get_number()
def protect_markup_dict (dict_):
return dict((k, protect_pango_markup (v)) for (k, v) in dict_.items())
return dict((k, protect_pango_markup (v)) for (k, v) in list(dict_.items()))
class Image (Gtk.Image):
@ -173,7 +173,7 @@ class PrettyButton (Gtk.Button):
def update_state_out (self, *args):
state = args[-1]
self.states[state] = False
if True in self.states.values ():
if True in list(self.states.values ()):
self.set_state (Gtk.StateType.PRELIGHT)
else:
self.set_state (Gtk.StateType.NORMAL)
@ -224,7 +224,7 @@ class IdleSettingsParser:
self.Context = context
self.Main = main
self.PluginList = [p for p in self.Context.Plugins.items() if FilterPlugin(p[1])]
self.PluginList = [p for p in list(self.Context.Plugins.items()) if FilterPlugin(p[1])]
nCategories = len (main.MainPage.RightWidget._boxes)
self.CategoryLoadIconsList = list(range(3, nCategories)) # Skip the first 3
print('Loading icons...')
@ -390,9 +390,9 @@ def GetSettings(group, types=None):
yield setting
if types:
screen = TypeFilter(iter(group.Screen.values()), types)
screen = TypeFilter(iter(list(group.Screen.values())), types)
else:
screen = iter(group.Screen.values())
screen = iter(list(group.Screen.values()))
return screen

View File

@ -1,3 +1,3 @@
from Conflicts import *
from Constants import *
from Utils import *
from .Conflicts import *
from .Constants import *
from .Utils import *

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd
@ -15,16 +15,16 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
import ConfigParser
import configparser
import os, sys
import threading
import gsettings
from . import gsettings
from shutil import copy
class CloudConfig(threading.Thread):
def __init__(self, sysdaemon):
self.sysdaemon = sysdaemon
self.conf = ConfigParser.ConfigParser()
self.conf = configparser.ConfigParser()
self.home = os.path.expandvars('$HOME')
self.youker_path = './'
self.kuaipan_path = ''
@ -527,7 +527,7 @@ class CloudConfig(threading.Thread):
# Restore the system configuration
def use_cloud_configuration(self, file_name):
print file_name
print(file_name)
self.conf.read(file_name)
sections = self.conf.sections()
for conf_id in sections:
@ -536,7 +536,7 @@ class CloudConfig(threading.Thread):
# Get kuaipan directory address
def get_kuaipan_path(self):
kpconf = ConfigParser.ConfigParser()
kpconf = configparser.ConfigParser()
kpconf.read(self.home + '/.config/ubuntukylin/kuaipan4uk.conf')
return kpconf.get('client-info', 'Root')

View File

@ -19,7 +19,7 @@
import glob
import logging
import ConfigParser
import configparser
from lxml import etree
@ -62,7 +62,7 @@ class RawConfigSetting(object):
return value
def init_configparser(self):
self._configparser = ConfigParser.ConfigParser()
self._configparser = configparser.ConfigParser()
self._configparser.read(self._path)
def sections(self):
@ -118,7 +118,7 @@ class Schema(object):
cls.cached_override[section] = {}
for option in cs.options(section):
cls.cached_override[section][option] = cs.get_value(section, option)
except Exception, e:
except Exception as e:
log.error('Error while parsing override file: %s' % override)
@classmethod
@ -163,7 +163,7 @@ class Schema(object):
@classmethod
def parse_value(cls, key_node):
log.debug("Try to get type for value: %s" % key_node.items())
log.debug("Try to get type for value: %s" % list(key_node.items()))
value = key_node.find('default').text
#TODO enum type

View File

@ -19,7 +19,7 @@
import logging
import ccm
from . import ccm
import compizconfig
log = logging.getLogger('CompizSetting')
@ -65,8 +65,8 @@ class CompizPlugin:
@classmethod
def is_available(cls, name, setting):
return cls.context.Plugins.has_key(name) and \
cls.context.Plugins[name].Screen.has_key(setting)
return name in cls.context.Plugins and \
setting in cls.context.Plugins[name].Screen
def create_setting(self, key, target):
settings = self._plugin.Screen

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -17,7 +17,7 @@
### END LICENSE
import os
import gsettings
from . import gsettings
class Desktop:
desktop = None

View File

@ -21,7 +21,7 @@
### END LICENSE
import os
import gsettings
from . import gsettings
class FileManager:

View File

@ -21,7 +21,7 @@
### END LICENSE
import os
from settings import Settings
from .settings import Settings
import types
class GeditManager:
@ -48,16 +48,16 @@ class GeditManager:
# default = off
# Get: Auto detect text encoding for Simplified Chinese in Gedit
def get_detect_chinese_encoding(self):
return self.settings.get_value("auto-detected", types.ListType)
return self.settings.get_value("auto-detected", list)
# Set: Auto detect text encoding for Simplified Chinese in Gedit
def set_detect_chinese_encoding(self, flag):
list_on = ['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']
list_off = ['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']
if(flag):
self.settings.set_value("auto-detected", types.ListType, list_off)
self.settings.set_value("auto-detected", list, list_off)
else:
self.settings.set_value("auto-detected", types.ListType, list_on)
self.settings.set_value("auto-detected", list, list_on)
# Get Default Value: Auto detect text encoding for Simplified Chinese in Gedit
@ -89,4 +89,4 @@ if __name__ == '__main__':
#aa = gm.get_default_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected")
#print aa
gm.set_default_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected", types.ListType)
gm.set_default_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected", list)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -17,7 +17,7 @@
### END LICENSE
from gi.repository import Gio as gio
from common import Schema
from .common import Schema
import logging
logger=logging.getLogger('kylin-assistant-daemon')

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -16,10 +16,15 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
import sys
sys.path.append('/usr/lib/python3/dist-packages/PIL') ## add by hb for python3
import os
import re
import shutil
import Image
# from _pyio import open
class Others:

View File

@ -24,7 +24,7 @@
from gi.repository import Gio as gio
import os, sys
import types
from common import Schema
from .common import Schema
#http://lazka.github.io/pgi-docs/api/Gio_2.0/classes/Settings.html
@ -44,32 +44,32 @@ class Settings:
try:
setting_type = type
get_func = {
types.IntType: self.db.get_int,
types.StringType: self.db.get_string,
types.BooleanType: self.db.get_boolean,
types.ListType: self.db.get_strv,
types.DictType: self.db.get_string,
types.NoneType: self.db.get_value,
int: self.db.get_int,
bytes: self.db.get_string,
bool: self.db.get_boolean,
list: self.db.get_strv,
dict: self.db.get_string,
type(None): self.db.get_value,
}[setting_type]
return get_func(key)
except Exception as e:
print e
print(e)
return None
def set_value(self, key, type, value):
try:
setting_type = type
set_func = {
types.IntType: self.db.set_int,
types.StringType: self.db.set_string,
types.BooleanType: self.db.set_boolean,
types.ListType: self.db.set_strv,
types.DictType: self.db.set_string,
types.NoneType: self.db.set_value,
int: self.db.set_int,
bytes: self.db.set_string,
bool: self.db.set_boolean,
list: self.db.set_strv,
dict: self.db.set_string,
type(None): self.db.set_value,
}[setting_type]
set_func(key, value)
except Exception as e:
print e
print(e)
def get_schema_value(self, schema, key):
schema_default = Schema.load_schema(schema, key)
@ -108,8 +108,8 @@ if __name__ == '__main__':
#print value
default_value = settings.get_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected")
print "default_value->"
print default_value
print("default_value->")
print(default_value)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -18,8 +18,8 @@
import os
import shutil
import gsettings
import utils
from . import gsettings
from . import utils
class Sound:
homedir = ''
@ -218,5 +218,5 @@ if __name__ == '__main__':
# sss.set_login_music_enable(False)
# print sss.get_sound_themes()
# print sss.get_sound_theme()
print sss.get_sounds()
print(sss.get_sounds())
# sss.set_sound_theme('freedesktop')

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -17,7 +17,7 @@
### END LICENSE
import os
import gsettings
from . import gsettings
import platform
from gi.repository import Gio as gio

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -17,8 +17,8 @@
### END LICENSE
import os
import gsettings
import utils
from . import gsettings
from . import utils
class Theme:
homedir = ''
@ -173,7 +173,7 @@ class Theme:
fd.write('Inherits=' + theme + '\n')
fd.close()
return True
except Exception,e :
except Exception as e :
return False
# get cursor size
@ -408,9 +408,9 @@ if __name__ == '__main__':
#print bb
aa = ttt.get_default_schema_value('org.gnome.desktop.interface', 'cursor-size')
print aa
print(aa)
bb = ttt.get_cursor_size()
print bb
print(bb)
ttt.set_default_schema_value('org.gnome.desktop.interface', 'cursor-size', 'int')
#aa = ttt.get_default_schema_value('org.gnome.desktop.interface', 'font-name')

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -17,8 +17,8 @@
### END LICENSE
import os
import gsettings
from compizsettings import CompizSetting
from . import gsettings
#from .compizsettings import CompizSetting
class Unity:
'''if compiz: key is icon_size; else if gsettins: key is icon-size'''
@ -33,9 +33,9 @@ class Unity:
# ---------------launcher---------------
# -----------------默认值-----------------
# Get Default Value
def get_default_schema_value(self, name, key):
compizsetting = CompizSetting("%s.%s" % (name, key))
return compizsetting.get_schema_value()
#def get_default_schema_value(self, name, key):
# compizsetting = CompizSetting("%s.%s" % (name, key))
# return compizsetting.get_schema_value()
# Set Default Value min=32, max=64, step=16, key="unityshell.icon_size"
#def set_default_schema_value(self, key, name, type, value):
@ -67,7 +67,7 @@ class Unity:
return True
else:
return None
except Exception, e:
except Exception as e:
return False
# launcher icon size 32-64
@ -83,7 +83,7 @@ class Unity:
return gsettings.get('org.compiz.unityshell',
'/org/compiz/profiles/unity/plugins/unityshell/',
'icon-size', 'int')
except Exception, e:
except Exception as e:
return 0
# launcher 'show desktop' icon True/False
@ -125,7 +125,7 @@ class Unity:
return gsettings.get('org.compiz.unityshell',
'/org/compiz/profiles/unity/plugins/unityshell/',
'launcher-opacity', 'double')
except Exception, e:
except Exception as e:
return 0.0
# 'min' : 0.2, # TODO : Check these min max. Most prolly wrong.
@ -147,7 +147,7 @@ class Unity:
return gsettings.get('org.compiz.unityshell',
'/org/compiz/profiles/unity/plugins/unityshell/',
'backlight-mode', 'int')
except Exception, e:
except Exception as e:
return 0
# 'map' : {0:0,1:1,2:2,3:3,4:4} 0:所有程序1:仅打开的应用程序2:不着色3:边缘着色4:每个工作区交替着色
@ -178,7 +178,7 @@ class Unity:
return gsettings.get('org.compiz.unityshell',
'/org/compiz/profiles/unity/plugins/unityshell/',
'dash-blur-experimental', 'int')
except Exception, e:
except Exception as e:
return 0
# 活动模糊smart: 2 静态模糊static:1 非模糊0
@ -194,7 +194,7 @@ class Unity:
return gsettings.get('org.compiz.unityshell',
'/org/compiz/profiles/unity/plugins/unityshell/',
'panel-opacity', 'double')
except Exception, e:
except Exception as e:
return 0.0
# 'min' : 0.2, # TODO : Check these min max. Most prolly wrong.
@ -421,7 +421,7 @@ if __name__ == '__main__':
uuu = Unity()
# print uuu.get_launcher_icon_colouring()
# print uuu.set_launcher_icon_colouring(1)
print uuu.get_time_format()
print(uuu.get_time_format())
# bb = uuu.get_default_schema_value("unityshell", "icon_size")
# aa = uuu.get_default_schema_value("unityshell", "launcher_hide_mode")
#aa = uuu.get_default_schema_value('org.gnome.desktop.media-handling', 'automount')

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -66,7 +66,7 @@ class Capture(threading.Thread):
if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
self.cam.stop()
pic_name = get_local_format_time() + '.png'
print pic_name
print(pic_name)
going = False
if self.cam.query_image():
self.snapshot = self.cam.get_image(self.snapshot)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -20,22 +20,22 @@ import sys
import apt
import apt_pkg
import shutil
import commands
import subprocess
import threading
import ctypes
from apt.progress.base import InstallProgress
import time
import historyclean
import cookiesclean
import searchsame
import diskanalyse
import osslim
import common
import cacheclean
import oldkernel
import systemhistory
import dashhistory
import softwareconfigfile
from . import historyclean
from . import cookiesclean
from . import searchsame
from . import diskanalyse
from . import osslim
from . import common
from . import cacheclean
from . import oldkernel
from . import systemhistory
from . import dashhistory
from . import softwareconfigfile
HOMEDIR = ''
@ -150,7 +150,7 @@ class OneKeyClean():
sysdaemon.status_for_quick_clean('software_center', caches)
objclean.clean_the_file(caches)
sysdaemon.status_for_quick_clean('software_center', 'end')
except Exception, e:
except Exception as e:
sysdaemon.clean_error_onekey('ce')
else:
sysdaemon.clean_complete_onekey('c')
@ -170,7 +170,7 @@ class OneKeyClean():
filepathc = "%s/.config/chromium/Default/History" % homedir
objca.clean_chromium_all_records(filepathc)
sysdaemon.status_for_quick_clean('chromiumhistory', 'end')
except Exception, e:
except Exception as e:
sysdaemon.clean_error_onekey('he')
else:
sysdaemon.clean_complete_onekey('h')
@ -191,7 +191,7 @@ class OneKeyClean():
pamcc = [filepathcc, 'cookies', 'host_key']
objcc.clean_all_records(pamcc[0], pamcc[1], pamcc[2])
sysdaemon.status_for_quick_clean('chromiumcookies', 'end')
except Exception, e:
except Exception as e:
sysdaemon.clean_error_onekey('ke')
else:
sysdaemon.clean_complete_onekey('k')
@ -602,7 +602,7 @@ def cancel_mainpage_function(target_tid, exception):
def get_threadid(thread_obj):
found = False
target_tid = 0
for tid, tobj in threading._active.items():
for tid, tobj in list(threading._active.items()):
if tobj is thread_obj:
found = True
target_tid = tid
@ -650,8 +650,8 @@ class MainPage():
thumbnailspath = "%s/.cache/thumbnails" % homedir
try:
temp_thumbnails_list = cache_obj.public_scan_cache(thumbnailspath)
except Exception, e:
print e
except Exception as e:
print(e)
if sesdaemon:
for one in temp_thumbnails_list:
self.cache_dic['thumbnail'].append(one)
@ -661,7 +661,7 @@ class MainPage():
for one in temp_thumbnails_list:
self.cache_dic['thumbnail'].append(one)
if sesdaemon:
for key in self.cache_dic.keys():
for key in list(self.cache_dic.keys()):
if self.cache_dic[key]:
flag = True
break
@ -677,7 +677,7 @@ class MainPage():
def clean_cache(self, sysdaemon):
totalsize = 0
self.get_cache(None)
for key in self.cache_dic.keys():
for key in list(self.cache_dic.keys()):
for f in self.cache_dic[key]:
totalsize += common.get_size(f)
if os.path.isdir(f):

View File

@ -1,6 +1,6 @@
import os
from common import get_dir_size
from common import confirm_filesize_unit
from .common import get_dir_size
from .common import confirm_filesize_unit
class CacheClean():

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -16,7 +16,7 @@
### END LICENSE
import os
import ConfigParser
import configparser
import apt
import apt_pkg
import psutil
@ -37,7 +37,7 @@ def confirm_filesize_unit(size):
return finalsize
def get_dir_size(path):
size = 0L
size = 0
for root, dirs, files in os.walk(path):
size += sum([os.path.getsize(os.path.join(root, name)) for name in files])
return size
@ -81,7 +81,7 @@ def analytical_profiles_file(homedir):
app_path = '%s/.mozilla/firefox' % homedir
profiles_path = '%s/profiles.ini' % app_path
if os.path.exists(profiles_path):
cfg = ConfigParser.ConfigParser()
cfg = configparser.ConfigParser()
cfg.read(profiles_path)
complete_section = cfg.sections()
for section in complete_section:
@ -90,7 +90,7 @@ def analytical_profiles_file(homedir):
complete_option = cfg.options(section)
try:
cfg.getint(section, 'Default') == 1
except Exception, e:
except Exception as e:
pass
else:
flag_pro_section = section
@ -124,7 +124,7 @@ def get_mozilla_path(homedir):
profiles_path = '%s/profiles.ini' % app_path
if os.path.exists(profiles_path):
cfg = ConfigParser.ConfigParser()
cfg = configparser.ConfigParser()
cfg.read(profiles_path)
complete_section = cfg.sections()
for section in complete_section:
@ -133,7 +133,7 @@ def get_mozilla_path(homedir):
complete_option = cfg.options(section)
try:
cfg.getint(section, 'Default') == 1
except Exception, e:
except Exception as e:
pass
else:
flag_pro_section = section
@ -156,4 +156,4 @@ def get_mozilla_path(homedir):
return finalpath
if __name__ == '__main__':
print analytical_profiles_file('/home/aya')
print(analytical_profiles_file('/home/aya'))

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -18,7 +18,7 @@
import os.path
import sqlite3
from common import get_mozilla_path
from .common import get_mozilla_path
class CookiesClean():

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -16,7 +16,7 @@
### END LICENSE
import os
import commands
import subprocess
import sqlite3
@ -48,7 +48,7 @@ class DashHistory():
user = tmp_path.split('/')[2]
os.remove(tmp_path)
cmd = "su - %s -c 'zeitgeist-daemon --replace & >& /dev/null'" % user
(status, output) = commands.getstatusoutput(cmd)
(status, output) = subprocess.getstatusoutput(cmd)
return

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -18,7 +18,7 @@
import os
import os.path
import common
from . import common
class DiskAnalyse():
def __init__(self):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -17,8 +17,8 @@
import os.path
import sqlite3
from common import process_pid
from common import get_mozilla_path
from .common import process_pid
from .common import get_mozilla_path
class HistoryClean():
@ -37,7 +37,7 @@ class HistoryClean():
tmp = list(eachvisit)
tmp[0], tmp[-1] = str(tmp[0]), str(tmp[-1])
if not isinstance(tmp[2], unicode):
if not isinstance(tmp[2], str):
tmp[2] = str(tmp[2])
tmp_str = '<2_2>'.join(tmp)
save.append(tmp_str)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -20,7 +20,7 @@ import os
import apt_pkg
import re
import common
from . import common
class OldKernel():
def __init__(self):
@ -65,5 +65,5 @@ if __name__ == "__main__":
objo = OldKernel()
#objo.get_the_kernel()
aaa = objo.get_old_kernel()
print aaa
print(aaa)

View File

@ -3,7 +3,7 @@ import apt
import apt_pkg
from apt.progress.base import InstallProgress
import common
from . import common
class OsSlim():
def __init__(self):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -50,7 +50,7 @@ class SearchSame():
def search_by_size(self):
self.style_dic = self.reduce_the_dic(self.tmp_style_dic)
size_dic = {}
for k in self.style_dic.keys():
for k in list(self.style_dic.keys()):
for abc in self.style_dic[k]:
filesize = os.path.getsize(abc)
size_dic.setdefault(filesize, []).append(abc)
@ -59,7 +59,7 @@ class SearchSame():
def search_by_cmp(self):
final_dic = {}
size_dic = self.search_by_size()
for k in size_dic.keys():
for k in list(size_dic.keys()):
for content in size_dic[k]:
sha1sumva = self.get_file_hash(content)
final_dic.setdefault(sha1sumva, []).append(content)
@ -76,7 +76,7 @@ class SearchSame():
def adjust_the_dic(self):
final_list = []
final_dic = self.search_by_cmp()
for key in final_dic.keys():
for key in list(final_dic.keys()):
tmp_str = "<2_2>".join(final_dic[key])
final_list.append(tmp_str)
# init
@ -85,7 +85,7 @@ class SearchSame():
return final_list
def reduce_the_dic(self, tmp_dic):
for key in tmp_dic.keys():
for key in list(tmp_dic.keys()):
if len(tmp_dic[key]) < 2:
del tmp_dic[key]
return tmp_dic

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -15,9 +15,9 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
import commands
import subprocess
import common
from . import common
class SoftwareConfigfile():
def __init__(self):
@ -27,7 +27,7 @@ class SoftwareConfigfile():
cache = common.get_cache_list()
final_softwareconfigfile_list = []
status, output = commands.getstatusoutput('dpkg -l')
status, output = subprocess.getstatusoutput('dpkg -l')
result = [(line.split()[1]).split(':')[0] for line in output.split('\n') if line.startswith('rc')]
for one in result:
final_softwareconfigfile_list.append(cache[one])
@ -36,7 +36,7 @@ class SoftwareConfigfile():
cache = common.get_cache_list()
softwareconfigfile_list = []
status, output = commands.getstatusoutput('dpkg -l')
status, output = subprocess.getstatusoutput('dpkg -l')
result = [(line.split()[1]).split(':')[0] for line in output.split('\n') if line.startswith('rc')]
for one in result:
pkg = cache[one]
@ -47,4 +47,4 @@ class SoftwareConfigfile():
if __name__ == '__main__':
obj = SoftwareConfigfile()
a = obj.scan_configfile_packages()
print a
print(a)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -26,7 +26,7 @@ import struct
import math
import binascii
import platform
import commands
import subprocess
import random
from pprint import pprint
@ -256,7 +256,7 @@ class DetailInfo:
# print platform.uname()
def ctoascii(self,buf):
ch = str(buf)
ch = bytes(buf.encode('utf-8'))
asci = binascii.b2a_hex(ch)
asci = int(asci,16)
return asci
@ -272,7 +272,7 @@ class DetailInfo:
k = len(s)
i = 0
while i < len(s):
if s[i] < 32:
if self.ctoascii(s[i]) < 32:
s = s[ :i] + s[i+1: ]
i -= 1
i += 1
@ -703,10 +703,10 @@ class DetailInfo:
cpu_siblings = line.rstrip('\n').split(':')[1]
elif line.rstrip('\n').startswith('clflush size'):
clflush_size = line.rstrip('\n').split(':')[1]
clflush_size = filter(str.isdigit,clflush_size)
clflush_size = list(filter(str.isdigit,clflush_size))
elif line.rstrip('\n').startswith('cache size'):
cache_size = line.rstrip('\n').split(':')[1]
cache_size = filter(str.isdigit,cache_size)
cache_size = list(filter(str.isdigit,cache_size))
Cpu['cpu_cores'],Cpu['cpu_siblings'],Cpu['clflush_size'],Cpu['cache_size'] = cpu_cores,cpu_siblings,clflush_size,cache_size
return Cpu
@ -924,7 +924,6 @@ class DetailInfo:
p = re.compile(r'Output %s connected' % monitor)
for m in p.finditer(info): # p.finditer(info) 返回一个迭代对象,通常只会循环一次
Vga_num += 1
print(monitor)
#print info.split("EDID for output %s" % monitor)[1].split("EDID for output")[0]
#ret.setdefault("Mon_output", monitor)
ret_output += (monitor + "<1_1>")
@ -964,7 +963,7 @@ class DetailInfo:
Vga_businfo += "<1_1>"; Vga_product += "<1_1>"; Vga_vendor += "<1_1>"; Vga_Drive += "<1_1>"
status, output = commands.getstatusoutput('lspci -vvv')
status, output = subprocess.getstatusoutput('lspci -vvv')
if not status:
for local in output.split("\n\n"):
if "VGA compatible controller: " in local:
@ -976,7 +975,7 @@ class DetailInfo:
for line in local.split("\n"):
if "VGA compatible controller: " in line:
print line
print(line)
Vga_product += line.split(":")[2][:-30]
Vga_vendor += self.get_url("", line.split(":")[2])
if "Kernel driver in use: " in line:
@ -990,131 +989,6 @@ class DetailInfo:
ret["Vga_num"], ret['Vga_businfo'],ret['Vga_product'],ret['Vga_vendor'],ret['Vga_Drive'] = self.strip(str(Vga_num)), self.strip(Vga_businfo),self.strip(Vga_product),self.strip(Vga_vendor),self.strip(Vga_Drive)
return ret
def get_monitor_obsolete(self):
#Monitor
# ret = {'Mon_chip': 'CAICOS',
# 'Mon_gamma': '2.20',
# 'Mon_in': '24.1',
# 'Mon_maxmode': '1920x1200',
# 'Mon_output': 'HDMI-0',
# 'Mon_product': 'DELL U2413',
# 'Mon_size': '51.8cm x 32.4cm',
# 'Mon_support': "['HDMI-0', 'VGA-0']",
# 'Mon_vendor': 'DELL',
# 'Mon_week': '13',
# 'Mon_year': '2015',
# 'Vga_Drive': 'radeon',
# 'Vga_businfo': 'pci@0000:02:00.0',
# 'Vga_num': '1',
# 'Vga_product': 'Advanced Micro Devices, Inc. [AMD/ATI] Caicos XT [Radeon HD 7470/8470 / R5 235/310 OEM] (prog-if 00 [VGA controller])',
# 'Vga_vendor': 'ATI'}
# return ret
ret = {}
with open('/var/log/Xorg.0.log','r') as fp:
info = fp.read()
tmp = re.findall('Monitor name: \s*(\w*)\s*(\w*)', info)
if tmp:
if tmp[0][1]:
ret["Mon_vendor"] = tmp[0][0]
ret["Mon_product"] = tmp[0][0] + " " + tmp[0][1]
else:ret["Mon_product"] = tmp[0][0]
tmp = re.findall("Manufacturer:\s*(\w*)\s*Model:\s*(\w*)", info)
if tmp:
if not ret.get("Mon_product"):
ret["Mon_product"] = tmp[0][0] + " " + tmp[0][1]
if not ret.get("Mon_vendor"):
ret["Mon_vendor"] = tmp[0][0]
tmp = re.findall("Year:\s*(\w*)\s*Week:\s*(\w*)", info)
if tmp:
ret["Mon_year"] = tmp[0][0]
ret["Mon_week"] = tmp[0][1]
tmp = re.findall("Image Size: \s*(\w*) x (\w*)", info)
if tmp:
x = float(tmp[0][0])/10
y = float(tmp[0][1])/10
d = math.sqrt(x**2 + y**2)/2.54
ret["Mon_size"] = str(x) + "cm" + " x " + str(y) + "cm"
ret["Mon_in"] = "%.1f" %d
tmp = re.findall("Gamma: (\S*)", info)
if tmp:
ret["Mon_gamma"] = tmp[0]
h = re.findall("h_active: (\d*)", info)
v = re.findall("v_active: (\d*)", info)
if h and v:
ret["Mon_maxmode"] = h[0] + "x" + v[0]
tmp = re.findall("EDID for output (.*)", info)
if tmp:
ret["Mon_support"] = str(tmp)
tmp = re.findall("Output (.*).* connected", info)
if tmp:
ret["Mon_output"] = tmp[0]
tmp = re.findall("Integrated Graphics Chipset: (.*)", info)
if tmp:
ret["Mon_chip"] = tmp[0]
tmp = re.findall("Chipset: \"(.*)\"", info)
if tmp:
if not ret.get("Mon_chip"):
ret["Mon_chip"] = tmp[0]
n = os.popen('lspci -vvv')
vga = n.read()
n.close()
Vga_num = 0
Vga_product,Vga_vendor,Vga_businfo,Vga_Drive = '','','',''
if vga :
while re.findall('VGA compatible controller: ',vga) :
tmp = vga[vga.index('VGA compatible controller: ') - 8:]
vga = tmp[30:]
if tmp[:8]:
median = 'pci@0000:' + tmp[:8]
else:
median = '$'
if Vga_businfo:
Vga_businfo += "<1_1>" + median
else:
Vga_businfo = median
pro = re.findall('VGA compatible controller: (.*)',tmp)
if pro:
median = pro[0]
median_2 = self.get_url('',pro[0])
else:
median = '$'
median_2 = '$'
if Vga_product:
Vga_product += "<1_1>" + median
Vga_vendor += "<1_1>" + median_2
else:
Vga_product = median
Vga_vendor = median_2
Vga_num += 1
tmp = re.findall('Kernel driver in use: (.*)',tmp)
if tmp:
median = tmp[0]
else:
median = '$'
if Vga_Drive:
Vga_Drive += "<1_1>" + median
else :
Vga_Drive = median
if (ret.get('Mon_vendor')):
if (ret.get('Mon_product')):
ret['Mon_vendor'] = self.get_url(ret['Mon_vendor'],ret['Mon_product'])
else :
ret['Mon_vendor'] = self.get_url(ret['Mon_vendor'],'')
ret['Vga_num'],ret['Vga_businfo'],ret['Vga_product'],ret['Vga_vendor'],ret['Vga_Drive'] = self.strip(str(Vga_num)),self.strip(Vga_businfo),self.strip(Vga_product),self.strip(Vga_vendor),self.strip(Vga_Drive)
return ret
def get_disk_obsolete(self):
dis={}
disknum = 0
@ -1210,7 +1084,7 @@ class DetailInfo:
### add by hebing at 2017.01.20
### NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
disklist = []
status, output = commands.getstatusoutput("lsblk -ab")
status, output = subprocess.getstatusoutput("lsblk -ab")
for line in output.split("\n"):
value = line.split()
if value[1] == "8:0" and value[5] == "disk":
@ -1255,7 +1129,7 @@ class DetailInfo:
DiskProduct,DiskVendor,DiskCapacity,DiskName,DiskFw,DiskSerial = '','','','','',''
diskdict = {}
disknum = 0
statusfirst, output = commands.getstatusoutput("lsblk -b")
statusfirst, output = subprocess.getstatusoutput("lsblk -b")
for line in output.split("\n"):
value = line.split()
@ -1266,21 +1140,18 @@ class DetailInfo:
# DiskCapacity += ( ((str(int(value[3]) / 10**9) + "G") if not statusfirst else "$") + "<1_1>")
infodict = {}
status, output = commands.getstatusoutput("hdparm -i %s" % ("/dev/" + value[0]))
pprint(status)
status, output = subprocess.getstatusoutput("hdparm -i %s" % ("/dev/" + value[0]))
if not status:
singleinfolist = [ tmp.strip() for tmp in output.split("\n") if tmp]
pprint(output)
for mid in singleinfolist[1].split(","):
needinfo = mid.split("=")
infodict.setdefault(needinfo[0].strip(), needinfo[1])
for key, va in disk_manufacturers.items():
for key, va in list(disk_manufacturers.items()):
if infodict.get("Model", "$").startswith(key):
infodict.setdefault("Vendor", va)
break
pprint(infodict)
DiskProduct += (infodict.get("Model", "$") + "<1_1>")
DiskVendor += (infodict.get("Vendor", "$") + "<1_1>")
DiskFw += (infodict.get("FwRev", "$") + "<1_1>")
@ -1292,12 +1163,6 @@ class DetailInfo:
DiskFw += ("$" + "<1_1>")
DiskSerial += ("$" + "<1_1>")
DiskName += (("/dev/" + value[0]) + "<1_1>")
pprint(DiskProduct)
pprint(DiskVendor)
pprint(DiskFw)
pprint(DiskSerial)
pprint(DiskName)
pprint(DiskCapacity)
dis['DiskNum'],dis['DiskProduct'],dis['DiskVendor'],dis['DiskCapacity'],dis['DiskName'],dis['DiskFw'],dis['DiskSerial'] = str(disknum),DiskProduct.rstrip("<1_1>"),DiskVendor.rstrip("<1_1>"),DiskCapacity.rstrip("<1_1>"),DiskName.rstrip("<1_1>"),DiskFw.rstrip("<1_1>"),DiskSerial.rstrip("<1_1>")
return dis
@ -1663,8 +1528,8 @@ class DetailInfo:
tmp = re.findall('capabilities: (\d*)',network)
if tmp:
NetCapacity = tmp[0]
except Exception, e:
print e
except Exception as e:
print(e)
WlanProduct,WlanVendor,WlanBusinfo,WlanLogicalname,WlanSerial,WlanIp,WlanDrive = '','','','','','',''
n = os.popen('lspci -vvv')
wlan = n.read()
@ -1891,16 +1756,16 @@ class DetailInfo:
"in19": 12,
}
status, output = commands.getstatusoutput("sensors")
status, output = subprocess.getstatusoutput("sensors")
for line in output.split("\n"):
for key in opposite.items():
for key in list(opposite.items()):
if line.split(":")[0] == key[1]:
if key[1] in ["in17", "in18", "in19"]:
value = (line.split(":")[1]).split("(")[0].strip()
origin[key[0]] = value[0:1] + str(float(value[1:-1]) * product[key[1]]) + " V"
break
if key[1] in ["temp5", "temp6"]:
origin[key[0]] = ((line.split(":")[1]).split("(")[0].strip())[0:5] + u""
origin[key[0]] = ((line.split(":")[1]).split("(")[0].strip())[0:5] + ""
break
origin[key[0]] = (line.split(":")[1]).split("(")[0].strip()
break

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2007-2011 Tualatrix Chou <tualatrix@gmail.com>
@ -26,7 +26,7 @@ UKPATH = '/com/kylin/assistant/systemdaemon'
SHOWED = False
def show_message(*args):
from dialogs import ErrorDialog
from .dialogs import ErrorDialog
title = 'Daemon start failed'
message = ('Kylin Assisant systemdaemon didn\'t start correctly.\n'
'If you want to help developers debugging, try to run "<b>sudo /usr/lib/python2.7/dist-packages/kylin-assistant-daemon/src/start_systemdbus.py</b>" in a terminal.')
@ -39,14 +39,14 @@ class DbusProxy:
try:
__system_bus = dbus.SystemBus()
__object = __system_bus.get_object(INTERFACE, UKPATH)
except Exception, e:
except Exception as e:
__object = None
def __getattr__(self, name):
global SHOWED
try:
return self.__object.get_dbus_method(name, dbus_interface=self.INTERFACE)
except Exception, e:
except Exception as e:
#log.error(e)
if not SHOWED:
SHOWED = True
@ -68,4 +68,4 @@ def init_dbus(dbus_iface=INTERFACE, dbus_path=UKPATH):
return proxy
if __name__ == '__main__':
print init_dbus()
print(init_dbus())

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -16,7 +16,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
import thread
import _thread
from gi.repository import GObject, Gtk, Gdk

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -21,11 +21,11 @@
### END LICENSE
import os, sys
import urllib2
import urllib.request, urllib.error, urllib.parse
import platform
import re
import subprocess
import commands
import subprocess
BOOL_TYPE = 1
INT_TYPE = 2
@ -98,21 +98,21 @@ def get_ip_again():
ret = ''
url = "http://members.3322.org/dyndns/getip"
try:
fp = urllib2.urlopen(url, timeout=5)
fp = urllib.request.urlopen(url, timeout=5)
souce = fp.read()
if not isinstance(souce, str):
souce = str(souce)
fp.close()
ret = souce.replace('\n', '')
except:
print >> sys.stderr, 'get_ip failed!'
print('get_ip failed!', file=sys.stderr)
return ret
def get_ip():
ret = ''
url = "http://iframe.ip138.com/ic.asp"
try:
fp = urllib2.urlopen(url, timeout=5)
fp = urllib.request.urlopen(url, timeout=5)
souce = fp.read().decode("GB2312")
fp.close()
ret = re.findall("<center>(.*)</center>", souce)[0].encode("UTF-8")
@ -144,10 +144,10 @@ def run_app(pkgname):
def get_output(cmd):
'''status =0 : success'''
status, output = commands.getstatusoutput(cmd)
status, output = subprocess.getstatusoutput(cmd)
if status: raise
return output
if __name__ == '__main__':
ip = get_ip()
print ip
print(ip)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -16,8 +16,6 @@
### END LICENSE
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import os
import glob
import fcntl
@ -25,7 +23,6 @@ import shutil
import logging
import tempfile
import subprocess
import commands
import re
from subprocess import PIPE
import apt
@ -39,8 +36,8 @@ import platform
import cleaner
from autostartmanage import autostartmanage
#import pywapi
import urllib2, urllib
from urllib import urlencode
import urllib.request, urllib.error, urllib.parse, urllib.request, urllib.parse, urllib.error
from urllib.parse import urlencode
from xml.dom.minidom import parseString
import re
import json
@ -67,7 +64,7 @@ from sysinfo import Sysinfo
#from camera.capture import Capture
#from weather.weatherinfo import WeatherInfo
#from weather.yahoo import YahooWeather
from common import *
from .common import *
#from unzip import unzip_resource
#from piston_mini_client import APIError
import httplib2
@ -97,7 +94,7 @@ BATTERY_PATH = "/sys/class/power_supply/BAT0"
BAT_FILE = "/sys/class/power_supply/BAT0/uevent"
from gi.repository import Gio as gio
from common import (BOOL_TYPE, INT_TYPE, DOUBLE_TYPE, STRING_TYPE)
from .common import (BOOL_TYPE, INT_TYPE, DOUBLE_TYPE, STRING_TYPE)
#Depends:gir1.2-gconf-2.0
#from gi.repository import GConf
@ -378,7 +375,10 @@ class SessionDaemon(dbus.service.Object):
def currently_installed_version(self):
apt_list = []
cache = apt.Cache()
pkg = cache['kylin-assistant']
try:
pkg = cache['kylin-assistant']
except KeyError as e:
return [""]
installed_version = pkg.installed.version
# print installed_version
if ":" in installed_version:
@ -432,13 +432,13 @@ class SessionDaemon(dbus.service.Object):
@dbus.service.method(INTERFACE, in_signature='d', out_signature='')
def adjust_screen_gamma(self, gamma):
cmd = "xgamma -gamma " + str(gamma)
print cmd
print(cmd)
os.system(cmd)
@dbus.service.method(INTERFACE, in_signature='', out_signature='d')
def get_screen_gamma(self):
# p = os.popen("xgamma")
status, output = commands.getstatusoutput("xgamma")
status, output = subprocess.getstatusoutput("xgamma")
gamma_list = output.split(" ")
gamma = gamma_list[len(gamma_list) - 1]
return float(gamma)
@ -547,9 +547,9 @@ class SessionDaemon(dbus.service.Object):
self.sso.find_oauth_token()
except ImportError:
print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.')
except Exception, e:
except Exception as e:
print('Check user failed.')
print e
print(e)
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
def slot_do_login_account(self):
@ -558,9 +558,9 @@ class SessionDaemon(dbus.service.Object):
self.sso.get_oauth_token()
except ImportError:
print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.')
except Exception, e:
except Exception as e:
print('User login failed.')
print e
print(e)
# user register
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
@ -571,9 +571,9 @@ class SessionDaemon(dbus.service.Object):
except ImportError:
print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.')
except Exception, e:
except Exception as e:
print('User register failed.')
print e
print(e)
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
def slot_do_logout(self):
@ -582,31 +582,31 @@ class SessionDaemon(dbus.service.Object):
except ImportError:
print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.')
except Exception, e:
except Exception as e:
print('User logout failed.')
print e
print(e)
#update user login status
def slot_whoami_done(self, sso, result):
self.user = result["username"]
self.display_name = result["displayname"]
self.preferred_email = result["preferred_email"]
print 'Login success, username: %s' % self.display_name
print('Login success, username: %s' % self.display_name)
self.youkerid_whoami_signal(self.display_name, self.preferred_email)
def slot_logout_successful(self, sso):
if self.token:
print 'User %s has been logout' % self.display_name
print('User %s has been logout' % self.display_name)
self.token = ''
self.user = ''
self.display_name = ''
self.preferred_email = ''
else:
print 'No user has been login'
print('No user has been login')
self.youkerid_logout_signal()
def slot_login_fail(self, sso):
print 'Login or logout failed'
print('Login or logout failed')
self.youkerid_login_fail_signal()
@dbus.service.signal(INTERFACE, signature='ss')
@ -665,7 +665,7 @@ class SessionDaemon(dbus.service.Object):
os.mknod(distrowatch_path)
srcFile = '/var/lib/kylin-assistant-daemon/distrowatch.conf'
if not os.path.exists(srcFile):
print "error with distrowatch file"
print("error with distrowatch file")
return
else:
open(distrowatch_path, "wb").write(open(srcFile, "rb").read())
@ -883,7 +883,7 @@ class SessionDaemon(dbus.service.Object):
if '=' in eachline:
tmp_list = eachline.split('=')
bat_dict[tmp_list[0]] = tmp_list[1]
except Exception, e:
except Exception as e:
bat_dict['error'] = 'unknown'
return bat_dict
@ -2030,10 +2030,10 @@ class SessionDaemon(dbus.service.Object):
for urllist in source_urllist:
source_url = '/'.join(urllist)
try:
response = urllib2.urlopen(source_url,timeout=5)
response = urllib.request.urlopen(source_url,timeout=5)
good_source_urllist.append(source_url)
except Exception, e:
print e
except Exception as e:
print(e)
bad_source_urllist.append(source_url)
if good_source_urllist == []:
self.check_source_list_signal(False)

View File

@ -23,9 +23,7 @@ ratings and reviews API, plus a few helper classes.
"""
import os, sys
reload(sys)
sys.setdefaultencoding('utf8')
from urllib import quote_plus
from urllib.parse import quote_plus
from piston_mini_client import (
PistonAPI,
PistonResponseObject,

View File

@ -43,10 +43,10 @@ def unzip_resource(package_file):
subprocess.call(["unzip", package_file, "-d", unziped_dir])
dest_dir = unziped_dir + "uk-img/"
if not os.path.exists(dest_dir):
print("unzip '%s' to '%s' failed" % (package_file , unziped_dir))
print(("unzip '%s' to '%s' failed" % (package_file , unziped_dir)))
return False
else:
print "unzip ok...."
print("unzip ok....")
return True
# unziped_dir = unziped_dir + WS360_CHROME_PKGNAME
# version = get_package_ver_from_manifest(unziped_dir)

View File

@ -1,8 +1,8 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os, sys, shutil, tempfile
import commands
import subprocess
# ensure that single instance of applet is running for each user
class SingleInstance(object):
@ -15,7 +15,7 @@ class SingleInstance(object):
# Make sure it is not a "stale" pidFile
pid = open(pidPath, 'r').read().strip()
# Check list of running pids, if not running it is stale so overwrite
pidRunning = commands.getoutput('ls -1 /proc | grep ^%s$' % pid)
pidRunning = subprocess.getoutput('ls -1 /proc | grep ^%s$' % pid)
self.lasterror = True if pidRunning else False
else:
self.lasterror = False
@ -24,15 +24,15 @@ class SingleInstance(object):
# Create a temp file, copy it to pidPath and remove temporary file
(fp, temp_path) = tempfile.mkstemp()
try:
os.fdopen(fp, "w+b").write(str(os.getpid()))
os.fdopen(fp, "w+b").write(bytes(os.getpid()))
shutil.copy(temp_path, pidPath)
os.unlink(temp_path)
except Exception as e:
print str(e)
print(str(e))
def is_already_running(self):
return self.lasterror
def __del__(self):
if not self.lasterror:
if not self.lasterror and os.path.exists(self.pidPath):
os.unlink(self.pidPath)

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -66,13 +66,13 @@ class WizardEventBox(gtk.EventBox):
# 鼠标事件
self.connect("button-press-event", self.on_button_press)
# 幻灯片图片
self.slider_pics = map(gtk.gdk.pixbuf_new_from_file, slider_icons)
self.slider_pics = list(map(gtk.gdk.pixbuf_new_from_file, slider_icons))
# 幻灯片总数
self.icon_num = len(slider_icons)
# 滑动圆点图片设置
self.pointer_pic, self.pointer_pic_active = map(gtk.gdk.pixbuf_new_from_file, pointer_icons)
self.pointer_pic, self.pointer_pic_active = list(map(gtk.gdk.pixbuf_new_from_file, pointer_icons))
# 开始按钮图片设置
self.btn_pic, self.btn_pic_press = map(gtk.gdk.pixbuf_new_from_file, button_icons)
self.btn_pic, self.btn_pic_press = list(map(gtk.gdk.pixbuf_new_from_file, button_icons))
button_size = 55
self.pointer_dict = {}
self.index = 0
@ -141,7 +141,7 @@ class WizardEventBox(gtk.EventBox):
def on_motion_notify(self, widget, event):
self.show_index = None
for index, rect in self.pointer_dict.items():
for index, rect in list(self.pointer_dict.items()):
if rect.x <= event.x <= rect.x + rect.width and rect.y <= event.y <= rect.y + rect.height:
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
self.show_index = index
@ -231,7 +231,7 @@ class Wizard(gtk.Window):
self.move_window_event(self.event_box)
def destroy_wizard(self, widget):
print 'Kylin-Assistant slide show is over!'
print('Kylin-Assistant slide show is over!')
#widget.destory()
def is_left_button(self, event):

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (C) 2010 Canonical

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (C) 2010 Canonical
@ -45,9 +45,9 @@ def utf8(s):
"""
if s is None:
return None
if isinstance(s, unicode):
if isinstance(s, str):
return s.encode("utf-8", "ignore")
return unicode(s, "utf8", "ignore").encode("utf8")
return str(s, "utf8", "ignore").encode("utf8")
class LoginBackendDbusSSO(LoginBackend):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (C) 2010 Canonical
@ -33,17 +33,17 @@ import piston_mini_client.failhandlers
#from fake_review_settings import FakeReviewSettings, network_delay
#from spawn_helper import SpawnHelper
from login import get_login_backend
from .login import get_login_backend
from piston.ubuntusso_pristine import (
from .piston.ubuntusso_pristine import (
UbuntuSsoAPI as PristineUbuntuSsoAPI,
)
# patch default_service_root to the one we use
from enums import UBUNTU_KYLIN_SSO_SERVICE
from .enums import UBUNTU_KYLIN_SSO_SERVICE
# *Don't* append /api/1.0, as it's already included in UBUNTU_SSO_SERVICE
PristineUbuntuSsoAPI.default_service_root = UBUNTU_KYLIN_SSO_SERVICE
from enums import (
from .enums import (
SOFTWARE_CENTER_NAME_KEYRING,
SOFTWARE_CENTER_SSO_DESCRIPTION,
)
@ -101,7 +101,7 @@ class UbuntuSSO(GObject.GObject):
try:
res = api.whoami()
except piston_mini_client.failhandlers.APIError as e:
print "api.whoami failed with APIError: '%s'" % e
print("api.whoami failed with APIError: '%s'" % e)
LOG.exception("api.whoami failed with APIError: '%s'" % e)
if len(res) == 0:
self.emit("error")

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2007-2011 Tualatrix Chou <tualatrix@gmail.com>
@ -27,7 +27,7 @@ from single import SingleInstance
if __name__ == '__main__':
myapp = SingleInstance("/tmp/kylin-assistant-sessiondbus-%d.pid" % os.getuid())
if myapp.is_already_running():
print "Another instance of this sessiondbus is already running"
print("Another instance of this sessiondbus is already running")
sys.exit("Another instance of this sessiondbus is already running")
from sessiondbus.daemon import SessionDaemon
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
@ -26,7 +26,7 @@ from single import SingleInstance
if __name__ == '__main__':
myapp = SingleInstance("/tmp/kylin-assistant-systemdbus-%d.pid" % os.getuid())
if myapp.is_already_running():
print "Another instance of this systemdbus is already running"
print("Another instance of this systemdbus is already running")
sys.exit("Another instance of this systemdbus is already running")
os.environ["TERM"] = "xterm"
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -194,7 +194,7 @@ class Sysinfo:
desktop_name = "N/A"
return desktop_name
except Exception as e:
print e
print(e)
desktop = os.getenv('DESKTOP_SESSION')
if desktop in desktop_dict:
return desktop_dict[desktop]
@ -254,6 +254,6 @@ class Sysinfo:
if __name__ == '__main__':
c = Sysinfo()
print(c.get_sys_msg())
print((c.get_sys_msg()))
import getpass
print(getpass.getuser())
print((getpass.getuser()))

View File

@ -1 +1 @@
#!/usr/bin/python
#!/usr/bin/python3

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import apt
@ -68,11 +68,11 @@ class FetchProcess(apb.AcquireProgress):
self.dbus_service.youker_fetch_signal("down_fetch", kwarg)
def ims_hit(self, item):
print 'ims_hit'
print('ims_hit')
pass
def media_change(self, media, drive):
print 'media_change'
print('media_change')
pass
def pulse(self, owner):
@ -106,7 +106,7 @@ class FetchProcess(apb.AcquireProgress):
# cancel the operation
if self.dbus_service.check_cancel_worker_item(self.appname) is True:
print "download_cancel"
print("download_cancel")
self.dbus_service.youker_fetch_signal("down_cancel", kwarg)
return False
@ -235,19 +235,19 @@ class AptHandler():
try:
self.cache.commit(FetchProcess(self.dbus_service, pkgName, AppActions.INSTALLDEPS), AptProcess(self.dbus_service, pkgName, AppActions.INSTALLDEPS))
except Exception, e:
print e
print "install err"
except Exception as e:
print(e)
print("install err")
# install package
def install(self, pkgName, kwargs=None):
print "real install->", pkgName
print("real install->", pkgName)
self.cache.open()
pkg = self.get_pkg_by_name(pkgName)
print pkg.installed.version#1.2.0-0ubuntu1
print len(pkg.versions)#2
print pkg.versions[0].version#1.3.1-0ubuntu1
print pkg.versions[1].version#1.2.0-0ubuntu1
print(pkg.installed.version)#1.2.0-0ubuntu1
print(len(pkg.versions))#2
print(pkg.versions[0].version)#1.3.1-0ubuntu1
print(pkg.versions[1].version)#1.2.0-0ubuntu1
# if pkg.is_installed:
# raise WorkitemError(7, "Package %s is installed" % pkgName)
pkg.mark_install()
@ -306,14 +306,14 @@ class AptHandler():
try:
if quiet == True:
print "quiet=True"
print("quiet=True")
self.cache.update()
else:
print "quiet=False"
print("quiet=False")
self.cache.update(fetch_progress=FetchProcess(self.dbus_service, "#update", AppActions.UPDATE))
except Exception, e:
print e
print "update except"
except Exception as e:
print(e)
print("update except")
class WorkitemError(Exception):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
### BEGIN LICENSE
@ -34,8 +34,8 @@ from gi.repository import GObject
#import aptsources.sourceslist
#import apt_pkg
import threading
import thread
from server import PolicyKitService
import _thread
from .server import PolicyKitService
from policykit import KYLIN_ASSISTANT_ACTION
import time
import cleaner
@ -52,7 +52,7 @@ INTERFACE = 'com.kylin.assistant.systemdaemon'
UKPATH = '/com/kylin/assistant/systemdaemon'
#------------------------------------apt start----------------------------
from apt_handler import AppActions, AptHandler, WorkitemError
from .apt_handler import AppActions, AptHandler, WorkitemError
#class WorkItem:
# def __init__(self, pkgname, action, kwargs):
# self.pkgname = pkgname
@ -170,12 +170,12 @@ class Daemon(PolicyKitService):
#sudo apt-get install youker-assistant=1.3.1-0ubuntu1
@dbus.service.method(INTERFACE, in_signature='s', out_signature='b', sender_keyword='sender')
def install(self, pkgName, sender=None):
print "####install: ",pkgName
print("####install: ",pkgName)
# item = WorkItem(pkgName, AppActions.INSTALL, None)
# self.add_worker_item(item)
# self.aptHandler.install(pkgName)
thread.start_new_thread(self.start_install_uk, (pkgName,))
print "####install return"
_thread.start_new_thread(self.start_install_uk, (pkgName,))
print("####install return")
return True
def start_update_source_list(self):
@ -183,7 +183,7 @@ class Daemon(PolicyKitService):
@dbus.service.method(INTERFACE, in_signature='', out_signature='b', sender_keyword='sender')
def update(self, sender=None):
thread.start_new_thread(self.start_update_source_list, ())
_thread.start_new_thread(self.start_update_source_list, ())
# self.aptHandler.update()
return True
@ -481,7 +481,7 @@ class Daemon(PolicyKitService):
t = threading.Thread(target = daemononekey.clean_all_onekey_crufts, args = (self, mode_list))
t.start()
#daemononekey.clean_all_onekey_crufts(self, mode_list)
except Exception, e:
except Exception as e:
self.clean_error_msg('onekey')
else:
self.clean_complete_msg('onekey')
@ -720,7 +720,7 @@ class Daemon(PolicyKitService):
return
else:
self.quit_clean(True)
thread.start_new_thread(self.start_clean_all, (mode_dic,))
_thread.start_new_thread(self.start_clean_all, (mode_dic,))
# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender')
# def remove_file(self, fp):
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)

6
debian/control vendored
View File

@ -7,7 +7,7 @@ Uploaders:
Build-Depends: debhelper (>= 9),
python-dev,
python-lxml,
python-piston-mini-client,
python3-piston-mini-client,
python-xdg,
qtbase5-dev (>= 5.1),
qt5-qmake,
@ -27,9 +27,9 @@ Depends: python-dbus,
python-lxml,
python-xdg,
python-apt,
python-pil,
python3-pil,
python-imaging,
python-piston-mini-client,
python3-piston-mini-client,
python-compizconfig,
hdparm,
lm-sensors,

4
debian/links vendored
View File

@ -1,2 +1,2 @@
/usr/lib/python2.7/dist-packages/kylin-assistant-daemon/src/start_systemdbus.py /usr/bin/kylin-assistant-backend.py
/usr/lib/python2.7/dist-packages/kylin-assistant-daemon/src/start_sessiondbus.py /usr/bin/kylin-assistant-session.py
/usr/lib/python3/dist-packages/kylin-assistant-daemon/src/start_systemdbus.py /usr/bin/kylin-assistant-backend.py
/usr/lib/python3/dist-packages/kylin-assistant-daemon/src/start_sessiondbus.py /usr/bin/kylin-assistant-session.py