Commit 9437842b authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added logs to gui.

parent 89171aff
......@@ -144,6 +144,22 @@ function archive(uploadHash, calcHash) {
.then(response => response.json())
}
function calcProcLog(uploadHash, calcHash) {
return fetch(`${apiBase}/logs/${uploadHash}/${calcHash}`)
.catch(networkError)
.then(response => {
if (!response.ok) {
if (response.status === 404) {
return ''
} else {
return handleResponseErrors(response)
}
} else {
return response.text()
}
})
}
function archiveUrl(uploadHash, calcHash) {
return `${apiBase}/archive/${uploadHash}/${calcHash}`
}
......@@ -236,6 +252,7 @@ const api = {
unstageUpload: unstageUpload,
getUploads: getUploads,
archive: archive,
calcProcLog: calcProcLog,
archiveUrl: archiveUrl,
repo: repo,
repoAll: repoAll,
......
......@@ -18,6 +18,10 @@ class ArchiveCalc extends React.Component {
calcData: {
padding: theme.spacing.unit
},
logs: {
marginTop: theme.spacing.unit * 2,
padding: theme.spacing.unit
},
metaInfo: {
height: 120,
padding: theme.spacing.unit * 2,
......@@ -37,6 +41,7 @@ class ArchiveCalc extends React.Component {
super(props)
this.state = {
data: null,
logs: null,
metaInfo: null,
showMetaInfo: false
}
......@@ -51,6 +56,12 @@ class ArchiveCalc extends React.Component {
this.props.raiseError(error)
})
api.calcProcLog(uploadHash, calcHash).then(logs => {
if (logs && logs !== '') {
this.setState({logs: logs})
}
})
api.getMetaInfo().then(metaInfo => {
this.setState({metaInfo: metaInfo})
}).catch(error => {
......@@ -112,6 +123,14 @@ class ArchiveCalc extends React.Component {
: <LinearProgress variant="query" />
}
</Paper>
{ this.state.logs
?
<Paper className={classes.logs}>
<pre>
{this.state.logs}
</pre>
</Paper>
: ''}
</div>
)
......
......@@ -69,6 +69,7 @@ class Objects:
path_segments = file_name.split('/')
path = os.path.join(*([config.fs.objects, bucket] + path_segments))
directory = os.path.dirname(path)
if not os.path.isdir(directory):
os.makedirs(directory)
......
......@@ -142,7 +142,7 @@ class Calc(Proc):
self.normalizing()
self.archiving()
finally:
# close open loghandler
# close loghandler that was not closed due to failures
try:
if self._loghandler is not None:
self._loghandler.close()
......@@ -196,6 +196,11 @@ class Calc(Proc):
with ArchiveFile(self.archive_id).write_archive_json() as out:
self._parser_backend.write_json(out, pretty=True)
# close loghandler
if self._loghandler is not None:
self._loghandler.close()
self._loghandler = None
class Upload(Chord):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment