diff -Nru ubuntu-kylin-software-center-0.3.1.0/backend/aptdaemon/dbus_service/apt_daemon.py ubuntu-kylin-software-center-0.3.2.0/backend/aptdaemon/dbus_service/apt_daemon.py --- ubuntu-kylin-software-center-0.3.1.0/backend/aptdaemon/dbus_service/apt_daemon.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/backend/aptdaemon/dbus_service/apt_daemon.py 2014-07-14 08:52:43.000000000 +0000 @@ -41,6 +41,7 @@ APPLY = "apply_changes" PURCHASE = "purchase" UPDATE = "update" + UPDATE_FIRST = "update_first" ADD_SOURCE = "add_source" REMOVE_SOURCE = "remove_source" GET_SOURCES = "get_sources" @@ -103,7 +104,7 @@ "action":str(self.action), } - if self.action == AppActions.UPDATE: + if self.action == AppActions.UPDATE or self.action == AppActions.UPDATE_FIRST: if self.total_items!= 0: percent = float(self.current_items * 100.0 / self.total_items) if percent > self.percent: @@ -276,6 +277,23 @@ except Exception, e: print e print "update except" + + # apt-get update first launch os + def update_first(self, taskName, kwargs=None): + quiet = False + if kwargs is not None: + quiet = int(kwargs["quiet"]) + + try: + if quiet == True: + print "quiet=True" + self.cache.update() + else: + print "quiet=False" + self.cache.update(fetch_progress=FetchProcess(self.dbus_service,taskName,AppActions.UPDATE_FIRST)) + except Exception, e: + print e + print "update except" # check package status by pkgName, i = installed u = can update n = notinstall def check_pkg_status(self, pkgName): diff -Nru ubuntu-kylin-software-center-0.3.1.0/backend/aptdaemon/dbus_service/apt_dbus_service.py ubuntu-kylin-software-center-0.3.2.0/backend/aptdaemon/dbus_service/apt_dbus_service.py --- ubuntu-kylin-software-center-0.3.1.0/backend/aptdaemon/dbus_service/apt_dbus_service.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/backend/aptdaemon/dbus_service/apt_dbus_service.py 2014-07-14 08:52:43.000000000 +0000 @@ -247,7 +247,7 @@ kwarg = {"appname":pkgName, "action":AppActions.INSTALL, } -# self.software_auth_signal("auth_cancel", kwarg) + self.software_auth_signal("auth_cancel", kwarg) return False @@ -269,7 +269,7 @@ kwarg = {"appname":pkgName, "action":AppActions.REMOVE, } -# self.software_auth_signal("auth_cancel", kwarg) + self.software_auth_signal("auth_cancel", kwarg) return False @@ -291,7 +291,7 @@ kwarg = {"appname":pkgName, "action":AppActions.UPGRADE, } -# self.software_auth_signal("auth_cancel", kwarg) + self.software_auth_signal("auth_cancel", kwarg) return False @@ -336,6 +336,25 @@ print "####update return" #???????????????????????????? + # apt-get update sa:software_fetch_signal() + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b', sender_keyword='sender') + def update_first(self, quiet, sender=None): + print "####update first: " + + granted = self.auth_with_policykit(sender,UBUNTUKYLIN_SOFTWARECENTER_ACTION,"要更新软件源") + if not granted: + return False + + kwargs = {"quiet":str(quiet), + } + + item = WorkItem("#update",AppActions.UPDATE_FIRST,kwargs) + + self.add_worker_item(item) + +# self.daemonApt.update() + + print "####update return" # check packages status by pkgNameList sa:software_check_status_signal() @dbus.service.method(INTERFACE, in_signature='as', out_signature='') diff -Nru ubuntu-kylin-software-center-0.3.1.0/backend/installbackend.py ubuntu-kylin-software-center-0.3.2.0/backend/installbackend.py --- ubuntu-kylin-software-center-0.3.1.0/backend/installbackend.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/backend/installbackend.py 2014-07-14 08:52:43.000000000 +0000 @@ -61,7 +61,6 @@ self.iface = None def init_dbus_ifaces(self): - try: bus = dbus.SystemBus(mainloop) except: @@ -176,6 +175,9 @@ def update_source(self,quiet=False): return self.call_dbus_iface(AppActions.UPDATE,False) + def update_source_first_os(self,quiet=False): + return self.call_dbus_iface(AppActions.UPDATE_FIRST,False) + def add_source(self,text): return self.call_dbus_iface(AppActions.ADD_SOURCE,text) diff -Nru ubuntu-kylin-software-center-0.3.1.0/backend/remote/piston_remoter.py ubuntu-kylin-software-center-0.3.2.0/backend/remote/piston_remoter.py --- ubuntu-kylin-software-center-0.3.1.0/backend/remote/piston_remoter.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/backend/remote/piston_remoter.py 2014-07-14 08:52:43.000000000 +0000 @@ -35,6 +35,9 @@ from piston_mini_client.validators import validate_pattern, validate from piston_mini_client import APIError import httplib2 +import sys +reload(sys) +sys.setdefaultencoding('utf8') class ReviewUK(PistonResponseObject): @@ -51,6 +54,15 @@ """ pass + +class PingbackmainRequest(PistonSerializable): + _atts = ('machine', 'distro', 'version_os', 'version_uksc') + + +class PingbackappRequest(PistonSerializable): + _atts = ('app_name', 'machine', 'isrcm') + + class PistonRemoter(PistonAPI): default_service_observe = 'observe' @@ -63,8 +75,6 @@ @returns_list_of(ReviewUK) def get_reviews(self, app, start, range_): - # start = (page - 1) * 10 - # range_ = 10 return self._get('getreviews/?app=%s;start=%s;range=%s' % (app, start, range_), scheme="http") @returns_list_of(ReviewUK) @@ -73,10 +83,38 @@ range_ = 1 return self._get('getreviews/?app=%s;start=%s;range=%s' % (app, start, range_), scheme="http") + @returns_json + def submit_pingback_main(self, machine, distro, version_os, version_uksc): + postdata = PingbackmainRequest() + postdata.machine = machine + postdata.distro = distro + postdata.version_os = version_os + postdata.version_uksc = version_uksc + return self._post('pingbackmain/', data=postdata, scheme='http', content_type='application/json') + + @returns_json + def submit_pingback_app(self, app_name, machine, isrcm): + postdata = PingbackappRequest() + postdata.app_name = app_name + postdata.machine = machine + postdata.isrcm = isrcm + return self._post('pingbackapp/', data=postdata, scheme='http', content_type='application/json') + if __name__ == '__main__': - s = PistonRemoter(service_root="http://service.ubuntukylin.com:8001/uksc/") - reslist = s._get("getallratings", scheme="http") + s = PistonRemoter(service_root="http://192.168.30.12/uksc/") + res = s.submit_pingback_main("123123","ubuntutu","1414","0.99") + print res + + res = s.submit_pingback_app("pyracerz","jioqjwfiqwf","True") + print res + # reslist = s._get("getallratings", scheme="http") + # reslist = s.get_all_ratings() + # print len(reslist) + # import json + # decoded = json.loads(reslist) + # print len(decoded) + # # try: # res = s.get_all_ratings() diff -Nru ubuntu-kylin-software-center-0.3.1.0/backend/service/appmanager.py ubuntu-kylin-software-center-0.3.2.0/backend/service/appmanager.py --- ubuntu-kylin-software-center-0.3.1.0/backend/service/appmanager.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/backend/service/appmanager.py 2014-07-14 08:52:43.000000000 +0000 @@ -39,6 +39,7 @@ from models.advertisement import Advertisement from backend.reviewratingspawn import SpawnProcess, RatingSortMethods,ReviewRatingStat from backend.service.dbmanager import Database +from utils.slientprocess import * from models.enums import (UBUNTUKYLIN_SERVER, UBUNTUKYLIN_RES_PATH, UBUNTUKYLIN_DATA_CAT_PATH, UBUNTUKYLIN_RES_SCREENSHOT_PATH) from models.enums import Signals,UnicodeToAscii @@ -115,10 +116,6 @@ #This class is the abstraction of application management class AppManager(QObject): - # piston remoter - premoter = '' - - # def __init__(self): #super(AppManager, self).__init__() QObject.__init__(self) @@ -130,22 +127,27 @@ self.distroseries = 'any' #'any' for all self.db = Database() - # piston remoter to ukscs - # self.premoter = PistonRemoter(service_root=UBUNTUKYLIN_SERVER) - # self.connect(self, Signals.get_all_ratings_ready, self.slot_update_ratings) - self.worklist = [] self.mutex = threading.RLock() self.worker_thread = ThreadWorkerDaemon(self) self.worker_thread.setDaemon(True) self.worker_thread.start() - def check_update(self): - (inst,up,total) = self.get_application_count() - #if self.db.is_update_needed() and total<300: - if total<500: + # silent process work queue + self.squeue = multiprocessing.Queue() + self.silent_process = SlientProcess(self.squeue) + self.silent_process.daemon = True + self.silent_process.start() + + def check_source_update(self): + f = QFile("/var/lib/apt/periodic/update-success-stamp") + if(f.exists() == False): return True else: + # fi = QFileInfo(f) + # dt = fi.lastModified() + # return dt.toString("yyyyMMddhh") + # return True return False #open the apt cache and get the package count @@ -460,7 +462,6 @@ #get toprated apps def get_toprated_stats_from_db(self, topcount=10, callback=None): - print "We need to get the top 10 applications" list = self.db.query_app_toprated() rnrStatList = [] for item in list: @@ -476,7 +477,6 @@ return rnrStatList - #get toprated apps def get_toprated_stats(self, topcount=100, callback=None): print "We need to get the top 10 applications" @@ -556,6 +556,35 @@ return [] + def get_pointout_apps_from_db(self): + # get apps from db when 0.3.3 + wps = self.get_application_by_name("wps-office") + kuaipan = self.get_application_by_name("kuaipan4uk") + sogou = self.get_application_by_name("sogoupinyin") + apps = [] + apps.append(wps) + apps.append(kuaipan) + apps.append(sogou) + # =========================== + + pl = [] + for app in apps: + if(app.is_installed == False): + pl.append(app) + + return pl + + def get_pointout_is_show_from_db(self): + value = self.db.get_pointout_is_show() + if(value == 'True'): + return True + else: + return False + + def set_pointout_is_show(self, flag): + self.db.set_pointout_is_show(flag) + + def dispatchWorkerResult(self,item,reslist): if item.funcname == "get_reviews": # convert into our review objects @@ -601,7 +630,7 @@ action = item.kwargs["action"] print "update apt cache ready:",len(reslist),pkgname - self.emit(Signals.apt_cache_update_ready,action, pkgname) + self.emit(Signals.apt_cache_update_ready, action, pkgname) elif item.funcname == "init_models": LOG.debug("init models ready") self.emit(Signals.init_models_ready,"ok","获取分类信息完成") @@ -621,20 +650,28 @@ self.db.init_toprated_table(rnrStats) - #------------------------0.3-------------------------- + #--------------------------------0.3---------------------------------- + + def get_all_ratings(self): + kwargs = {} + + item = SilentWorkerItem("get_all_ratings", kwargs) + self.squeue.put_nowait(item) + + def submit_pingback_main(self): + kwargs = {} + + item = SilentWorkerItem("submit_pingback_main", kwargs) + self.squeue.put_nowait(item) + + def submit_pingback_app(self, app_name, isrcm=False): + kwargs = {"app_name": app_name, + "isrcm": isrcm, + } + + item = SilentWorkerItem("submit_pingback_app", kwargs) + self.squeue.put_nowait(item) - # get all app's rating & rating times - # def update_ratings(self): - # kwargs = None - # - # item = WorkerItem("get_all_ratings",kwargs) - # - # self.mutex.acquire() - # self.worklist.append(item) - # self.mutex.release() - # - # def slot_update_ratings(self, ratinglist): - # self.db.update_ratings(ratinglist) def _reviews_ready_callback(str_pkgname, reviews_data, my_votes=None, action=None, single_review=None): diff -Nru ubuntu-kylin-software-center-0.3.1.0/backend/service/dbmanager.py ubuntu-kylin-software-center-0.3.2.0/backend/service/dbmanager.py --- ubuntu-kylin-software-center-0.3.1.0/backend/service/dbmanager.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/backend/service/dbmanager.py 2014-07-14 08:52:43.000000000 +0000 @@ -412,50 +412,22 @@ return reviews + def get_pointout_is_show(self): + self.cursor.execute("select value from dict where key=?", ('pointout',)) + res = self.cursor.fetchall() + for item in res: + isshow = item[0] + return isshow + + def set_pointout_is_show(self, flag): + value = '' + if(flag == True): + value = 'True' + else: + value = 'False' + self.cursor.execute("update dict set value=? where key='pointout'", (value,)) + self.connect.commit() -class CacheProcess(multiprocessing.Process): - - def __init__(self, func, kwargs=None, event=None, queue=None): - super(CacheProcess, self).__init__() - multiprocessing.Process.__init__(self) - self.func = func - self.kwargs = kwargs - self.daemon = True - self.event = event - self.queue = queue - - def run(self): - if self.func == "get_all_ratings": - from backend.remote.piston_remoter import PistonRemoter - import json - premoter = PistonRemoter(service_root=UBUNTUKYLIN_SERVER) - reslist = premoter._get("getallratings", scheme="http") - decoded = json.loads(reslist) - print "all ratings and rating_total download over : ",len(decoded) - - import sqlite3 - destFile = os.path.join(UKSC_CACHE_DIR,"uksc.db") - self.connect = sqlite3.connect(destFile, check_same_thread=False) - self.cursor = self.connect.cursor() - - for rating in decoded: - app_name = rating['app_name'] - # print app_name - rating_avg = str(rating['rating_avg']) - # print rating_avg - rating_total = str(rating['rating_total']) - # print rating_total - - sql = "update application set rating_total=" + rating_total + ",rating_avg=" + rating_avg +" where app_name='" + app_name + "'" - self.cursor.execute(sql) - self.connect.commit() - - # CACHE update rating_avg and rating_total - def update_ratings(self, result): - pass - - def update_categories(self): - pass if __name__ == "__main__": db = Database() Binary files /tmp/trSFMoMqFF/ubuntu-kylin-software-center-0.3.1.0/data/icons/wiznote.png and /tmp/l2WVtSQRhb/ubuntu-kylin-software-center-0.3.2.0/data/icons/wiznote.png differ Binary files /tmp/trSFMoMqFF/ubuntu-kylin-software-center-0.3.1.0/data/uksc.db and /tmp/l2WVtSQRhb/ubuntu-kylin-software-center-0.3.2.0/data/uksc.db differ diff -Nru ubuntu-kylin-software-center-0.3.1.0/debian/bzr-builder.manifest ubuntu-kylin-software-center-0.3.2.0/debian/bzr-builder.manifest --- ubuntu-kylin-software-center-0.3.1.0/debian/bzr-builder.manifest 2014-06-18 00:47:02.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/debian/bzr-builder.manifest 2014-07-14 08:52:45.000000000 +0000 @@ -1,2 +1,2 @@ -# bzr-builder format 0.3 deb-version {debupstream}-0~121 -lp:ubuntu-kylin-software-center revid:shenghuang@ubuntukylin.com-20140616080309-j7lgzzlmy1plgenr +# bzr-builder format 0.3 deb-version {debupstream}-0~130 +lp:ubuntu-kylin-software-center revid:289483102@qq.com-20140714084102-ecnzgi3ijovh7ees diff -Nru ubuntu-kylin-software-center-0.3.1.0/debian/changelog ubuntu-kylin-software-center-0.3.2.0/debian/changelog --- ubuntu-kylin-software-center-0.3.1.0/debian/changelog 2014-06-18 00:47:02.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/debian/changelog 2014-07-14 08:52:45.000000000 +0000 @@ -1,8 +1,17 @@ -ubuntu-kylin-software-center (0.3.1.0-0~121~ubuntu13.10.1) saucy; urgency=low +ubuntu-kylin-software-center (0.3.2.0-0~130~ubuntu13.10.1) saucy; urgency=low * Auto build. - -- wenbo607 Wed, 18 Jun 2014 00:47:02 +0000 + -- wenbo607 Mon, 14 Jul 2014 08:52:45 +0000 + +ubuntu-kylin-software-center (0.3.2.0) trusty; urgency=medium + + * Increase the small icon, click on the optional after hide/show the main interface, exit procedures + * Modify the update software source of tips, dbus tips such as text and control logic + * Increase start software center data record and install the software of data records + * fix many bugs(1329237,1326692,1297108,1340497,1323209) + + -- Shine Fri, 11 Jul 2014 16:34:17 +0800 ubuntu-kylin-software-center (0.3.1.0) trusty; urgency=medium diff -Nru ubuntu-kylin-software-center-0.3.1.0/models/application.py ubuntu-kylin-software-center-0.3.2.0/models/application.py --- ubuntu-kylin-software-center-0.3.1.0/models/application.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/models/application.py 2014-07-14 08:52:43.000000000 +0000 @@ -140,6 +140,18 @@ except: return " " + # get total download size include dependencies + def get_total_size(self): + totalsize = 0 + deplist = self.package.candidate.dependencies + for dep_l in deplist: + dep = dep_l[0] + if(dep.rawtype == 'Depends'): + deppackage = self.cache[dep.name] + if(deppackage.is_installed == False): + totalsize += deppackage.candidate.size + + return totalsize #get the reviews object list of this application def get_reviews(self,page): diff -Nru ubuntu-kylin-software-center-0.3.1.0/models/enums.py ubuntu-kylin-software-center-0.3.2.0/models/enums.py --- ubuntu-kylin-software-center-0.3.1.0/models/enums.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/models/enums.py 2014-07-14 08:52:43.000000000 +0000 @@ -37,6 +37,7 @@ # UBUNTUKYLIN_SERVER = "http://192.168.30.12/uksc/" UBUNTUKYLIN_SERVER = "http://service.ubuntukylin.com:8001/uksc/" +#UBUNTUKYLIN_SERVER = "http://service.ubuntukylin.com/uksc/" # pkg action state constants @@ -122,6 +123,7 @@ click_item = SIGNAL("clickitem") show_app_detail = SIGNAL("app-show-detail") install_app = SIGNAL("install-app") + install_app_rcm = SIGNAL("install-app-rcm") remove_app = SIGNAL("remove-app") upgrade_app = SIGNAL("upgrade-app") click_update_source = SIGNAL("click-update-source") @@ -143,6 +145,7 @@ APPLY = "apply_changes" PURCHASE = "purchase" UPDATE = "update" + UPDATE_FIRST = "update_first" ADD_SOURCE = "add_source" REMOVE_SOURCE = "remove_source" GET_SOURCES = "get_sources" @@ -153,6 +156,7 @@ "remove":"卸载", "upgrade":"更新", "update":"源更新", + "update_first":"源初始化", } AptProcessMsg = { @@ -203,4 +207,4 @@ if match: return True else: - return False \ No newline at end of file + return False diff -Nru ubuntu-kylin-software-center-0.3.1.0/models/globals.py ubuntu-kylin-software-center-0.3.2.0/models/globals.py --- ubuntu-kylin-software-center-0.3.1.0/models/globals.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/models/globals.py 2014-07-14 08:52:43.000000000 +0000 @@ -29,4 +29,5 @@ class Globals: # how many softwares show in a setp showSoftwareStep = 20 - UKSC_VERSION = '0.3.1' + LAUNCH_MODE = 'quiet' + UKSC_VERSION = '0.3.2' \ No newline at end of file Binary files /tmp/trSFMoMqFF/ubuntu-kylin-software-center-0.3.1.0/res/pointheader.png and /tmp/l2WVtSQRhb/ubuntu-kylin-software-center-0.3.2.0/res/pointheader.png differ Binary files /tmp/trSFMoMqFF/ubuntu-kylin-software-center-0.3.1.0/res/trayicon.png and /tmp/l2WVtSQRhb/ubuntu-kylin-software-center-0.3.2.0/res/trayicon.png differ diff -Nru ubuntu-kylin-software-center-0.3.1.0/res/trayicon.svg ubuntu-kylin-software-center-0.3.2.0/res/trayicon.svg --- ubuntu-kylin-software-center-0.3.1.0/res/trayicon.svg 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/res/trayicon.svg 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru ubuntu-kylin-software-center-0.3.1.0/setup.py ubuntu-kylin-software-center-0.3.2.0/setup.py --- ubuntu-kylin-software-center-0.3.1.0/setup.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/setup.py 2014-07-14 08:52:43.000000000 +0000 @@ -6,7 +6,7 @@ #import build_i18n_ext as build_i18n setup(name="ubuntu-kylin-software-center", - version="0.3.1", + version="0.3.2", author="Ubuntu Kylin Team", author_email="ubuntukylin-members@list.launchpad.net", url="https://launchpad.net/ubuntu-kylin-software-center", @@ -36,4 +36,5 @@ ('share/ubuntu-kylin-software-center/ui/', glob.glob('ui/*')), ('share/ubuntu-kylin-software-center/utils/', glob.glob('utils/*')), ('share/ubuntu-kylin-software-center/',['ReadMe','ubuntu-kylin-software-center.py']), + ('../etc/xdg/autostart/',['ubuntu-kylin-software-center-autostart.desktop']), ]) diff -Nru ubuntu-kylin-software-center-0.3.1.0/test/apttest.py ubuntu-kylin-software-center-0.3.2.0/test/apttest.py --- ubuntu-kylin-software-center-0.3.1.0/test/apttest.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/test/apttest.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +__author__ = 'Shine Huang' + +import apt +import locale +import apt.progress.base as apb + +from PyQt4.QtCore import * +try: + _fromUtf8 = QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + + +class BackendApt(QObject): + #the apt cache + ca = '' + sl = [] + + def __init__(self): + QObject.__init__(self) + locale.setlocale(locale.LC_ALL, "zh_CN.UTF-8") + print locale.getlocale() + self.ca = apt.Cache() + self.ca.open() + + # get all packages + def get_all_packages(self): + # self.ca.open() + for pkg in self.ca: + self.sl.append(pkg) + return self.sl + + # get package by pkgName + def get_package_by_name(self, pkgName): + for pkg in self.sl: + if(pkg.name == pkgName): + return pkg + else: + return None + + def get_pkg_in_cache(self, pkgName): + return self.ca[pkgName] + + # update_package_status + def update_package_status(self, pkgName): + self.ca.open() + for pkg in self.ca: + if(pkg.name == pkgName): + return pkg + else: + return None + + +def main(): + a = BackendApt() + # a.get_all_packages() + # print a.get_package_by_name("abe") + pkg = a.get_pkg_in_cache("abe") + deplist = pkg.candidate.dependencies + deplisttrue = [] + dep_l = deplist[0] + dep = dep_l[0] + + print dep.name + print dep.rawtype + # for dep in deplist: + # print dep + # for ha in haha: + # print type(ha) + +if __name__ == '__main__': + main() \ No newline at end of file diff -Nru ubuntu-kylin-software-center-0.3.1.0/test/pistontest.py ubuntu-kylin-software-center-0.3.2.0/test/pistontest.py --- ubuntu-kylin-software-center-0.3.1.0/test/pistontest.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/test/pistontest.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,51 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import json +import os +from urllib import quote_plus +from piston_mini_client import ( + PistonAPI, + PistonResponseObject, + PistonSerializable, + returns, + returns_json, + returns_list_of, +) +from piston_mini_client.validators import validate_pattern, validate +from piston_mini_client.failhandlers import APIError + +import piston_mini_client + +import sys +reload(sys) +sys.setdefaultencoding('utf8') + + +class ReviewRequest(PistonSerializable): + _atts = ('machine', 'distro', 'version_os', 'version_uksc') + + +class RatingsAndReviewsAPI(PistonAPI): + + default_service_root = 'http://192.168.30.12/uksc/' + default_content_type = 'application/x-www-form-urlencoded' + + @validate('review', ReviewRequest) + @returns_json + def submit_review(self,review): + return self._post('pingbackmain/', data=review,scheme='http', content_type='application/json') + + +if __name__ == '__main__': + wb = RatingsAndReviewsAPI() + rdata = ReviewRequest() + rdata.machine = '01010101010101' + rdata.distro = 'ubuntu kylin' + rdata.version_os = '14.10' + rdata.version_uksc = '0.3.33' + + res = wb.submit_review(review=rdata) + print res + # decoded = json.loads(res) + # print decoded \ No newline at end of file diff -Nru ubuntu-kylin-software-center-0.3.1.0/ubuntu-kylin-software-center ubuntu-kylin-software-center-0.3.2.0/ubuntu-kylin-software-center --- ubuntu-kylin-software-center-0.3.1.0/ubuntu-kylin-software-center 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ubuntu-kylin-software-center 2014-07-14 08:52:43.000000000 +0000 @@ -1,3 +1,14 @@ #!/bin/sh -cd /usr/share/ubuntu-kylin-software-center -python ubuntu-kylin-software-center.py +if [ $# = 0 ]; then + echo "normal start" + cd /usr/share/ubuntu-kylin-software-center + python ubuntu-kylin-software-center.py +else + if [ $1 = "-quiet" ]; then + echo "quiet start" + cd /usr/share/ubuntu-kylin-software-center + python ubuntu-kylin-software-center.py -quiet + else + echo "unknown option" + fi +fi diff -Nru ubuntu-kylin-software-center-0.3.1.0/ubuntu-kylin-software-center-autostart.desktop ubuntu-kylin-software-center-0.3.2.0/ubuntu-kylin-software-center-autostart.desktop --- ubuntu-kylin-software-center-0.3.1.0/ubuntu-kylin-software-center-autostart.desktop 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ubuntu-kylin-software-center-autostart.desktop 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Ubuntu Kylin Software Center +Name[zh_CN]=Ubuntu Kylin 软件中心 +Comment=Ubuntu Kylin software-center +Exec=/usr/bin/ubuntu-kylin-software-center -quiet +Icon=ubuntu-kylin-software-center +StartupNotify=true +Terminal=false +Type=Application +Categories=PackageManager;GTK;Graphics;System;Settings;Viewer; +Keywords=Sources;PPA;Install;Uninstall;Remove;Purchase;Catalogue;Store;Apps; diff -Nru ubuntu-kylin-software-center-0.3.1.0/ubuntu-kylin-software-center.py ubuntu-kylin-software-center-0.3.2.0/ubuntu-kylin-software-center.py --- ubuntu-kylin-software-center-0.3.1.0/ubuntu-kylin-software-center.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ubuntu-kylin-software-center.py 2014-07-14 08:52:43.000000000 +0000 @@ -27,20 +27,26 @@ import dbus import dbus.service import webbrowser +from PyQt4.QtGui import * +from PyQt4.QtCore import * from ui.mainwindow import Ui_MainWindow from ui.recommenditem import RecommendItem from ui.listitemwidget import ListItemWidget from ui.tasklistitemwidget import TaskListItemWidget from ui.ranklistitemwidget import RankListItemWidget +from ui.pointlistitemwidget import PointListItemWidget from ui.adwidget import * from ui.detailscrollwidget import DetailScrollWidget from ui.loadingdiv import * from ui.messagebox import MessageBox from ui.confirmdialog import ConfirmDialog from ui.configwidget import ConfigWidget +from ui.pointoutwidget import PointOutWidget +from ui.singleprocessbar import SingleProcessBar from utils import vfs +from utils import log from utils.history import History from backend.search import * @@ -56,13 +62,12 @@ from dbus.mainloop.glib import DBusGMainLoop mainloop = DBusGMainLoop(set_as_default=True) - LOG = logging.getLogger("uksc") class SoftwareCenter(QMainWindow): - # recommend number in fill func + # recommend number in function "fill" recommendNumber = 0 # now page nowPage = '' @@ -78,95 +83,58 @@ def __init__(self,parent=None): QMainWindow.__init__(self,parent) + # single check self.check_single_process_by_sessionbus() - # init the ui - self.init_main_view() - - windowWidth = QApplication.desktop().width() - windowHeight = QApplication.desktop().height() - self.move((windowWidth - self.width()) / 2, (windowHeight - self.height()) / 2) - - self.history = History(self.ui) - # connect the ui signals - # self.ui.headerWidget.installEventFilter(self) + # init dbus backend + self.init_dbus() - self.ui.btnBack.clicked.connect(self.history.history_back) - self.ui.btnNext.clicked.connect(self.history.history_next) - self.ui.categoryView.itemClicked.connect(self.slot_change_category) - self.ui.rankView.itemClicked.connect(self.slot_click_rank_item) - self.ui.allsListWidget.itemClicked.connect(self.slot_click_item) - self.ui.upListWidget.itemClicked.connect(self.slot_click_item) - self.ui.unListWidget.itemClicked.connect(self.slot_click_item) - self.ui.searchListWidget.itemClicked.connect(self.slot_click_item) - self.ui.allsListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) - self.ui.upListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) - self.ui.searchListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) - self.ui.unListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) - self.ui.btnHomepage.pressed.connect(self.slot_goto_homepage) - self.ui.btnUp.pressed.connect(self.slot_goto_uppage) - self.ui.btnUn.pressed.connect(self.slot_goto_unpage) - self.ui.btnTask.pressed.connect(self.slot_goto_taskpage) - self.ui.btnClose.clicked.connect(self.slot_close) - self.ui.btnMin.clicked.connect(self.slot_min) - self.ui.btnConf.clicked.connect(self.slot_show_config) - self.ui.leSearch.textChanged.connect(self.slot_search_text_change) - self.connect(self, Signals.click_item, self.slot_show_app_detail) - - self.connect(self, Signals.install_app, self.slot_click_install) - self.connect(self.detailScrollWidget, Signals.install_app, self.slot_click_install) - self.connect(self.detailScrollWidget, Signals.upgrade_app, self.slot_click_upgrade) - self.connect(self.detailScrollWidget, Signals.remove_app, self.slot_click_remove) - self.connect(self,Signals.update_source,self.slot_update_source) - - # init text info - self.ui.userName.setText("未登陆") - self.ui.userLv.setText("Lv 0") - self.ui.leSearch.setPlaceholderText("请输入想要搜索的软件") - self.ui.bottomText1.setText("Ubuntu Kylin软件中心") - self.ui.bottomText2.setText(Globals.UKSC_VERSION) - - self.ui.categoryView.setEnabled(False) - self.ui.btnUp.setEnabled(False) - self.ui.btnUn.setEnabled(False) - self.ui.btnTask.setEnabled(False) - - self.searchDTimer = QTimer(self) - self.searchDTimer.timeout.connect(self.slot_searchDTimer_timeout) - - # init the initial data for view init - self.appmgr = AppManager() - self.connect(self.appmgr,Signals.init_models_ready,self.slot_init_models_ready) - self.appmgr.init_models() + # init ui + self.init_main_view() - # alert message box - self.messageBox = MessageBox(self) + # init system tray + self.create_tray() - self.ui.categoryView.hide() - self.ui.headerWidget.hide() - self.ui.centralwidget.hide() - self.ui.leftWidget.hide() - - # show user to wait - self.loadingDiv.start_loading("系统正在初始化...") + # init main service + self.init_main_service() - def show_to_frontend(self): - self.show() - self.raise_() + # check apt source and update it + self.check_source() def init_main_view(self): self.ui = Ui_MainWindow() self.ui.setupUi(self) - self.setWindowTitle("Ubuntu Kylin Software-Center") + self.setWindowTitle("Ubuntu Kylin 软件中心") self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) + windowWidth = QApplication.desktop().width() + windowHeight = QApplication.desktop().height() + self.move((windowWidth - self.width()) / 2, (windowHeight - self.height()) / 2) + + # init components + # point out widget + self.pointout = PointOutWidget(self) # detail page self.detailScrollWidget = DetailScrollWidget(self) self.detailScrollWidget.raise_() - # loading page + # loading div self.loadingDiv = LoadingDiv(self) + self.topratedload = MiniLoadingDiv(self.ui.rankView, self.ui.rankWidget) + # alert message box + self.messageBox = MessageBox(self) + # first update process bar + self.updateSinglePB = SingleProcessBar(self) + # config widget + self.configWidget = ConfigWidget(self) + self.connect(self.configWidget, Signals.click_update_source, self.slot_click_update_source) + self.connect(self.configWidget, Signals.task_cancel, self.slot_click_cancel) + # history manager + self.history = History(self.ui) + # search trigger + self.searchDTimer = QTimer(self) + self.searchDTimer.timeout.connect(self.slot_searchDTimer_timeout) # style by code self.ui.headerWidget.setAutoFillBackground(True) @@ -183,7 +151,6 @@ self.ui.userWidget.setAutoFillBackground(True) palette = QPalette() - # img = QPixmap("res/categorybg.png") palette.setBrush(QPalette.Background, QColor(44, 46, 61)) self.ui.userWidget.setPalette(palette) @@ -231,22 +198,6 @@ self.ui.rankView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.ui.rankView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.ui.allsWidget.hide() - self.ui.upWidget.hide() - self.ui.unWidget.hide() - self.ui.searchWidget.hide() - self.ui.taskWidget.hide() - - - # erase the window edge shade from window manager in 1404beta - # bm = QBitmap(self.size()) - # qp = QPainter() - # qp.begin(bm) - # qp.setBrush(QColor(0, 0, 0)) - # qp.drawRoundedRect(self.rect(), 10, 10) - # qp.end() - # self.setMask(bm) - self.softCountText1 = QLabel(self.ui.searchBG) self.softCountText1.setGeometry(QRect(10, 8, 30, 17)) self.softCountText1.setObjectName("softCountText1") @@ -262,10 +213,6 @@ self.softCount.setAlignment(Qt.AlignCenter) - self.softCountText1.setStyleSheet("QLabel{color:white;font-size:14px;}") - self.softCountText2.setStyleSheet("QLabel{color:white;font-size:14px;}") - self.softCount.setStyleSheet("QLabel{color:white;font-size:15px;}") - self.ui.texticon.setText("图标") self.ui.textappname.setText("软件名") self.ui.textsize.setText("大小") @@ -293,9 +240,16 @@ self.ui.textrating_all.setText("评分") self.ui.textaction_all.setText("操作") - #self.show() + self.ui.userName.setText("未登陆") + self.ui.userLv.setText("Lv 0") + self.ui.leSearch.setPlaceholderText("请输入想要搜索的软件") + self.ui.bottomText1.setText("Ubuntu Kylin软件中心") + self.ui.bottomText2.setText(Globals.UKSC_VERSION) # style by qss + self.softCountText1.setStyleSheet("QLabel{color:white;font-size:14px;}") + self.softCountText2.setStyleSheet("QLabel{color:white;font-size:14px;}") + self.softCount.setStyleSheet("QLabel{color:white;font-size:15px;}") self.ui.shadowleft.setStyleSheet("QLabel{background-image:url('res/sleft.png')}") self.ui.shadowright.setStyleSheet("QLabel{background-image:url('res/sright.png')}") self.ui.shadowup.setStyleSheet("QLabel{background-image:url('res/sup.png')}") @@ -382,60 +336,95 @@ "QScrollBar:sub-page:vertical{background:qlineargradient(x1: 0.5, y1: 1, x2: 0.5, y2: 0, stop: 0 #D4DCE1, stop: 1 white);}QScrollBar:add-page:vertical{background:qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 #D4DCE1, stop: 1 white);}" "QScrollBar:handle:vertical{background:qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #CACACA, stop: 1 #818486);}QScrollBar:add-line:vertical{background-color:green;}") - # advertisement - adw = ADWidget([], self) - # self.setAttribute(Qt.WA_X11NetWmWindowTypeDock) - - - def check_single_process_by_sessionbus(self): - - try: - bus = dbus.SessionBus() - except: - LOG.exception("could not initiate dbus") - sys.exit() - return + # signal / slot + self.ui.btnBack.clicked.connect(self.history.history_back) + self.ui.btnNext.clicked.connect(self.history.history_next) + self.ui.categoryView.itemClicked.connect(self.slot_change_category) + self.ui.rankView.itemClicked.connect(self.slot_click_rank_item) + self.ui.allsListWidget.itemClicked.connect(self.slot_click_item) + self.ui.upListWidget.itemClicked.connect(self.slot_click_item) + self.ui.unListWidget.itemClicked.connect(self.slot_click_item) + self.ui.searchListWidget.itemClicked.connect(self.slot_click_item) + self.ui.allsListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) + self.ui.upListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) + self.ui.searchListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) + self.ui.unListWidget.verticalScrollBar().valueChanged.connect(self.slot_softwidget_scroll_end) + self.ui.btnHomepage.pressed.connect(self.slot_goto_homepage) + self.ui.btnUp.pressed.connect(self.slot_goto_uppage) + self.ui.btnUn.pressed.connect(self.slot_goto_unpage) + self.ui.btnTask.pressed.connect(self.slot_goto_taskpage) + self.ui.btnClose.clicked.connect(self.hide) + self.ui.btnMin.clicked.connect(self.slot_min) + self.ui.btnConf.clicked.connect(self.slot_show_config) + self.ui.leSearch.textChanged.connect(self.slot_search_text_change) - #if there is an instance running, call to bring it to frontend - try: - proxy_obj = bus.get_object('com.ubuntukylin.softwarecenter', - '/com/ubuntukylin/softwarecenter') - iface = dbus.Interface(proxy_obj, 'com.ubuntukylin.softwarecenterIFace') + self.connect(self, Signals.click_item, self.slot_show_app_detail) + self.connect(self, Signals.install_app, self.slot_click_install) + self.connect(self.detailScrollWidget, Signals.install_app, self.slot_click_install) + self.connect(self.detailScrollWidget, Signals.upgrade_app, self.slot_click_upgrade) + self.connect(self.detailScrollWidget, Signals.remove_app, self.slot_click_remove) + self.connect(self, Signals.update_source,self.slot_update_source) - res = iface.bringToFront() + # widget status + self.ui.categoryView.setEnabled(False) + self.ui.btnUp.setEnabled(False) + self.ui.btnUn.setEnabled(False) + self.ui.btnTask.setEnabled(False) - sys.exit() + self.ui.allsWidget.hide() + self.ui.upWidget.hide() + self.ui.unWidget.hide() + self.ui.searchWidget.hide() + self.ui.taskWidget.hide() + self.ui.categoryView.hide() + self.ui.headerWidget.hide() + self.ui.centralwidget.hide() + self.ui.leftWidget.hide() - except dbus.DBusException: - bus_name = dbus.service.BusName('com.ubuntukylin.softwarecenter', bus) - self.dbusControler = SoftwarecenterDbusController(self, bus_name) + # loading + self.loadingDiv.start_loading("系统正在初始化...") + def create_tray(self): + self.actionshow = QAction("隐藏/显示", self) + self.actionshow.triggered.connect(self.slot_show_or_hide) + + self.actionquit = QAction("退出", self) + self.actionquit.triggered.connect(self.slot_close) + + self.traymenu = QMenu(self) + self.traymenu.addAction(self.actionshow) + self.traymenu.addSeparator() + self.traymenu.addAction(self.actionquit) + + self.trayicon = QSystemTrayIcon(self) + self.icon = QIcon("res/trayicon.png") + self.trayicon.setIcon(self.icon) + self.trayicon.setContextMenu(self.traymenu) + self.trayicon.activated.connect(self.slot_trayicon_activated) - def mousePressEvent(self, event): - if (event.button() == Qt.LeftButton): - self.dragPosition = event.globalPos() - self.frameGeometry().topLeft() - event.accept() + def init_main_service(self): + self.appmgr = AppManager() - def mouseMoveEvent(self, event): - if (event.buttons() == Qt.LeftButton and self.dragPosition != -1): - self.move(event.globalPos() - self.dragPosition) - event.accept() + self.connect(self.appmgr, Signals.init_models_ready,self.slot_init_models_ready) + self.connect(self.appmgr, Signals.ads_ready, self.slot_advertisement_ready) + self.connect(self.appmgr, Signals.recommend_ready, self.slot_recommend_apps_ready) + self.connect(self.appmgr, Signals.rating_reviews_ready, self.slot_rating_reviews_ready) + self.connect(self.appmgr, Signals.toprated_ready, self.slot_toprated_ready) + self.connect(self.appmgr, Signals.app_reviews_ready, self.slot_app_reviews_ready) + self.connect(self.appmgr, Signals.app_screenshots_ready, self.slot_app_screenshots_ready) + self.connect(self.appmgr, Signals.apt_cache_update_ready, self.slot_apt_cache_update_ready) - def init_models(self): - LOG.debug("begin init_models...") - #init appmgr -# self.appmgr = AppManager() -# self.connect(self.appmgr,Signals.init_models_ready,self.slot_init_models_ready) -# self.appmgr.init_models() - self.init_category_view() + self.connect(self, Signals.count_application_update,self.slot_count_application_update) + self.connect(self, Signals.apt_process_finish,self.slot_apt_process_finish) - #init backend + def init_dbus(self): self.backend = InstallBackend() + self.connect(self.backend, Signals.dbus_apt_process,self.slot_status_change) res = self.backend.init_dbus_ifaces() while res == False: button=QMessageBox.question(self,"初始化提示", - self.tr("DBus服务初始化失败!\n请确认是否正确安装,继续操作将不能正常进行软件安装等操作!\n是否继续?"), - "重试", "是", "否", 0) + self.tr("初始化失败 (DBus服务)\n请确认是否正确安装,忽略将不能正常进行软件安装等操作\n请选择:"), + "重试", "忽略", "退出", 0) if button == 0: res = self.backend.init_dbus_ifaces() elif button == 1: @@ -445,111 +434,125 @@ LOG.warning("dbus service init failed, you choose to exit.\n\n") sys.exit(0) - # config widget - self.configWidget = ConfigWidget(self) - self.connect(self.configWidget, Signals.click_update_source, self.slot_click_update_source) - self.connect(self.configWidget, Signals.task_cancel, self.slot_click_cancel) + def check_source(self): + if(self.appmgr.check_source_update()): + if(Globals.LAUNCH_MODE == 'quiet'): + button = QMessageBox.question(self,"软件源更新提示", + self.tr("您是第一次进入系统 或 软件源发生异常\n要在系统中 安装/卸载/升级 软件,需要连接网络更新软件源\n如没有网络或不想更新,下次可通过运行软件中心触发此功能\n\n请选择:"), + "更新", "不更新", "", 0) + if button == 0: + LOG.info("update source when first start...") + self.updateSinglePB.show() + self.backend.update_source_first_os() + elif button == 1: + LOG.warning("dbus service init failed, you choose to exit.\n\n") + sys.exit(0) + else: + button = QMessageBox.question(self,"软件源更新提示", + self.tr("您是第一次进入系统 或 软件源发生异常\n要在系统中 安装/卸载/升级 软件,需要连接网络更新软件源\n如不更新,也可以运行软件,但大部分操作都无法执行\n\n请选择:"), + "更新", "不更新", "", 0) + + # normal launch mode, show loading div this moment + self.show() + + if button == 0: + LOG.info("update source when first start...") + self.updateSinglePB.show() + self.backend.update_source_first_os() + elif button == 1: + self.appmgr.init_models() + else: + if(Globals.LAUNCH_MODE == 'normal'): + self.show() + self.appmgr.init_models() + + def check_single_process_by_sessionbus(self): + try: + bus = dbus.SessionBus() + except: + LOG.exception("could not initiate dbus") + sys.exit() + return + + # if there is an instance running, call to bring it to frontend + try: + proxy_obj = bus.get_object('com.ubuntukylin.softwarecenter', '/com/ubuntukylin/softwarecenter') + iface = dbus.Interface(proxy_obj, 'com.ubuntukylin.softwarecenterIFace') + res = iface.bringToFront() + sys.exit() + + except dbus.DBusException: + bus_name = dbus.service.BusName('com.ubuntukylin.softwarecenter', bus) + self.dbusControler = SoftwarecenterDbusController(self, bus_name) + def init_last_data(self): + # init category list + self.init_category_view() - #init search + # init search self.searchDB = Search() self.searchList = {} - #init others + # init others self.category = "" self.nowPage = "homepage" - self.topratedload = MiniLoadingDiv(self.ui.rankView, self.ui.rankWidget) - - self.slot_goto_homepage() - - #self signals - self.connect(self,Signals.apt_process_finish,self.slot_apt_process_finish) - #connect data signals - self.connect(self.appmgr, Signals.ads_ready, self.slot_advertisement_ready) - self.connect(self.appmgr, Signals.recommend_ready, self.slot_recommend_apps_ready) - self.connect(self, Signals.count_application_update,self.slot_count_application_update) - self.connect(self.appmgr, Signals.rating_reviews_ready, self.slot_rating_reviews_ready) - self.connect(self.appmgr, Signals.toprated_ready, self.slot_toprated_ready) - self.connect(self.appmgr, Signals.app_reviews_ready, self.slot_app_reviews_ready) - self.connect(self.appmgr, Signals.app_screenshots_ready, self.slot_app_screenshots_ready) - self.connect(self.appmgr, Signals.apt_cache_update_ready, self.slot_apt_cache_update_ready) - - - #conncet apt signals - self.connect(self.backend, Signals.dbus_apt_process,self.slot_status_change) - - # request init data + # init data flags self.ads_ready = False self.toprated_ready = True self.rec_ready = False self.rnr_ready = True - if self.appmgr.check_update(): - - button=QMessageBox.question(self,"软件源更新提示", - self.tr("您是第一次运行软件中心或者软件源发生变化,\n为保证软件运行正常,您需要连接网络并更新软件源!\n是否继续?"), - "跳过", "是", "否", 0) - if button == 0: - self.appmgr.get_advertisements() - self.appmgr.get_recommend_apps() - self.appmgr.get_toprated_stats() - elif button == 1: - LOG.info("update source when first start...") - self.backend.update_source() - else: - LOG.warning("dbus service init failed, you choose to exit.\n\n") - sys.exit(0) - return - else: - self.appmgr.get_advertisements() - self.appmgr.get_recommend_apps() - self.appmgr.get_toprated_stats() - #????we should decide when to call this to sync data from backend server - # self.appmgr.get_rating_review_stats() - - # base loading finish - def check_init_data_ready(self): - LOG.debug("check init data stat:%d,%d,%d,%d",self.ads_ready,self.toprated_ready,self.rec_ready,self.rnr_ready) - if self.ads_ready and self.toprated_ready and self.rec_ready and self.rnr_ready: - self.loadingDiv.stop_loading() - self.topratedload.start_loading() - # all init finished, start update cache db - # self.appmgr.update_ratings() - from backend.service.dbmanager import CacheProcess - cp = CacheProcess('get_all_ratings') - cp.daemon = True - cp.start() + # check uksc upgradable + self.check_uksc_update() - def slot_init_models_ready(self, step, message): + self.topratedload.start_loading() - if step == "fail": - LOG.warning("init models failed:%s",message) - sys.exit(0) - return - - elif step == "ok": - LOG.debug("init models successfully and ready to setup ui...") + self.appmgr.get_advertisements() + self.appmgr.get_recommend_apps() + self.appmgr.get_toprated_stats() - self.init_models() #???? + # check base init + def check_init_ready(self): + LOG.debug("check init data stat:%d,%d,%d,%d",self.ads_ready,self.toprated_ready,self.rec_ready,self.rnr_ready) + # base init finished + if self.ads_ready and self.toprated_ready and self.rec_ready and self.rnr_ready: self.ui.categoryView.setEnabled(True) self.ui.btnUp.setEnabled(True) self.ui.btnUn.setEnabled(True) self.ui.btnTask.setEnabled(True) -# self.emit(Signals.count_application_update) - - self.show() - self.ui.categoryView.show() self.ui.headerWidget.show() self.ui.centralwidget.show() self.ui.leftWidget.show() - # check uksc upgradable - self.check_uksc_update() + self.slot_goto_homepage() + self.loadingDiv.stop_loading() + self.trayicon.show() + + # base loading finish, start backend work + self.start_silent_work() + # silent background works + def start_silent_work(self): + # init pointout + self.init_pointout() + + # update cache db + self.appmgr.get_all_ratings() + + # pingback_main + self.appmgr.submit_pingback_main() + + def slot_init_models_ready(self, step, message): + if step == "fail": + LOG.warning("init models failed:%s",message) + sys.exit(0) + elif step == "ok": + LOG.debug("init models successfully and ready to setup ui...") + self.init_last_data() def init_category_view(self): cat_list_orgin = self.appmgr.get_category_list() @@ -574,6 +577,19 @@ oneitem.setWhatsThis(catname) self.ui.categoryView.addItem(oneitem) + def show_to_frontend(self): + self.show() + self.raise_() + + def mousePressEvent(self, event): + if (event.button() == Qt.LeftButton): + self.dragPosition = event.globalPos() - self.frameGeometry().topLeft() + event.accept() + + def mouseMoveEvent(self, event): + if (event.buttons() == Qt.LeftButton and self.dragPosition != -1): + self.move(event.globalPos() - self.dragPosition) + event.accept() def show_more_search_result(self, listWidget): listLen = len(listWidget) @@ -731,7 +747,32 @@ def restart_uksc(self): os.execv("/usr/bin/ubuntu-kylin-software-center", ["uksc"]) - #-------------------------------slots------------------------------- + # get the point out app + def init_pointout(self): + # check user config is show + flag = self.appmgr.get_pointout_is_show_from_db() + if(flag == True): + self.get_pointout() + + def get_pointout(self): + # find not installed pointout apps + pl = self.appmgr.get_pointout_apps_from_db() + + if(len(pl) > 0): + self.pointout.ui.contentliw.clear() + for p in pl: + oneitem = QListWidgetItem() + pliw = PointListItemWidget(p, self.backend, self) + self.connect(pliw, Signals.show_app_detail, self.slot_show_app_detail) + self.connect(pliw, Signals.install_app_rcm, self.slot_click_install_rcm) + # self.connect(pliw, Signals.install_app, self.slot_click_install) + self.pointout.ui.contentliw.addItem(oneitem) + self.pointout.ui.contentliw.setItemWidget(oneitem, pliw) + + self.pointout.show_animation() + + + #--------------------------------------slots-------------------------------------- def slot_change_category(self, citem): category = str(citem.whatsThis()) @@ -742,6 +783,8 @@ self.switch_to_category(category,False) + if(self.nowPage == "homepage"): + self.reset_nav_bar() if(self.nowPage == "homepage" and self.ui.allsWidget.isVisible() == False): self.ui.allsWidget.setVisible(True) if(self.nowPage == "uppage" and self.ui.upWidget.isVisible() == False): @@ -759,13 +802,11 @@ LOG.debug("receive ads ready, count is %d", len(adlist)) if adlist is not None: adw = ADWidget(adlist, self) - #adw.add_advertisements(adlist) (sum_inst,sum_up, sum_all) = self.appmgr.get_application_count() - # adw.update_total_count(sum_all) self.softCount.setText(str(sum_all)) self.ads_ready = True - self.check_init_data_ready() + self.check_init_ready() def slot_recommend_apps_ready(self,applist_orig): LOG.debug("receive recommend apps ready, count is %d", len(applist_orig)) @@ -794,16 +835,12 @@ recommend.move(x, y) self.rec_ready = True - self.check_init_data_ready() + self.check_init_ready() def slot_rating_reviews_ready(self,rnrlist): LOG.debug("receive ratings and reviews ready, count is %d", len(rnrlist)) print "receive ratings and reviews ready, count is:",len(rnrlist) - #app = self.appmgr.get_application_by_name("gimp") - #self.appmgr.update_rating_reviews(rnrlist) - self.rnr_ready = True - # self.check_init_data_ready() def slot_toprated_ready(self,rnrlist): LOG.debug("receive toprated apps ready, count is %d", len(rnrlist)) @@ -823,9 +860,6 @@ self.ui.rankView.setItemWidget(oneitem, rliw) self.ui.rankWidget.setVisible(True) - #????we should update this when to get latest list from backend server -# self.appmgr.update_toprated(rnrlist) - self.toprated_ready = True # self.check_init_data_ready() @@ -886,10 +920,6 @@ self.ui.btnTask.setStyleSheet("QPushButton{background-image:url('res/nav-task-1.png');border:0px;}QPushButton:hover{background:url('res/nav-task-2.png');}QPushButton:pressed{background:url('res/nav-task-3.png');}") def slot_goto_uppage(self, ishistory=False): - - #???????? -# self.emit(Signals.update_source,False) - if(ishistory == False): self.history.history_add(self.slot_goto_uppage) @@ -1000,6 +1030,16 @@ def slot_show_config(self): self.configWidget.show() + def slot_show_or_hide(self): + if(self.isHidden()): + self.show() + else: + self.hide() + + def slot_trayicon_activated(self, reason): + if(reason == QSystemTrayIcon.Trigger): + self.slot_show_or_hide() + def slot_click_ad(self, ad): if(ad.type == "pkg"): app = self.appmgr.get_application_by_name(ad.urlorpkgid) @@ -1047,10 +1087,19 @@ def slot_click_install(self, app): LOG.info("add an install task:%s",app.name) + self.appmgr.submit_pingback_app(app.name) res = self.backend.install_package(app.name) if res: self.add_task_item(app) + def slot_click_install_rcm(self, app): + LOG.info("add an install task:%s",app.name) + self.appmgr.submit_pingback_app(app.name, isrcm=True) + res = self.backend.install_package(app.name) + if res: + self.add_task_item(app) + + def slot_click_upgrade(self, app): LOG.info("add an upgrade task:%s",app.name) @@ -1083,7 +1132,6 @@ reslist = self.searchDB.search_software(s) - #返回查询结果 LOG.debug("search result:%d",len(reslist)) self.searchList = reslist count = 0 @@ -1101,69 +1149,69 @@ # name:app name ; processtype:fetch/apt ; def slot_status_change(self, name, processtype, action, percent, msg): - if action == AppActions.UPDATE: if int(percent) == 0: self.configWidget.slot_update_status_change(1) elif int(percent) == 100: self.configWidget.slot_update_status_change(99) + elif int(percent) >= 200: + self.appmgr.update_models(AppActions.UPDATE,"") else: self.configWidget.slot_update_status_change(percent) + elif action == AppActions.UPDATE_FIRST: if int(percent) >= 200: - self.appmgr.update_models(AppActions.UPDATE,"") - - if self.stmap.has_key(name) is False: - LOG.warning("there is no task for this app:%s",name) + self.appmgr.update_models(AppActions.UPDATE_FIRST,"") + else: + self.updateSinglePB.value_change(percent) else: - taskItem = self.stmap[name] if processtype=='cancel': - print "####cancel:",name,action - self.del_task_item(name) - del self.stmap[name] self.emit(Signals.apt_process_cancel,name,action) + + if self.stmap.has_key(name) is False: + print "has no key : ",name + LOG.warning("there is no task for this app:%s",name) else: - if processtype=='apt' and int(percent)>=200: - self.emit(Signals.apt_process_finish,name,action) + taskItem = self.stmap[name] + if processtype=='cancel': + self.del_task_item(name) + del self.stmap[name] + #self.emit(Signals.apt_process_cancel,name,action) else: - taskItem.status_change(processtype, percent, msg) + if processtype=='apt' and int(percent)>=200: + self.emit(Signals.apt_process_finish,name,action) + else: + taskItem.status_change(processtype, percent, msg) # call the backend models update opeartion def slot_apt_process_finish(self,pkgname,action): - print "slot_apt_process_finish:",pkgname,action - self.appmgr.update_models(action,pkgname) - #update backend models ready + # update backend models ready def slot_apt_cache_update_ready(self, action, pkgname): - - (inst,up, all) = self.appmgr.get_application_count(self.category) - (cat_inst,cat_up, cat_all) = self.appmgr.get_application_count() - - self.emit(Signals.count_application_update) - - #msg = "软件" + str(pkgname) + AptActionMsg[action] + "操作完成" - msg = "软件" + AptActionMsg[action] + "操作完成" - - if(action == AppActions.UPDATE): - self.configWidget.slot_update_finish() - if(self.configWidget.iscanceled == True): - self.messageBox.alert_msg("已取消更新软件源") - else: - self.messageBox.alert_msg(msg) - - #restart uksc when finish update - if self.appmgr.check_update(): - self.appmgr.get_advertisements() - self.appmgr.get_recommend_apps() - self.appmgr.get_toprated_stats() - + if(action == AppActions.UPDATE_FIRST): + self.updateSinglePB.hide() + self.appmgr.init_models() else: - if(pkgname == "ubuntu-kylin-software-center"): - cd = ConfirmDialog("软件中心升级完成,重启程序?", self) - self.connect(cd, SIGNAL("confirmdialogok"), self.restart_uksc) - cd.exec_() + (inst,up, all) = self.appmgr.get_application_count(self.category) + (cat_inst,cat_up, cat_all) = self.appmgr.get_application_count() + self.emit(Signals.count_application_update) + + msg = "软件" + AptActionMsg[action] + "操作完成" + + if(action == AppActions.UPDATE): + self.configWidget.slot_update_finish() + if(self.configWidget.iscanceled == True): + self.messageBox.alert_msg("已取消更新软件源") + else: + self.messageBox.alert_msg(msg) else: - self.messageBox.alert_msg(msg) + if(pkgname == "ubuntu-kylin-software-center"): + cd = ConfirmDialog("软件中心升级完成,重启程序?", self) + self.connect(cd, SIGNAL("confirmdialogok"), self.restart_uksc) + cd.exec_() + else: + self.messageBox.alert_msg(msg) + def main(): app = QApplication(sys.argv) @@ -1172,20 +1220,23 @@ QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8")) globalfont = QFont() - globalfont.setFamily("文泉驿微米黑") - # globalfont.setFamily("华文细黑") + globalfont.setFamily("文泉驿微米黑") # 文泉驿微米黑 文泉驿等宽微米黑 华文细黑 app.setFont(globalfont) app.setWindowIcon(QIcon(UBUNTUKYLIN_RES_PATH +"uksc.png")) + # check show quiet (only trayicon) + argn = len(sys.argv) + if(argn == 1): + Globals.LAUNCH_MODE = 'normal' + elif(argn > 1): + arg = sys.argv[1] + if(arg == '-quiet'): + Globals.LAUNCH_MODE = 'quiet' + mw = SoftwareCenter() - mw.show() sys.exit(app.exec_()) if __name__ == '__main__': - - main() - - - + main() \ No newline at end of file diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/configwidget.py ubuntu-kylin-software-center-0.3.2.0/ui/configwidget.py --- ubuntu-kylin-software-center-0.3.1.0/ui/configwidget.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/configwidget.py 2014-07-14 08:52:43.000000000 +0000 @@ -30,13 +30,14 @@ class ConfigWidget(QWidget): - sourcelist = '' + mainw = '' iscanceled = '' def __init__(self, parent=None): QWidget.__init__(self,parent) self.ui_init() + self.mainw = parent self.backend = parent.backend self.setWindowFlags(Qt.FramelessWindowHint) @@ -66,18 +67,27 @@ self.ui.lesource.textChanged.connect(self.slot_le_input) self.ui.cbhideubuntu.stateChanged.connect(self.slot_checkstate_changed) self.ui.btnCancel.clicked.connect(self.slot_click_cancel) + self.ui.pageListWidget.itemClicked.connect(self.slot_item_clicked) self.ui.text1.setText("软件源列表") self.ui.cbhideubuntu.setText("隐藏ubuntu源") self.ui.btnUpdate.setText(" 更新软件源") self.ui.btnAdd.setText(" 添加软件源") self.ui.btnReset.setText("恢复默认设置") + sourceitem = QListWidgetItem("软件源设置") icon = QIcon() icon.addFile("res/source.png", QSize(), QIcon.Normal, QIcon.Off) sourceitem.setIcon(icon) self.ui.pageListWidget.addItem(sourceitem) + pointoutitem = QListWidgetItem("软件推荐页") + pointoutitem.setWhatsThis('pointout') + icon = QIcon() + icon.addFile("res/ubuntukylin.png", QSize(), QIcon.Normal, QIcon.Off) + pointoutitem.setIcon(icon) + self.ui.pageListWidget.addItem(pointoutitem) + self.ui.bg.setStyleSheet("QLabel{background-image:url('res/configwidget.png');}") self.ui.text1.setStyleSheet("QLabel{color:#1E66A4;font-size:14px;}") self.ui.line1.setStyleSheet("QLabel{background-color:#E0E0E0;}") @@ -168,6 +178,10 @@ def slot_checkstate_changed(self): self.fill_sourcelist() + def slot_item_clicked(self, item): + if(item.whatsThis() == 'pointout'): + self.mainw.pointout.show_animation() + class SourceItemWidget(QWidget): confw = '' @@ -213,7 +227,7 @@ def slot_remove_source(self): source = str(self.type) + " " + str(self.sourcetext.text().toUtf8()) - self.confw.sourcelist.remove_source(source) + self.confw.backend.remove_source(source) self.confw.fill_sourcelist() diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/detailscrollwidget.py ubuntu-kylin-software-center-0.3.2.0/ui/detailscrollwidget.py --- ubuntu-kylin-software-center-0.3.1.0/ui/detailscrollwidget.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/detailscrollwidget.py 2014-07-14 08:52:43.000000000 +0000 @@ -172,11 +172,17 @@ size = app.packageSize sizek = size / 1024 - #self.ui.size.setText("软件大小: " + str(sizek) + " K") if(sizek < 1024): - self.ui.size.setText("软件大小: " + str(sizek) + " KB") + self.ui.size.setText("下载大小: " + str(sizek) + " KB") else: - self.ui.size.setText("软件大小: " + str('%.2f'%(sizek/1024.0)) + " MB") + self.ui.size.setText("下载大小: " + str('%.2f'%(sizek/1024.0)) + " MB") + + installedsize = app.installedSize + installedsizek = installedsize / 1024 + if(installedsizek < 1024): + self.ui.size_install.setText("安装大小: " + str(installedsizek) + " KB") + else: + self.ui.size_install.setText("安装大小: " + str('%.2f'%(installedsizek/1024.0)) + " MB") self.ui.gradeText1.setText("我的评分: ") self.ui.gradeText2.setText("评分" + (str(app.ratings_total)) + "次") diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/detailw.py ubuntu-kylin-software-center-0.3.2.0/ui/detailw.py --- ubuntu-kylin-software-center-0.3.1.0/ui/detailw.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/detailw.py 2014-07-14 08:52:43.000000000 +0000 @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'detailw.ui' # -# Created: Mon Jun 16 15:04:12 2014 +# Created: Wed Jun 25 10:10:06 2014 # by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! @@ -56,7 +56,7 @@ self.installedVersion.setText(_fromUtf8("")) self.installedVersion.setObjectName(_fromUtf8("installedVersion")) self.size = QtGui.QLabel(DetailWidget) - self.size.setGeometry(QtCore.QRect(330, 87, 140, 18)) + self.size.setGeometry(QtCore.QRect(330, 90, 140, 18)) self.size.setText(_fromUtf8("")) self.size.setObjectName(_fromUtf8("size")) self.gradeBG = QtGui.QLabel(DetailWidget) @@ -145,6 +145,10 @@ self.sshot.setGeometry(QtCore.QRect(350, 530, 1, 1)) self.sshot.setText(_fromUtf8("")) self.sshot.setObjectName(_fromUtf8("sshot")) + self.size_install = QtGui.QLabel(DetailWidget) + self.size_install.setGeometry(QtCore.QRect(330, 111, 140, 18)) + self.size_install.setText(_fromUtf8("")) + self.size_install.setObjectName(_fromUtf8("size_install")) self.retranslateUi(DetailWidget) QtCore.QMetaObject.connectSlotsByName(DetailWidget) diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/detailw.ui ubuntu-kylin-software-center-0.3.2.0/ui/detailw.ui --- ubuntu-kylin-software-center-0.3.1.0/ui/detailw.ui 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/detailw.ui 2014-07-14 08:52:43.000000000 +0000 @@ -108,7 +108,7 @@ 330 - 87 + 90 140 18 @@ -404,6 +404,19 @@ + + + + + + + 330 + 111 + 140 + 18 + + + diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/listitemwidget.py ubuntu-kylin-software-center-0.3.2.0/ui/listitemwidget.py --- ubuntu-kylin-software-center-0.3.1.0/ui/listitemwidget.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/listitemwidget.py 2014-07-14 08:52:43.000000000 +0000 @@ -86,12 +86,15 @@ # summ += "..." self.ui.descr.setText(summ) - size = app.packageSize - sizek = size / 1024 - if(sizek < 1024): - self.ui.size.setText(str(sizek) + " KB") - else: - self.ui.size.setText(str('%.2f'%(sizek/1024.0)) + " MB") + # size = app.packageSize + # sizek = size / 1024 + # if(sizek < 1024): + # self.ui.size.setText(str(sizek) + " KB") + # else: + # self.ui.size.setText(str('%.2f'%(sizek/1024.0)) + " MB") + self.ui.size.setAlignment(Qt.AlignCenter) + self.ui.size.setText("安装后:") + # print "########item size:",app.name,app.packageSize,app.installedSize installedsize = app.installedSize installedsizek = installedsize / 1024 diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/messagebox.py ubuntu-kylin-software-center-0.3.2.0/ui/messagebox.py --- ubuntu-kylin-software-center-0.3.1.0/ui/messagebox.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/messagebox.py 2014-07-14 08:52:43.000000000 +0000 @@ -79,4 +79,4 @@ def slot_hide_alert(self): self.alert.hide() - self.alertDelayTimer.stop() \ No newline at end of file + self.alertDelayTimer.stop() diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/pointlistitemwidget.py ubuntu-kylin-software-center-0.3.2.0/ui/pointlistitemwidget.py --- ubuntu-kylin-software-center-0.3.1.0/ui/pointlistitemwidget.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/pointlistitemwidget.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,132 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE + +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd + +# Author: +# Shine Huang +# Maintainer: +# Shine Huang + +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +import os +from PyQt4.QtGui import * +from PyQt4.QtCore import * +from ui.ukpliw import Ui_Ukpliw +from utils import run +from models.enums import (ITEM_LABEL_STYLE, + UBUNTUKYLIN_RES_TMPICON_PATH, + UBUNTUKYLIN_RES_ICON_PATH, + LIST_BUTTON_STYLE, + UBUNTUKYLIN_RES_PATH, + RECOMMEND_BUTTON_STYLE, + AppActions, + Signals) + +class PointListItemWidget(QWidget): + app = '' + + def __init__(self, app, backend, parent=None): + QWidget.__init__(self,parent) + self.ui_init() + self.app = app + self.backend = backend + self.parent = parent + + self.ui.candidateVersion.setAlignment(Qt.AlignRight) + self.ui.installedsize.setAlignment(Qt.AlignRight) + self.ui.btn.setFocusPolicy(Qt.NoFocus) + # self.ui.btnDetail.setFocusPolicy(Qt.NoFocus) + # self.ui.btnDetail.setText("详情") + self.ui.btnDetail.hide() + + + if(os.path.isfile(UBUNTUKYLIN_RES_ICON_PATH + str(self.app.name) + ".png")): + self.ui.icon.setStyleSheet(ITEM_LABEL_STYLE % (UBUNTUKYLIN_RES_ICON_PATH + app.name+".png")) + elif(os.path.isfile(UBUNTUKYLIN_RES_ICON_PATH + str(self.app.name) + ".jpg")): + self.ui.icon.setStyleSheet(ITEM_LABEL_STYLE % (UBUNTUKYLIN_RES_ICON_PATH + app.name+".jpg")) + elif(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name+".png")): + self.ui.icon.setStyleSheet(ITEM_LABEL_STYLE % (UBUNTUKYLIN_RES_TMPICON_PATH + app.name+".png")) + elif(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name+".jpg")): + self.ui.icon.setStyleSheet(ITEM_LABEL_STYLE % (UBUNTUKYLIN_RES_TMPICON_PATH + app.name+".jpg")) + else: + self.ui.icon.setStyleSheet(ITEM_LABEL_STYLE % (UBUNTUKYLIN_RES_TMPICON_PATH + "default.png")) + # self.ui.btnDetail.setStyleSheet(RECOMMEND_BUTTON_STYLE %(UBUNTUKYLIN_RES_PATH+"btn6-1.png",UBUNTUKYLIN_RES_PATH+"btn6-2.png",UBUNTUKYLIN_RES_PATH+"btn6-3.png")) + self.ui.name.setStyleSheet("QLabel{font-size:14px;font-weight:bold;}") + self.ui.descr.setStyleSheet("QLabel{font-size:13px;color:#7E8B97;}") + self.ui.installedsize.setStyleSheet("QLabel{font-size:13px;}") + self.ui.candidateVersion.setStyleSheet("QLabel{font-size:13px;color:#FF7D15;}") + self.ui.btn.setStyleSheet(LIST_BUTTON_STYLE % (UBUNTUKYLIN_RES_PATH+"btn-small2-1.png",UBUNTUKYLIN_RES_PATH+"btn-small2-2.png",UBUNTUKYLIN_RES_PATH+"btn-small2-3.png") ) + + self.ui.name.setText(app.displayname) + summ = app.summary + self.ui.descr.setText(summ) + + installedsize = app.packageSize + installedsizek = installedsize / 1024 + if(installedsizek < 1024): + self.ui.installedsize.setText("大小: " + str(installedsizek) + " KB") + else: + self.ui.installedsize.setText("大小: " + str('%.2f'%(installedsizek/1024.0)) + " MB") + + self.ui.candidateVersion.setText("版本: " + app.candidate_version) + + self.ui.btn.setText("安装") + + self.ui.btn.clicked.connect(self.slot_btn_click) + self.ui.btnDetail.clicked.connect(self.slot_emit_detail) + self.connect(self.parent,Signals.apt_process_finish,self.slot_work_finished) + self.connect(self.parent,Signals.apt_process_cancel,self.slot_work_cancel) + + def ui_init(self): + self.ui = Ui_Ukpliw() + self.ui.setupUi(self) + self.show() + + # def enterEvent(self, event): + # self.ui.btnDetail.show() + # + # def leaveEvent(self, event): + # self.ui.btnDetail.hide() + + def slot_btn_click(self): + if(self.ui.btn.text() == "启动"): + run.run_app(self.app.name) + else: + self.ui.btn.setEnabled(False) + self.ui.btn.setText("处理中") + # self.emit(Signals.install_app, self.app) + self.emit(Signals.install_app_rcm, self.app) + self.parent.slot_goto_taskpage() + self.parent.show() + + def slot_emit_detail(self): + self.emit(Signals.show_app_detail, self.app) + + def slot_work_finished(self, pkgname, action): + if self.app.name == pkgname: + if(run.get_run_command(self.app.name) == ""): + self.ui.btn.setText("已安装") + self.ui.btn.setEnabled(False) + else: + self.ui.btn.setText("启动") + self.ui.btn.setEnabled(True) + + + def slot_work_cancel(self, pkgname, action): + if self.app.name == pkgname: + self.ui.btn.setText("安装") + self.ui.btn.setEnabled(True) \ No newline at end of file diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/pointoutwidget.py ubuntu-kylin-software-center-0.3.2.0/ui/pointoutwidget.py --- ubuntu-kylin-software-center-0.3.1.0/ui/pointoutwidget.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/pointoutwidget.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,134 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE + +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd + +# Author: +# Shine Huang +# Maintainer: +# Shine Huang + +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + + +from PyQt4.QtGui import * +from PyQt4.QtCore import * +from ui.pointoutw import Ui_PointWidget + + +class PointOutWidget(QWidget): + + # main window + mainw = '' + # move timer + pointoutTimer = '' + # opacity effect + pointoutGOE = '' + # opacity + po = '' + # target y + ty = '' + + def __init__(self, parent=None): + QWidget.__init__(self,None) + self.ui_init() + + self.setWindowFlags(Qt.FramelessWindowHint) + self.setAttribute(Qt.WA_TranslucentBackground, True) + self.setWindowTitle("推荐安装") + + self.mainw = parent + + desktopw = QDesktopWidget() + self.dwidth = desktopw.screenGeometry().width() + self.dheight = desktopw.screenGeometry().height() + self.px = self.dwidth - self.width() + self.py = self.dheight + self.ty = self.dheight - self.height() + + self.pointoutTimer = QTimer(self) + self.pointoutTimer.timeout.connect(self.slot_show_animation_step) + self.pointoutGOE = QGraphicsOpacityEffect() + self.setGraphicsEffect(self.pointoutGOE) + + self.ui.cbisshow.setText("下次启动提示") + self.ui.title.setText("安装以下常用软件 提高系统使用体验") + + self.ui.contentliw.setFocusPolicy(Qt.NoFocus) + self.ui.cbisshow.setFocusPolicy(Qt.NoFocus) + + self.ui.btnClose.clicked.connect(self.hide) + self.ui.cbisshow.stateChanged.connect(self.slot_checkstate_changed) + + self.ui.header.setStyleSheet("QLabel{background-image:url('res/pointheader.png');}") + self.ui.btnClose.setStyleSheet("QPushButton{background-image:url('res/close-2.png');border:0px;}QPushButton:hover{background:url('res/close-2.png');}QPushButton:pressed{background:url('res/close-3.png');}") + self.ui.title.setStyleSheet("QLabel{background-color:#E7EDF0;font-size:14px;padding-left:10px;}") + self.ui.bottom.setStyleSheet("QLabel{background-color:white;}") + self.ui.cbisshow.setStyleSheet("QCheckBox{border:0px;font-size:13px;}") + self.ui.contentliw.setStyleSheet("QListWidget{border:0px;}QListWidget::item{height:74px;margin-top:-1px;border:1px solid #d5e3ec;}") + self.ui.contentliw.verticalScrollBar().setStyleSheet("QScrollBar:vertical{width:5px;background-color:black;margin:0px,0px,0px,0px;padding-top:0px;padding-bottom:0px;}" + "QScrollBar:sub-page:vertical{background:qlineargradient(x1: 0.5, y1: 1, x2: 0.5, y2: 0, stop: 0 #D4DCE1, stop: 1 white);}QScrollBar:add-page:vertical{background:qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 #D4DCE1, stop: 1 white);}" + "QScrollBar:handle:vertical{background:qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #CACACA, stop: 1 #818486);}QScrollBar:add-line:vertical{background-color:green;}") + + def ui_init(self): + self.ui = Ui_PointWidget() + self.ui.setupUi(self) + self.show() + + def slot_checkstate_changed(self): + flag = self.ui.cbisshow.isChecked() + self.mainw.appmgr.set_pointout_is_show(flag) + + def show_animation(self): + flag = self.mainw.appmgr.get_pointout_is_show_from_db() + self.ui.cbisshow.setChecked(flag) + + self.py = self.dheight + self.move(self.px, self.py) + self.po = 0.0 + self.pointoutGOE.setOpacity(self.po) + self.show() + self.pointoutTimer.start(12) + + def slot_show_animation_step(self): + if(self.po < 1): + self.po += 0.011 + self.pointoutGOE.setOpacity(self.po) + if(self.py > self.ty): + self.py -= 4 + self.move(self.x(), self.py) + else: + self.pointoutTimer.stop() + self.move(self.x(), self.ty) + self.pointoutGOE.setOpacity(self.po) + + +def main(): + import sys + app = QApplication(sys.argv) + + QTextCodec.setCodecForTr(QTextCodec.codecForName("UTF-8")) + QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8")) + + globalfont = QFont() + globalfont.setFamily("文泉驿微米黑") + app.setFont(globalfont) + a = PointOutWidget() + a.show_animation() + + sys.exit(app.exec_()) + +if __name__ == "__main__": + main() \ No newline at end of file diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/pointoutw.py ubuntu-kylin-software-center-0.3.2.0/ui/pointoutw.py --- ubuntu-kylin-software-center-0.3.1.0/ui/pointoutw.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/pointoutw.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'pointoutw.ui' +# +# Created: Fri Jun 20 10:19:14 2014 +# by: PyQt4 UI code generator 4.10.4 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_PointWidget(object): + def setupUi(self, PointWidget): + PointWidget.setObjectName(_fromUtf8("PointWidget")) + PointWidget.resize(413, 355) + self.header = QtGui.QLabel(PointWidget) + self.header.setGeometry(QtCore.QRect(0, 0, 413, 69)) + self.header.setText(_fromUtf8("")) + self.header.setObjectName(_fromUtf8("header")) + self.title = QtGui.QLabel(PointWidget) + self.title.setGeometry(QtCore.QRect(0, 69, 413, 34)) + self.title.setText(_fromUtf8("")) + self.title.setObjectName(_fromUtf8("title")) + self.contentliw = QtGui.QListWidget(PointWidget) + self.contentliw.setGeometry(QtCore.QRect(0, 103, 413, 225)) + self.contentliw.setObjectName(_fromUtf8("contentliw")) + self.btnClose = QtGui.QPushButton(PointWidget) + self.btnClose.setGeometry(QtCore.QRect(393, 5, 15, 15)) + self.btnClose.setText(_fromUtf8("")) + self.btnClose.setObjectName(_fromUtf8("btnClose")) + self.bottom = QtGui.QLabel(PointWidget) + self.bottom.setGeometry(QtCore.QRect(0, 328, 413, 29)) + self.bottom.setText(_fromUtf8("")) + self.bottom.setObjectName(_fromUtf8("bottom")) + self.cbisshow = QtGui.QCheckBox(PointWidget) + self.cbisshow.setGeometry(QtCore.QRect(10, 330, 120, 22)) + self.cbisshow.setText(_fromUtf8("")) + self.cbisshow.setObjectName(_fromUtf8("cbisshow")) + + self.retranslateUi(PointWidget) + QtCore.QMetaObject.connectSlotsByName(PointWidget) + + def retranslateUi(self, PointWidget): + PointWidget.setWindowTitle(_translate("PointWidget", "Form", None)) + diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/pointoutw.ui ubuntu-kylin-software-center-0.3.2.0/ui/pointoutw.ui --- ubuntu-kylin-software-center-0.3.1.0/ui/pointoutw.ui 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/pointoutw.ui 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,94 @@ + + + PointWidget + + + + 0 + 0 + 413 + 355 + + + + Form + + + + + 0 + 0 + 413 + 69 + + + + + + + + + + 0 + 69 + 413 + 34 + + + + + + + + + + 0 + 103 + 413 + 225 + + + + + + + 393 + 5 + 15 + 15 + + + + + + + + + + 0 + 328 + 413 + 29 + + + + + + + + + + 10 + 330 + 120 + 22 + + + + + + + + + + diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/singleprocessbar.py ubuntu-kylin-software-center-0.3.2.0/ui/singleprocessbar.py --- ubuntu-kylin-software-center-0.3.1.0/ui/singleprocessbar.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/singleprocessbar.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE + +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd + +# Author: +# Shine Huang +# Maintainer: +# Shine Huang + +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + + +from PyQt4.QtGui import * +from PyQt4.QtCore import * + +class SingleProcessBar(QWidget): + + def __init__(self, parent=None): + QWidget.__init__(self,parent) + self.setGeometry(815 / 2 - 96, 417, 197, 17) + + self.progressBar = QProgressBar(self) + self.progressBar.setGeometry(0, 0, 194, 17) + self.progressBar.setRange(0,100) + self.progressBar.reset() + self.progressBar.setStyleSheet("QProgressBar{background-image:url('res/progressbg2.png');border:0px;border-radius:0px;text-align:center;color:#1E66A4;}" + "QProgressBar:chunk{background-image:url('res/progress2.png');}") + + self.hide() + + def value_change(self, percent): + if percent <= 100: + self.progressBar.setValue(percent) \ No newline at end of file diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/tasklistitemwidget.py ubuntu-kylin-software-center-0.3.2.0/ui/tasklistitemwidget.py --- ubuntu-kylin-software-center-0.3.1.0/ui/tasklistitemwidget.py 2014-06-18 00:46:59.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/tasklistitemwidget.py 2014-07-14 08:52:43.000000000 +0000 @@ -28,7 +28,7 @@ from PyQt4.QtCore import * from ui.uktliw import Ui_TaskLIWidget from models.enums import Signals,AptActionMsg -from models.enums import UBUNTUKYLIN_RES_TMPICON_PATH +from models.enums import UBUNTUKYLIN_RES_TMPICON_PATH,UBUNTUKYLIN_RES_ICON_PATH class TaskListItemWidget(QWidget): @@ -55,12 +55,16 @@ self.connect(self.parent,Signals.apt_process_finish,self.slot_work_finished) img = '' - if(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".png")): - img = QPixmap("data/tmpicons/" + app.name + ".png") + if(os.path.isfile(UBUNTUKYLIN_RES_ICON_PATH + app.name + ".png")): + img = QPixmap(UBUNTUKYLIN_RES_ICON_PATH + app.name + ".png") + elif(os.path.isfile(UBUNTUKYLIN_RES_ICON_PATH + app.name + ".jpg")): + img = QPixmap(UBUNTUKYLIN_RES_ICON_PATH + app.name + ".jpg") + elif(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".png")): + img = QPixmap(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".png") elif(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".jpg")): - img = QPixmap("data/tmpicons/" + app.name + ".jpg") + img = QPixmap(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".jpg") else: - img = QPixmap("data/tmpicons/default.jpg") + img = QPixmap(UBUNTUKYLIN_RES_TMPICON_PATH + "default.jpg") img = img.scaled(32, 32) self.ui.icon.setPixmap(img) @@ -68,7 +72,10 @@ size = app.packageSize sizek = size / 1024 - self.ui.size.setText(str(sizek) + " K") + if(sizek < 1024): + self.ui.size.setText(str(sizek) + " KB") + else: + self.ui.size.setText(str('%.2f'%(sizek/1024.0)) + " MB") self.ui.progressBar.setRange(0,100) self.ui.progressBar.reset() diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/ukpliw.py ubuntu-kylin-software-center-0.3.2.0/ui/ukpliw.py --- ubuntu-kylin-software-center-0.3.1.0/ui/ukpliw.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/ukpliw.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'ukpliw.ui' +# +# Created: Mon Jun 30 10:24:39 2014 +# by: PyQt4 UI code generator 4.10.4 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_Ukpliw(object): + def setupUi(self, Ukpliw): + Ukpliw.setObjectName(_fromUtf8("Ukpliw")) + Ukpliw.resize(413, 74) + self.icon = QtGui.QLabel(Ukpliw) + self.icon.setGeometry(QtCore.QRect(12, 14, 48, 48)) + self.icon.setText(_fromUtf8("")) + self.icon.setObjectName(_fromUtf8("icon")) + self.name = QtGui.QLabel(Ukpliw) + self.name.setGeometry(QtCore.QRect(69, 19, 131, 18)) + self.name.setText(_fromUtf8("")) + self.name.setObjectName(_fromUtf8("name")) + self.descr = QtGui.QLabel(Ukpliw) + self.descr.setGeometry(QtCore.QRect(69, 38, 155, 18)) + self.descr.setText(_fromUtf8("")) + self.descr.setObjectName(_fromUtf8("descr")) + self.btn = QtGui.QPushButton(Ukpliw) + self.btn.setGeometry(QtCore.QRect(340, 28, 47, 20)) + self.btn.setText(_fromUtf8("")) + self.btn.setObjectName(_fromUtf8("btn")) + self.candidateVersion = QtGui.QLabel(Ukpliw) + self.candidateVersion.setGeometry(QtCore.QRect(200, 19, 120, 18)) + self.candidateVersion.setText(_fromUtf8("")) + self.candidateVersion.setObjectName(_fromUtf8("candidateVersion")) + self.btnDetail = QtGui.QPushButton(Ukpliw) + self.btnDetail.setGeometry(QtCore.QRect(16, 29, 40, 18)) + self.btnDetail.setText(_fromUtf8("")) + self.btnDetail.setObjectName(_fromUtf8("btnDetail")) + self.installedsize = QtGui.QLabel(Ukpliw) + self.installedsize.setGeometry(QtCore.QRect(220, 38, 100, 18)) + self.installedsize.setText(_fromUtf8("")) + self.installedsize.setObjectName(_fromUtf8("installedsize")) + + self.retranslateUi(Ukpliw) + QtCore.QMetaObject.connectSlotsByName(Ukpliw) + + def retranslateUi(self, Ukpliw): + Ukpliw.setWindowTitle(_translate("Ukpliw", "Form", None)) + diff -Nru ubuntu-kylin-software-center-0.3.1.0/ui/ukpliw.ui ubuntu-kylin-software-center-0.3.2.0/ui/ukpliw.ui --- ubuntu-kylin-software-center-0.3.1.0/ui/ukpliw.ui 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/ui/ukpliw.ui 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,110 @@ + + + Ukpliw + + + + 0 + 0 + 413 + 74 + + + + Form + + + + + 12 + 14 + 48 + 48 + + + + + + + + + + 69 + 19 + 131 + 18 + + + + + + + + + + 69 + 38 + 155 + 18 + + + + + + + + + + 340 + 28 + 47 + 20 + + + + + + + + + + 200 + 19 + 120 + 18 + + + + + + + + + + 16 + 29 + 40 + 18 + + + + + + + + + + 220 + 38 + 100 + 18 + + + + + + + + + + diff -Nru ubuntu-kylin-software-center-0.3.1.0/utils/machine.py ubuntu-kylin-software-center-0.3.2.0/utils/machine.py --- ubuntu-kylin-software-center-0.3.1.0/utils/machine.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/utils/machine.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,79 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE + +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd + +# Author: +# Shine Huang +# Maintainer: +# Shine Huang + +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +import os +import platform +from models.globals import Globals + + +# the machine-id which from dbus calculates +def get_machine_id(): + fpath = '/var/lib/dbus/machine-id' + if(os.path.exists(fpath) and os.path.isfile(fpath)): + f = open(fpath, 'r') + id = f.read() + f.close() + id = id.replace('\n','') + if(id == ''): + return 'unknown' + else: + return id + else: + return 'unknown' + +# the linux distribution of this machine +def get_distro_info(): + ufpath = '/etc/ubuntukylin-release' + if(os.path.exists(ufpath) and os.path.isfile(ufpath)): + uf = open(ufpath) + lines = uf.readlines() + rtn = [] + for line in lines: + kv = line.split('=') + if (kv[0] == 'DISTRIB_ID'): + v = kv[1] + rtn.append(v[:-1]) + if (kv[0] == 'DISTRIB_RELEASE'): + v = kv[1] + rtn.append(v[:-1]) + uf.close() + return rtn + else: + dist = platform.dist() + distname = dist[0] + distversion = dist[1] + return [distname, distversion] + +# uksc version +def get_uksc_version(): + return Globals.UKSC_VERSION + + +def main(): + print get_machine_id() + print get_distro_info() + print get_uksc_version() + +if __name__ == '__main__': + main() diff -Nru ubuntu-kylin-software-center-0.3.1.0/utils/slientprocess.py ubuntu-kylin-software-center-0.3.2.0/utils/slientprocess.py --- ubuntu-kylin-software-center-0.3.1.0/utils/slientprocess.py 1970-01-01 00:00:00.000000000 +0000 +++ ubuntu-kylin-software-center-0.3.2.0/utils/slientprocess.py 2014-07-14 08:52:43.000000000 +0000 @@ -0,0 +1,114 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE + +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd + +# Author: +# Shine Huang +# Maintainer: +# Shine Huang + +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +import sqlite3 +import os +import time +from PyQt4.QtGui import * +from PyQt4.QtCore import * +import multiprocessing +from backend.remote.piston_remoter import PistonRemoter +from utils.machine import * +from models.review import Review +from models.enums import UBUNTUKYLIN_SERVER,UBUNTUKYLIN_DATA_PATH,UKSC_CACHE_DIR,UnicodeToAscii + +DB_PATH = os.path.join(UBUNTUKYLIN_DATA_PATH,"uksc.db") + + +class SlientProcess(multiprocessing.Process): + + def __init__(self, squeue): + super(SlientProcess, self).__init__() + multiprocessing.Process.__init__(self) + + self.daemon = True + self.squeue = squeue + + self.premoter = PistonRemoter(service_root=UBUNTUKYLIN_SERVER) + + def run(self): + while True: + workqueuelen = self.squeue.qsize() + # print "silent worklist size : ", str(workqueuelen) + if workqueuelen == 0: + time.sleep(1) + continue + + item = self.squeue.get_nowait() + + print "silent process get one workitem : ", item.funcname + + if item.funcname == "get_all_ratings": + self.get_all_ratings() + elif item.funcname == "submit_pingback_main": + self.submit_pingback_main() + elif item.funcname == "submit_pingback_app": + self.submit_pingback_app(item.kwargs) + + # update rating_avg and rating_total in cache db from server + def get_all_ratings(self): + reslist = self.premoter.get_all_ratings() + print "all ratings and rating_total download over : ",len(reslist) + + destFile = os.path.join(UKSC_CACHE_DIR,"uksc.db") + self.connect = sqlite3.connect(destFile, check_same_thread=False) + self.cursor = self.connect.cursor() + + for rating in reslist: + app_name = rating['app_name'] + rating_avg = str(rating['rating_avg']) + rating_total = str(rating['rating_total']) + + sql = "update application set rating_total=" + rating_total + ",rating_avg=" + rating_avg +" where app_name='" + app_name + "'" + self.cursor.execute(sql) + self.connect.commit() + + # submit pingback-main to server + def submit_pingback_main(self): + machine = get_machine_id() + distro = get_distro_info()[0] + version_os = get_distro_info()[1] + version_uksc = get_uksc_version() + + res = self.premoter.submit_pingback_main(machine, distro, version_os, version_uksc) + return res + + # submit pingback-app to server + def submit_pingback_app(self, kwargs): + app_name = kwargs["app_name"] + isrcm = kwargs["isrcm"] + machine = get_machine_id() + res = self.premoter.submit_pingback_app(app_name, machine, isrcm) + return res + + +class SilentWorkerItem: + + def __init__(self, funcname, kwargs): + self.funcname = funcname + self.kwargs = kwargs + + +if __name__ == "__main__": + pass \ No newline at end of file