Fix upgrade stdout handling if file doesn't exist yet

plus some other tweaks..
This commit is contained in:
Lance Edgar 2017-08-09 11:56:25 -05:00
parent e5b0fe7198
commit 773a0c769d
3 changed files with 19 additions and 12 deletions

View file

@ -895,6 +895,10 @@ class MasterView(View):
progress.session['success_url'] = success_url
progress.session.save()
def execute_error_message(self, error):
return "Execution of {} failed: {}: {}".format(self.get_model_title(),
type(error).__name__, error)
def get_execute_success_url(self, obj, **kwargs):
return self.get_action_url('view', obj, **kwargs)

View file

@ -298,13 +298,14 @@ class UpgradeView(MasterView):
path = self.rattail_config.upgrade_filepath(upgrade.uuid, filename='stdout.log')
offset = session.get('stdout.offset', 0)
size = os.path.getsize(path) - offset
with open(path, 'rb') as f:
f.seek(offset)
chunk = f.read(size)
data['stdout'] = chunk.replace('\n', '<br />')
session['stdout.offset'] = offset + size
session.save()
if os.path.exists(path):
size = os.path.getsize(path) - offset
with open(path, 'rb') as f:
f.seek(offset)
chunk = f.read(size)
data['stdout'] = chunk.replace('\n', '<br />')
session['stdout.offset'] = offset + size
session.save()
return data