diff -Nur indicator-china-weather-1.0.4.old/data/indicator-china-weather.desktop indicator-china-weather-1.0.4/data/indicator-china-weather.desktop --- indicator-china-weather-1.0.4.old/data/indicator-china-weather.desktop 2013-04-07 11:15:52.756065843 +0800 +++ indicator-china-weather-1.0.4/data/indicator-china-weather.desktop 2013-04-07 12:59:43.905882979 +0800 @@ -1,10 +1,10 @@ [Desktop Entry] -Name=China Weather Indicator Applet +Name=indicator-china-weather Comment=Indicator applet for current weather conditions in China GenericName=China Weather Applet Categories=GNOME;Utility; Exec=/usr/bin/indicator-china-weather -Icon=/usr/share/indicator-china-weather/data/media/icon.png +Icon=chinaweather.png Hidden=False X-GNOME-Autostart-enabled=true Type=Application diff -Nur indicator-china-weather-1.0.4.old/debian/control indicator-china-weather-1.0.4/debian/control --- indicator-china-weather-1.0.4.old/debian/control 2013-04-07 11:15:52.756065843 +0800 +++ indicator-china-weather-1.0.4/debian/control 2013-04-07 16:28:38.240573893 +0800 @@ -14,12 +14,11 @@ Depends: gir1.2-glib-2.0, gnome-icon-theme, python-appindicator, - python-gconf, python-gobject, python-gtk2, ${shlibs:Depends}, ${misc:Depends} Recommends: python-apport -Description: indicator that displays China weather information from +Description: indicator that displays China weather information Indicator-China-Weather displays information for one place, and you can change it. diff -Nur indicator-china-weather-1.0.4.old/debian/copyright indicator-china-weather-1.0.4/debian/copyright --- indicator-china-weather-1.0.4.old/debian/copyright 2013-04-07 11:15:52.756065843 +0800 +++ indicator-china-weather-1.0.4/debian/copyright 2013-04-07 11:31:21.696068885 +0800 @@ -10,7 +10,7 @@ License: GPL-3 Files: debian/* -Copyright: 2013, Kobe Lee +Copyright: 2013, National University of Defense Technology(NUDT) & Kylin Ltd. License: GPL-3 License: GPL-3 diff -Nur indicator-china-weather-1.0.4.old/debian/indicator-china-weather.install indicator-china-weather-1.0.4/debian/indicator-china-weather.install --- indicator-china-weather-1.0.4.old/debian/indicator-china-weather.install 2013-04-07 11:15:52.756065843 +0800 +++ indicator-china-weather-1.0.4/debian/indicator-china-weather.install 2013-04-07 13:05:17.345884071 +0800 @@ -1,6 +1,7 @@ bin/indicator-china-weather usr/bin/ COPYING usr/share/indicator-china-weather/ data usr/share/indicator-china-weather/ +data/media/chinaweather.png usr/share/pixmaps/ data/indicator-china-weather.desktop etc/xdg/autostart/ data/indicator-china-weather.desktop usr/share/applications/ data/indicator-china-weather.gschema.xml usr/share/glib-2.0/schemas/ diff -Nur indicator-china-weather-1.0.4.old/indicator-china-weather.desktop.in indicator-china-weather-1.0.4/indicator-china-weather.desktop.in --- indicator-china-weather-1.0.4.old/indicator-china-weather.desktop.in 2013-04-07 11:15:52.756065843 +0800 +++ indicator-china-weather-1.0.4/indicator-china-weather.desktop.in 2013-04-07 13:03:11.889883660 +0800 @@ -1,10 +1,10 @@ [Desktop Entry] -_Name= China Weather Indicator +_Name=indicator-china-weather _Comment=A weather indicator that displays information for one place in China. GenericName=China Weather Applet Categories=GNOME;Utility; -Exec=indicator-china-weather -Icon=/usr/share/indicator-china-weather/data/media/icon.png +Exec=/usr/bin/indicator-china-weather +Icon=chinaweather.png Hidden=False X-GNOME-Autostart-enabled=true Type=Application diff -Nur indicator-china-weather-1.0.4.old/src/forecastui.py indicator-china-weather-1.0.4/src/forecastui.py --- indicator-china-weather-1.0.4.old/src/forecastui.py 2013-04-07 11:15:52.752065843 +0800 +++ indicator-china-weather-1.0.4/src/forecastui.py 2013-04-07 11:32:48.960069171 +0800 @@ -1,5 +1,23 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd +# Authors: Zhang Zhao vaguedream@hotmail.com +# Kobe Lee kobe24_lixiang@126.com +# wyan yiwuhehe@163.com +# binghe kylinhebing@163.com +# 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 . +### END LICENSE import os, sys import gtk diff -Nur indicator-china-weather-1.0.4.old/src/indicator-china-weather.py indicator-china-weather-1.0.4/src/indicator-china-weather.py --- indicator-china-weather-1.0.4.old/src/indicator-china-weather.py 2013-04-07 11:15:52.752065843 +0800 +++ indicator-china-weather-1.0.4/src/indicator-china-weather.py 2013-04-15 09:33:14.375721126 +0800 @@ -4,8 +4,11 @@ # Copyright (C) 2010 Sebastian MacDonald Sebas310@gmail.com # Copyright (C) 2010 Mehdi Rejraji mehd36@gmail.com # Copyright (C) 2011 Vadim Rutkovsky roignac@gmail.com -# Copyright (C) 2013 Zhang Zhao vaguedream@hotmail.com -# Copyright (C) 2013 Kobe Lee kobe24_lixiang@126.com +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd +# Authors: Zhang Zhao vaguedream@hotmail.com +# Kobe Lee kobe24_lixiang@126.com +# wyan yiwuhehe@163.com +# binghe kylinhebing@163.com # 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. @@ -23,13 +26,14 @@ from gi.repository import Gio except ImportError: pass -import os, sys, tempfile +import os, sys, shutil, tempfile import gtk, pygtk, gobject import commands, threading import appindicator import logging, logging.handlers import traceback import types +import time import string from xml.dom.minidom import parseString import pycwapi @@ -159,6 +163,7 @@ self.pm = {} self.places = str(self.settings.get_value("places")) self.placechosen = self.settings.get_value("placechosen") + self.actualization_time = 0 #(LP: #1153468) if self.city_id not in (False, None, '', '[]', "['']") and self.places in (False, None, '', '[]', "['']"): @@ -206,7 +211,7 @@ 'n0.gif':'weather-clear-night', 'n1.gif':'weather-few-clouds-night', 'n2.gif':'weather-few-clouds-night', - 'n3.gif':'weather-showerst', + 'n3.gif':'weather-showers', 'n4.gif':'weather-showers', 'n5.gif':'weather-showers', 'n6.gif':'weather-snow', @@ -249,6 +254,8 @@ self.update_data() #self.place = get_location_from_cityid(self.city_id) #self.pm = get_pm_from_city(self.place.split(',')[2]) + # fix bug about update time (LP: #1131556) + gobject.timeout_add_seconds(60,self.work) # Show a menu if no places specified def menu_noplace(self): @@ -374,10 +381,10 @@ self.menu.append(ext_show) ##Update Button - refresh_show = gtk.MenuItem(_("更新")) - refresh_show.connect("activate", self.update_data) - refresh_show.show() - self.menu.append(refresh_show) + self.refresh_show = gtk.MenuItem(_("更新")) + self.refresh_show.connect("activate", self.update_data) + self.refresh_show.show() + self.menu.append(self.refresh_show) ##Preferences prefs_show = gtk.MenuItem(_("配置...")) @@ -400,6 +407,8 @@ self.winder.set_menu(self.menu) self.update_label(" ") + self.work() + def on_city_changed(self,widget): if widget.get_active(): @@ -453,7 +462,6 @@ if pint > 7 or pint < 20: self.icon = self.weather_icons[self.weather_data['img1']] else : - #self.pm_show.set_label(_('PM2.5:') + self.pm['quality'] + ' ' + str(self.pm['aqi'])) self.icon = self.weather_icons[self.weather_data['img2']] self.menu_normal() self.winder.set_icon(self.icon) @@ -478,7 +486,7 @@ if not pm_flag: self.pm_show.set_label(_('PM2.5:') + 'N/A') else: - if (self.pm).has_key('error'): + if self.pm.has_key('error'): self.pm_show.set_label(_('PM2.5:') + 'N/A') else: self.pm_show.set_label(_('PM2.5:') + self.pm['quality'] + ' ' + str(self.pm['aqi'])) @@ -501,16 +509,30 @@ if self.pm.has_key('error'): self.pm_show.set_label(_('PM2.5:') + 'N/A') else: - self.pm_show.set_label('PM2.5:' + self.pm['quality'] + ' ' + str(self.pm['aqi'])) + self.pm_show.set_label(_('PM2.5:') + self.pm['quality'] + ' ' + str(self.pm['aqi'])) except Exception, e: log.error(e) log.debug(traceback.format_exc(e)) + # update time + def work(self): + ut = int(round((time.time()-self.actualization_time)/60.0,0)) + if self.actualization_time == 0 or ut == 0: + msg = '刚刚' + else: + msg = str(ut)+'分钟之前' + self.refresh_show.set_label('更新'+' ('+msg+')') + if (time.time()-self.actualization_time) > self.rate*60: + self.actualization_time = time.time() + return True + # Update weather and forecast def update_data(self, widget = None): threading.Thread(target=self.get_set_weather, name='Weather').start() threading.Thread(target=self.get_forecast, name='Forecast').start() threading.Thread(target=self.get_pm_info, name='PM25').start() + self.actualization_time = 0 + self.work() # Menu callbacks # Open Preferences dialog @@ -528,7 +550,7 @@ self.aboutdialog.set_version(VERSION) self.aboutdialog.set_copyright('Copyright (C) 2013 UbuntuKylin Team kobe24_lixiang@126.com') - self.aboutdialog.set_comments(_('天气插件:提供来自于中国气象局的六天天气预报信息,添加\n人们日益关注的PM2.5浓度,支持多城市切换和数据自动更新,\n分享每日生活指数和建议,为用户日常起居和旅行提供参考。')) + self.aboutdialog.set_comments(_('天气插件:提供来自于中国气象局的六天天气预报信息,添加\n人们日益关注的PM2.5指数,支持多城市切换和数据自动更新,\n分享每日生活指数和建议,为用户日常起居和旅行提供参考。')) ifile = open(os.path.join(PROJECT_ROOT_DIRECTORY, "COPYING"), "r") self.aboutdialog.set_license(ifile.read().replace('\x0c', '')) @@ -537,7 +559,7 @@ self.aboutdialog.set_website("https://launchpad.net/indicator-china-weather") self.aboutdialog.set_documenters(['Zhang Zhao ', 'yanwang ', 'binghe ']) self.aboutdialog.set_artists(['Ou Yangyu']) - logo_path = os.path.join(PROJECT_ROOT_DIRECTORY, "data/media/icon.png") + logo_path = os.path.join(PROJECT_ROOT_DIRECTORY, "data/media/chinaweather.png") self.aboutdialog.set_logo(gtk.gdk.pixbuf_new_from_file(logo_path)) self.aboutdialog.connect("response", self.about_close) @@ -620,7 +642,7 @@ need_to_update = False #City id if iw.city_change_flag: - iw.citget_location_from_cityidy_change_flag = False + iw.city_change_flag = False need_to_update = True #Show temperature @@ -842,11 +864,11 @@ #log.info("Weather Indicator version %s" % VERSION) # Single instance stuff for weather indicator - #myapp = SingleInstance("/tmp/indicator-china-weather-%d.pid" % os.getuid()) + myapp = SingleInstance("/tmp/indicator-china-weather-%d.pid" % os.getuid()) # check is another instance of same program running - #if myapp.is_already_running(): - #log.info("Another instance of this program is already running") - #sys.exit(_("Another instance of this program is already running")) + if myapp.is_already_running(): + log.info("Another instance of this program is already running") + sys.exit(_("Another instance of this program is already running")) # Set http proxy support ProxyMonitor.monitor_proxy(log) diff -Nur indicator-china-weather-1.0.4.old/src/location.txt indicator-china-weather-1.0.4/src/location.txt --- indicator-china-weather-1.0.4.old/src/location.txt 2013-04-07 11:15:52.752065843 +0800 +++ indicator-china-weather-1.0.4/src/location.txt 2013-04-07 11:34:39.744069533 +0800 @@ -651,7 +651,7 @@ 山西,吕梁,汾阳:101101111:fenyang 山西,吕梁,文水:101101112:wenshui 山西,吕梁,交城:101101113:jiaocheng -陕西,西安,西安:101110101:xian +陕西,西安,西安:101110101:xian:xi'an 陕西,西安,长安:101110102:changan 陕西,西安,临潼:101110103:lintong 陕西,西安,蓝田:101110104:lantian @@ -2541,10 +2541,10 @@ 海南,南沙,南沙:101310220:nansha 海南,乐东,乐东:101310221:ledong 海南,五指山,五指山:101310222:wuzhishan -香港,香港,香港:101320101:hongkong +香港,香港,香港:101320101:hongkong:xianggang 香港,香港,九龙:101320102:jiulong 香港,香港,新界:101320103:xinjie -澳门,澳门,澳门:101330101:macao +澳门,澳门,澳门:101330101:macao:aomen 澳门,澳门,氹仔岛:101330102:dangzidao 澳门,澳门,路环岛:101330103:luhuandao 台湾,台北,台北:101340101:taibeixian diff -Nur indicator-china-weather-1.0.4.old/src/pm25.py indicator-china-weather-1.0.4/src/pm25.py --- indicator-china-weather-1.0.4.old/src/pm25.py 2013-04-07 11:15:52.752065843 +0800 +++ indicator-china-weather-1.0.4/src/pm25.py 2013-04-07 11:36:31.984069901 +0800 @@ -1,4 +1,23 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd +# Authors: Zhang Zhao vaguedream@hotmail.com +# Kobe Lee kobe24_lixiang@126.com +# wyan yiwuhehe@163.com +# binghe kylinhebing@163.com +# 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 . +### END LICENSE import json import os,sys diff -Nur indicator-china-weather-1.0.4.old/src/pycwapi.py indicator-china-weather-1.0.4/src/pycwapi.py --- indicator-china-weather-1.0.4.old/src/pycwapi.py 2013-04-07 11:15:52.752065843 +0800 +++ indicator-china-weather-1.0.4/src/pycwapi.py 2013-04-15 09:39:52.055722428 +0800 @@ -1,8 +1,11 @@ #!/usr/bin/python # -*- coding: utf-8 -*- ### BEGIN LICENSE -# Copyright (C) 2013 Zhang Zhao vaguedream@hotmail.com -# Copyright (C) 2013 Kobe Lee kobe24_lixiang@126.com +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd +# Authors: Zhang Zhao vaguedream@hotmail.com +# Kobe Lee kobe24_lixiang@126.com +# wyan yiwuhehe@163.com +# binghe kylinhebing@163.com # 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. @@ -71,7 +74,7 @@ url = CHN_WEATHER_URL_COMPLEX % (location_id) json_string = read_from_url(url) parsed_json = json.loads(json_string) - tp_forecast = ('fchh', 'temp1', 'temp2', 'temp3', 'temp4', 'temp5', 'temp6', \ + tp_forecast = ('city', 'date_y', 'fchh', 'temp1', 'temp2', 'temp3', 'temp4', 'temp5', 'temp6', \ 'weather1', 'weather2', 'weather3', 'weather4', 'weather5', 'weather6', \ 'wind1', 'wind2', 'wind3', 'wind4', 'wind5', 'wind6', \ 'img1', 'img2', 'img3', 'img4', 'img5', 'img6', 'img7', 'img8', 'img9', 'img10', 'img11', 'img12', 'img_single', \