Skip to content

Commit

Permalink
Changes & fixes
Browse files Browse the repository at this point in the history
Changes: 
- changed schema to match cumulus project
- changed setup.py completely with a standard script

Fixes: 
- fixed issue where the script for open weather map calculated the
weather speed wrong  
- changed the way weather updates inteval because the interval was never
resetting, just creating more update intervals in case operations such
as (changed location / api / measurements), now it should properly
update the weather on an hour basis since last update  

Added: 
- cumulus.desktop file
- snapcraft.yaml file
  • Loading branch information
adi committed Sep 27, 2016
1 parent 3111dbe commit c67fa41
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 144 deletions.
8 changes: 8 additions & 0 deletions cumulus.desktop
@@ -0,0 +1,8 @@
[Desktop Entry]
_Name=Cumulus
_Comment=Weather application
Categories=GNOME;Internet;
Exec=cumulus
Icon=cumulus
Terminal=false
Type=Application
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="cumulus">
<schema id="net.launchpad.cumulus" path="/net/launchpad/cumulus/">
<schema id="com.github.cumulus" path="/apps/cumulus/" gettext-domain="cumulus">
<key name="example" type="s">
<default>''</default>
<summary>Sample setting</summary>
Expand Down
Binary file modified data/glib-2.0/schemas/gschemas.compiled
Binary file not shown.
6 changes: 3 additions & 3 deletions data/media/app.html
Expand Up @@ -32,7 +32,7 @@
<!-- Creddits page -->
<div class="credits">
<img src="back.svg">
<h3 style="text-align: center">Cumulus v1.0.5</h3>
<h3 style="text-align: center">Cumulus v1.0.6</h3>
<br>
<p>Cumulus is a simple weather application for Ubuntu. <br>
It is and always will be free.<br>
Expand Down Expand Up @@ -134,8 +134,8 @@ <h3 style="text-align: center">Thanks for using.</h3><br><br>
</div>
<div style="width:100%; text-align:center;">
<a class="btn" tag="credits">CREDITS</a>
<a class="btn" href="javascript:showNotFinished();">HOW TO</a>
<a class="btn" href="javascript:showNotFinished();">SUPPORT</a>
<!-- <a class="btn" href="javascript:showNotFinished();">HOW TO</a> -->
<!-- <a class="btn" href="javascript:showNotFinished();">SUPPORT</a> -->
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion data/media/scripts/owmApi.js
Expand Up @@ -6,7 +6,7 @@ function saveOpenWeatherStats(data, callback) {
localStorage.cumulus_country = data.sys.country;
localStorage.cumulus_link = "http://openweathermap.org/city/" + data.id;
localStorage.weather_temp = getTemperature(data.main.temp, "k");
localStorage.weather_wind_speed = getSpeed(data.wind.speed, "mph");
localStorage.weather_wind_speed = getSpeed(data.wind.speed, "ms");
localStorage.weather_humidity = data.main.humidity;
localStorage.weather_desc = data.weather[0].description;
openWeatherForecast(data, function() {
Expand Down
37 changes: 20 additions & 17 deletions data/media/scripts/ui-script.js
@@ -1,4 +1,6 @@
$(document).ready(function() {
var updateInteval = 3600000;
var updateTimer;
//Filters Proprietary RSS Tags
jQuery.fn.filterNode = function(name){
return this.filter(function(){
Expand All @@ -15,16 +17,15 @@ $(document).ready(function() {
} else {
//Has been run before
getWeather(null);
setInterval(function() {
console.log("Updating Data...");
getWeather(null);
}, 3600000);
updateTimer = setInterval(getPeriodicWeather, updateInteval);
}
init_settings();

//Update weather data based on location stored
$("#decoratorBar .sync").on("click", function() {
getWeather(null);
clearInterval(updateTimer);
updateTimer = setInterval(getPeriodicWeather, updateInteval);
});

//Sets temperature measurement
Expand Down Expand Up @@ -74,20 +75,16 @@ $(document).ready(function() {
});
}

//This can only be run if there is a tick.
$("#locationModal .loader").on("click", function() {
if ( $(this).hasClass("tick") ) {
//This can only be run if there is a tick.
$("#locationModal .loader").on("click", function() {
if ($(this).hasClass("tick")) {
getWeather(null);
$("#locationModal .input :input").val("");
$(this).removeClass("tick");
$(this).removeAttr("data-code");
$(this).html("");
show_settings("noweather");
setInterval(function() {
console.log("Updating Data...");
$("#decoratorBar .sync").click();
}, 3600000)

$(this).html("");
clearInterval(updateTimer);
updateTimer = setInterval(getPeriodicWeather, updateInteval);
}
});

Expand All @@ -107,6 +104,8 @@ $(document).ready(function() {
savelocationFromInput(searchLocation, function(cityCode) {
$("#decoratorBar .sync").show();
setApiSelected();
clearInterval(updateTimer);
updateTimer = setInterval(getPeriodicWeather, updateInteval);
});
}
});
Expand All @@ -121,15 +120,16 @@ $(document).ready(function() {

function getWeather(inputLocation, callback) {
$('#decoratorBar .sync').addClass('busy');
$("#decoratorBar .settings, #decoratorBar .sync").show();
$("#decoratorBar .settings, #decoratorBar .sync").show();
if ( inputLocation != null ) {
//Saves location name and id in localStorage for future updates
savelocationFromInput(inputLocation, function(cityCode) {
callback(cityCode);
});
}
else {
getWeatherData(function() {
getWeatherData(function() {
console.log("Updating Data...");
//Updates the weather in UI with data from localStorage
setWeather();
//Sets opacity
Expand Down Expand Up @@ -221,7 +221,7 @@ function setWeather() {
$('#decoratorBar .sync').removeClass('busy');
$('#actualWeather').fadeIn(500);
$("#locationModal").fadeOut(500);
}, 500);
}, 500);
}

function init_storage() {
Expand Down Expand Up @@ -427,4 +427,7 @@ $(document).ajaxError(function() {
showError();
});

function getPeriodicWeather() {
getWeather(null)
}

144 changes: 22 additions & 122 deletions setup.py
Expand Up @@ -20,131 +20,31 @@

import os
import sys
import glob
from setuptools import setup, find_packages

try:
import DistUtilsExtra.auto
except ImportError:
print >> sys.stderr, 'To build cumulus you need https://launchpad.net/python-distutils-extra'
sys.exit(1)
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'

def update_config(libdir, values = {}):

filename = os.path.join(libdir, 'cumulus_lib/CumulusConfig.py')
oldvalues = {}
try:
fin = file(filename, 'r')
fout = file(filename + '.new', 'w')

for line in fin:
fields = line.split(' = ') # Separate variable from value
if fields[0] in values:
oldvalues[fields[0]] = fields[1].strip()
line = "%s = %s\n" % (fields[0], values[fields[0]])
fout.write(line)

fout.flush()
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError), e:
print ("ERROR: Can't find %s" % filename)
sys.exit(1)
return oldvalues


def move_desktop_file(root, target_data, prefix):
# The desktop file is rightly installed into install_data. But it should
# always really be installed into prefix, because while we can install
# normal data files anywhere we want, the desktop file needs to exist in
# the main system to be found. Only actually useful for /opt installs.

old_desktop_path = os.path.normpath(root + target_data + '/share/applications')
old_desktop_file = old_desktop_path + '/cumulus.desktop'
desktop_path = os.path.normpath(root + prefix + '/share/applications')
desktop_file = desktop_path + '/cumulus.desktop'

if not os.path.exists(old_desktop_file):
print ("ERROR: Can't find", old_desktop_file)
sys.exit(1)
elif target_data != prefix + '/':
# This is an /opt install, so rename desktop file to use extras-
desktop_file = desktop_path + '/extras-cumulus.desktop'
try:
os.makedirs(desktop_path)
os.rename(old_desktop_file, desktop_file)
os.rmdir(old_desktop_path)
except OSError as e:
print ("ERROR: Can't rename", old_desktop_file, ":", e)
sys.exit(1)

return desktop_file

def update_desktop_file(filename, target_pkgdata, target_scripts):
try:
fin = file(filename, 'r')
fout = file(filename + '.new', 'w')

for line in fin:
if 'Icon=' in line:
line = "Icon=%s\n" % (target_pkgdata + 'media/cumulus.svg')
elif 'Exec=' in line:
cmd = line.split("=")[1].split(None, 1)
line = "Exec=%s" % (target_scripts + 'cumulus')
if len(cmd) > 1:
line += " %s" % cmd[1].strip() # Add script arguments back
line += "\n"
fout.write(line)
fout.flush()
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError), e:
print ("ERROR: Can't find %s" % filename)
sys.exit(1)

def compile_schemas(root, target_data):
if target_data == '/usr/':
return # /usr paths don't need this, they will be handled by dpkg
schemadir = os.path.normpath(root + target_data + 'share/glib-2.0/schemas')
if (os.path.isdir(schemadir) and
os.path.isfile('/usr/bin/glib-compile-schemas')):
os.system('/usr/bin/glib-compile-schemas "%s"' % schemadir)


class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
def run(self):
DistUtilsExtra.auto.install_auto.run(self)

if not self.root:
self.root = '/'

target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
target_pkgdata = target_data + 'share/cumulus/'
target_scripts = '/' + os.path.relpath(self.install_scripts, self.root) + '/'

values = {'__cumulus_data_directory__': "'%s'" % (target_pkgdata),
'__version__': "'%s'" % self.distribution.get_version()}
update_config(self.install_lib, values)

desktop_file = move_desktop_file(self.root, target_data, self.prefix)
update_desktop_file(desktop_file, target_pkgdata, target_scripts)
compile_schemas(self.root, target_data)


##################################################################################
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
##################################################################################

DistUtilsExtra.auto.setup(
setup(
name='cumulus',
version='1.0.5',
license='GPL-3',
author='Daryl Bennett',
version= '1.0.6',
author='Daryl Bennett',
author_email='kd8bny@gmail.com',
license='GPL-3',
description='Quickly check the weather with this beautiful application',
long_description='Cumulus is a free and open source weather application. It is continuation of discontinued Stormcloud 1.1 ,however with some changes. It is and always will be free.',
url='https://github.com/kd8bny/cumulus',
cmdclass={'install': InstallAndUpdateDataDirectory}
)

packages=find_packages(),
data_files=[
('share/glib-2.0/schemas', ['data/glib-2.0/schemas/com.github.cumulus.gschema.xml']),
('share/doc/cumulus', ['README.md']),
('share/cumulus/ui', glob.glob('data/ui/*.ui')),
('share/cumulus/ui', glob.glob('data/ui/*.xml')),
('share/cumulus/media/fonts', glob.glob('data/media/fonts/*.*')),
('share/cumulus/media/scripts', glob.glob('data/media/scripts/*.*')),
('share/cumulus/media', glob.glob('data/media/*.html')),
('share/cumulus/media', glob.glob('data/media/*.svg')),
('share/cumulus/media', glob.glob('data/media/*.json')),
('share/cumulus/media', glob.glob('data/media/*.css')),
('bin', ['bin/cumulus']),
('../share/applications', ['cumulus.desktop'])
]
)
20 changes: 20 additions & 0 deletions snapcraft.yaml
@@ -0,0 +1,20 @@
name: cumulus
version: "1.0.6"
summary: Simple weather application, powered by Yahoo! Weather & Open Weather Map
description: Forked from typhoon which was based on Stormcloud by Jono Cooper.
confinement: devmode

apps:
cumulus:
command: ./bin/cumulus

parts:
cumulus:
plugin: python2
source: .
stage-packages:
- python-all
- python-gi
- gir1.2-webkit-3.0
- gir1.2-glib-2.0
- gir1.2-gtk-3.0

0 comments on commit c67fa41

Please sign in to comment.