Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
keeleliin
keeleliin-wrapper
Commits
12c300f1
Commit
12c300f1
authored
Jul 21, 2015
by
priit
Browse files
Utiliidi vea korral tagasta veateade
parent
4ebd0108
Changes
7
Hide whitespace changes
Inline
Side-by-side
middlewares/errorhandler.js
View file @
12c300f1
var
logger
=
require
(
'
log4js
'
).
getLogger
(
'
router_middleware
'
);
var
express
=
require
(
'
express
'
);
module
.
exports
=
{
common
:
function
(
err
,
req
,
res
,
next
)
{
...
...
src/mapper/commandModel.js
View file @
12c300f1
var
logger
=
require
(
'
log4js
'
).
getLogger
(
'
router_middleware
'
);
var
logger
=
require
(
'
log4js
'
).
getLogger
(
'
command_model
'
);
var
sessionService
=
require
(
'
../service/sessionService
'
);
function
CommandModel
(){
...
...
src/model/session.js
View file @
12c300f1
...
...
@@ -12,12 +12,19 @@ var Session = function( id ){
this
.
requestFiles
=
{};
this
.
data
=
null
;
this
.
outputFiles
=
{};
this
.
errors
=
null
;
};
Session
.
prototype
.
addOutputFile
=
function
(
key
,
path
){
this
.
outputFiles
[
key
]
=
path
;
};
Session
.
prototype
.
setErrors
=
function
(
errors
,
path
){
this
.
errors
=
errors
;
this
.
isSuccess
=
false
;
this
.
message
=
Session
.
messages
.
ERROR
};
Session
.
messages
=
{
RUNNING
:
'
RUNNING
'
,
OK
:
'
OK
'
,
...
...
src/service/executor/localExecutor.js
View file @
12c300f1
...
...
@@ -12,9 +12,9 @@ function LocalExecutor() {
this
.
execute
=
function
(
commandModel
,
callback
)
{
var
response
=
{
message
:
null
,
isSuccess
:
true
,
stdOutPath
:
sessionService
.
getNewSessionFilePath
(
commandModel
.
session
)
stdOutPath
:
sessionService
.
getNewSessionFilePath
(
commandModel
.
session
),
errors
:
[]
};
var
localCommand
=
new
LocalCommand
(
commandModel
).
generate
();
...
...
@@ -44,6 +44,13 @@ function LocalExecutor() {
process
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
logger
.
error
(
'
Got error:
'
+
data
);
response
.
isSuccess
=
false
;
response
.
errors
.
push
({
util
:
data
});
});
process
.
on
(
'
error
'
,
function
(
data
)
{
logger
.
error
(
'
Got error:
'
+
data
);
response
.
isSuccess
=
false
;
response
.
errors
.
push
({
util
:
data
});
});
process
.
on
(
'
close
'
,
function
(
code
,
signal
)
{
...
...
src/service/sessionService.js
View file @
12c300f1
...
...
@@ -165,6 +165,10 @@ function SessionService() {
response
.
success
=
session
.
success
;
response
.
message
=
session
.
message
;
if
(
session
.
errors
!=
null
){
response
.
errors
=
session
.
errors
;
}
if
(
session
.
message
==
Session
.
messages
.
RUNNING
)
{
response
.
recheckInterval
=
session
.
recheckInterval
;
}
...
...
wrapper/contentTokenizer.js
View file @
12c300f1
...
...
@@ -7,8 +7,6 @@ var SessionService = require('./../src/service/sessionService');
var
CommandModel
=
require
(
'
../src/mapper/commandModel
'
);
var
fs
=
require
(
'
fs
'
);
function
ContentTokenizer
(){
var
self
=
this
;
...
...
@@ -22,9 +20,15 @@ function ContentTokenizer(){
if
(
err
)
return
callback
(
err
);
localExecutor
.
execute
(
model
,
function
(
err
,
response
)
{
if
(
err
)
return
callback
(
err
);
logger
.
debug
(
'
Väline programm on lõpetanud
'
);
if
(
err
){
session
.
setErrors
(
err
);
return
callback
(
err
,
session
);
}
if
(
!
response
.
isSuccess
){
session
.
setErrors
(
response
.
errors
);
return
callback
(
err
,
session
);
}
fs
.
readFile
(
model
.
outputPaths
.
outputPath1
,
function
(
err
,
output
)
{
if
(
err
)
return
callback
(
err
);
...
...
wrapper/morfyhestaja.js
View file @
12c300f1
...
...
@@ -2,7 +2,6 @@ var logger = require('log4js').getLogger('wrapper');
var
config
=
require
(
'
./../config
'
);
var
localExecutor
=
require
(
'
./../src/service/executor/localExecutor
'
);
var
Session
=
require
(
'
../src/model/session
'
);
var
SessionService
=
require
(
'
./../src/service/sessionService
'
);
var
CommandModel
=
require
(
'
../src/mapper/commandModel
'
);
var
fs
=
require
(
'
fs
'
);
...
...
@@ -23,8 +22,7 @@ function ContentTokenizer(){
if
(
response
.
isSuccess
){
session
.
message
=
Session
.
messages
.
OK
;
}
else
{
session
.
message
=
Session
.
messages
.
ERROR
;
session
.
success
=
false
;
session
.
setErrors
(
response
.
errors
);
}
session
.
addOutputFile
(
'
output
'
,
response
.
stdOutPath
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment