comparison src/core/sat_main.py @ 1598:b144babc2658

core, plugin file: fixed progress id + data is now returned by getProgress, instead of being an argument to fill
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:20:33 +0100
parents a3d0cfa5b7a6
children e2ed8009e66e
comparison
equal deleted inserted replaced
1597:91a605feed8c 1598:b144babc2658
809 except KeyError: 809 except KeyError:
810 log.error(_(u"Trying to remove an unknow progress callback")) 810 log.error(_(u"Trying to remove an unknow progress callback"))
811 811
812 def _progressGet(self, progress_id, profile): 812 def _progressGet(self, progress_id, profile):
813 data = self.progressGet(progress_id, profile) 813 data = self.progressGet(progress_id, profile)
814 return {k: unicode(v) for k,v in data} 814 return {k: unicode(v) for k,v in data.iteritems()}
815 815
816 def progressGet(self, progress_id, profile): 816 def progressGet(self, progress_id, profile):
817 """Return a dict with progress information 817 """Return a dict with progress information
818 818
819 @param progress_id(unicode): unique id of the progressing element 819 @param progress_id(unicode): unique id of the progressing element
822 'position' (int): current possition 822 'position' (int): current possition
823 'size' (int): end_position 823 'size' (int): end_position
824 if id doesn't exists (may be a finished progression), and empty dict is returned 824 if id doesn't exists (may be a finished progression), and empty dict is returned
825 """ 825 """
826 client = self.getClient(profile) 826 client = self.getClient(profile)
827 data = {}
828 try: 827 try:
829 client._progress_cb[progress_id](progress_id, data, profile) 828 data = client._progress_cb[progress_id](progress_id, profile)
830 except KeyError: 829 except KeyError:
831 log.debug("Requested progress for unknown progress_id") 830 data = {}
832 return data 831 return data
833 832
834 def _progressGetAll(self, profile_key): 833 def _progressGetAll(self, profile_key):
835 progress_all = self.progressGetAll(profile_key) 834 progress_all = self.progressGetAll(profile_key)
836 for profile, progress_dict in progress_all.iteritems(): 835 for profile, progress_dict in progress_all.iteritems():
842 def progressGetAll(self, profile_key): 841 def progressGetAll(self, profile_key):
843 """Return all progress informations 842 """Return all progress informations
844 843
845 @param profile_key: %(doc_profile)s get all progress from this profile 844 @param profile_key: %(doc_profile)s get all progress from this profile
846 if C.PROF_KEY_ALL is used, all progress from all profiles are returned 845 if C.PROF_KEY_ALL is used, all progress from all profiles are returned
847 @return (dict[dict]): key=progress id, value=dict of data with the following keys: 846 @return (dict[dict[dict]]): a dict which map profile to progress_dict
848 'position' (int): current possition 847 progress_dict map progress_id to progress_data
849 'size' (int): end_position 848 progress_data is the same dict as returned by [progressGet]
850 """ 849 """
851 clients = self.getClients(profile_key) 850 clients = self.getClients(profile_key)
852 progress_all = {} 851 progress_all = {}
853 for client in clients: 852 for client in clients:
854 profile = client.profile 853 profile = client.profile