Skip to content

Commit

Permalink
Merge branch '2.7-hotfix' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Sep 27, 2018
2 parents 865bde9 + a1c57dc commit d32e563
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/configmanager/ui/nodewidgets/ui_publishwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<string>Include the projects_data folder when doing a publish</string>
</property>
<property name="text">
<string>Inlcude data folder</string>
<string>Include data folder</string>
</property>
<property name="checked">
<bool>true</bool>
Expand Down
2 changes: 2 additions & 0 deletions src/configmanager/ui/widgets/publishwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def set_data(self, data):
self.dataservice = DataService(self.config)
self.reload_projects()
self.deployLocationText.setText(self.config.get('global_publish_path', ""))
self.includeDataCheck.setChecked(self.config.get('include_data', True))
self.refresh()

def reload_projects(self):
Expand All @@ -90,6 +91,7 @@ def write_config(self):
projects = self.get_project_depoly_settings(True)
self.config['global_publish_path'] = self.deployLocationText.text()
self.config['projects'] = projects
self.config['include_data'] = self.includeDataCheck.isChecked()
self.config.save()
super(PublishWidget, self).write_config()

Expand Down
2 changes: 1 addition & 1 deletion src/roam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NUM_VERSION = (2, 7, 0)
NUM_VERSION = (2, 7, 1)

import sip
import os
Expand Down
3 changes: 2 additions & 1 deletion src/roam/infodock.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ def update(self, cursor):
self.deleteFeatureButton.setVisible(deletefeature)
self.quickInspectButton.setVisible('inspection' in tools)
self.editButton.setVisible(editattributes)
geom = cursor.feature.geometry()
feature = cursor.feature
geom = feature.geometry()
geomtype = geom.type()
if geomtype == QGis.Polygon and geom.isMultipart():
editgeom = False
Expand Down
38 changes: 34 additions & 4 deletions src/roam/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import roam.config


class UpdateExpection(Exception):
pass


def add_slash(url):
if not url.endswith("/"):
url += "/"
Expand Down Expand Up @@ -103,7 +107,16 @@ def download_file(url, fileout):
Will open and write to fileout
"""
roam.utils.debug("Opening URL: {}".format(url))
result = urllib2.urlopen(url)
try:
result = urllib2.urlopen(url)
except urllib2.HTTPError as ex:
if ex.code == 404:
roam.utils.warning("Can't find URL: {}".format(url))
else:
roam.utils.exception("HTTP Error: {}".format(ex))
yield "Error in download"
raise UpdateExpection("Error in downloading file.")

length = result.headers['content-length']

length = int(length) / 1024 / 1024
Expand Down Expand Up @@ -184,6 +197,13 @@ def __init__(self, basefolder):
self.basefolder = basefolder
self.projectUpdateStatus.connect(self.status_updated)

def check_url_found(self, url):
try:
result = urllib2.urlopen(url)
return result.code == 200
except urllib2.HTTPError as ex:
return False

def fetch_data(self, rootfolder, filename, serverurl):
"""
Download the update zip file for the project from the server
Expand All @@ -197,9 +217,19 @@ def fetch_data(self, rootfolder, filename, serverurl):
filename = "{}.zip".format(filename)
url = urlparse.urljoin(serverurl, "projects/{}".format(filename))
zippath = os.path.join(tempfolder, filename)
roam.utils.info("Downloading project zip {}".format(url))
for status in download_file(url, zippath):
yield status
if not self.check_url_found(url):
yield "Skipping data download"
yield "Done"
return

roam.utils.info("Downloading data zip from {}".format(url))
try:
for status in download_file(url, zippath):
yield status
except UpdateExpection as ex:
roam.utils.exception("Error in update for project")
yield "Error in downloading data"
return

yield "Extracting data.."
with zipfile.ZipFile(zippath, "r") as z:
Expand Down

0 comments on commit d32e563

Please sign in to comment.