Ejemplo n.º 1
0
 def notify(self, message):
     try:
         global notification, os
         if not notification:
             from plyer import notification
         icon = (os.path.dirname(os.path.realpath(__file__))
                 + '/../../' + self.icon)
         notification.notify('Electrum', message,
                         app_icon=icon, app_name='Electrum')
     except ImportError:
         Logger.Error('Notification: needs plyer; `sudo pip install plyer`')
Ejemplo n.º 2
0
    def updateData(self):
        baseurl = "https://query.yahooapis.com/v1/public/yql?q="
        query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="' + self.location + '")'
        form = "&format=json"
        r = jsonRequests.getResponse(baseurl + query + form)

        if r.status:
            item = r["query"]["results"]["channel"]["item"]
            condition = item["condition"]
            forecasts = item["forecast"]

            todayFC = forecasts[0]

            self.forecastString = todayFC["high"] + " / " + todayFC[
                "low"] + " " + weatherCodes.codes[todayFC["code"]]

            self.currentConditions = condition[
                "temp"] + " | " + weatherCodes.codes[condition["code"]]

            self.day1 = forecasts[1]["day"] + " | " + forecasts[1][
                "high"] + " / " + forecasts[1][
                    "low"] + " " + weatherCodes.codes[forecasts[1]["code"]]
            self.day2 = forecasts[2]["day"] + " | " + forecasts[2][
                "high"] + " / " + forecasts[2][
                    "low"] + " " + weatherCodes.codes[forecasts[2]["code"]]
            self.day3 = forecasts[3]["day"] + " | " + forecasts[3][
                "high"] + " / " + forecasts[3][
                    "low"] + " " + weatherCodes.codes[forecasts[3]["code"]]
            self.day4 = forecasts[4]["day"] + " | " + forecasts[4][
                "high"] + " / " + forecasts[4][
                    "low"] + " " + weatherCodes.codes[forecasts[4]["code"]]
            self.day5 = forecasts[5]["day"] + " | " + forecasts[5][
                "high"] + " / " + forecasts[5][
                    "low"] + " " + weatherCodes.codes[forecasts[5]["code"]]

        else:
            Logger.Error("WeatherApp: Had trouble getting weather.")