'use strict';
// connected socket object
- var client,
+ var client;
- // the list of checked pakages
- checkedPackagesList,
+ // the list of checked pakages
+ var checkedPackagesList;
- // template for the URL
- URL_EXPORTS = '<%= protocol %>//<%= hostname %>:<%= port %>/exports',
-
- // the path for ks
- PATH_TIC_KS = '/tmp/tic/ks/',
-
- // the path for images
- PATH_TIC_IMAGES = '/tmp/tic/images/';
+ // template for the URL
+ var URL_EXPORTS = '<%= protocol %>//<%= hostname %>:<%= port %>/exports';
+ // the path for ks
+ var PATH_TIC_KS = '/tmp/tic/ks/';
+ // the path for images
+ var PATH_TIC_IMAGES = '/tmp/tic/images/';
function updateList(socket) {
+ if (!_.isEmpty(socket)) {
+ client = socket;
+ }
+
var msgData = {
path: PATH_TIC_IMAGES
};
- client = socket;
-
client.emit('ws/fs/image/list/from', msgData);
client.on('ws/fs/image/list/to', function (data) {
list = data.list;
tableDomElem = $('#tic-image-list');
+ tableDomElem.empty();
list.forEach(function (file) {
var liElem, aElem, spanElem, fileName, hrefPath;
$('#tic-image-new-container').hide();
// upate the list of images
- updateList();
+ updateList(null);
});
}
var Mic = {};
-Mic.subprocess = function (processname, arg, cb) {
- var p = exec(processname, arg);
+Mic.subprocess = function (processname, cb) {
+ var p = exec(processname);
p.on('exit', cb.exit);
p.stdout.on('data', cb.stdout || function (out) {
process.stdout.write(out);
Mic.create = function (paramObj, client) {
console.log('Mic.create called');
- var micProcess, micProcessArgs, mic, child, stdoutPath, exitPath;
- stdoutPath = 'ws/fs/image/add/to';
- exitPath = 'ws/fs/image/add/finished';
-
- micProcess = 'sudo mic cr loop ' + paramObj.pathKsFile;
- micProcessArgs = [];
- micProcessArgs.push(util.format('-A %s', 'x86_64'));
- micProcessArgs.push(util.format('-o %s', paramObj.pathOutput));
+ var stdoutPath = 'ws/fs/image/add/to';
+ var exitPath = 'ws/fs/image/add/finished';
+ var micProcess = 'sudo mic cr loop ' + paramObj.pathKsFile + util.format(' -A %s', 'x86_64') + util.format(' -o %s', paramObj.pathOutput);
function sendMsg(path, msg) {
client.emit(path, msg);
}
- Mic.subprocess(micProcess, micProcessArgs, {
+ Mic.subprocess(micProcess, {
stdout: function (out) {
- console.log('stdout' + out);
- sendMsg(stdoutPath, 'stdout: ' + out);
+ console.log(out);
+ sendMsg(stdoutPath, out);
},
stderr: function (out) {
- console.log('stderr' + out);
- sendMsg(stdoutPath, 'stderr: ' + out);
+ console.error(out);
+ sendMsg(stdoutPath, out);
},
exit: function (out) {
- console.log('exit: ' + out);
- sendMsg(exitPath, 'exit: ' + out);
+ console.log(out);
+ sendMsg(exitPath, out);
}
});
};