Commit b2b7a848 authored by Efthymia Bika's avatar Efthymia Bika
Browse files

Locate duplicity and timeview in exec_path

Load paths on global vars when application starts
parent 566f7a47
......@@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');
var mkdirp = require("mkdirp");
var exec = require('child_process').exec;
var execSync = require('child_process').execSync;
var BAAS_HOME_DIR = '.baas';
var CLOUDS_CONF_FILE = 'clouds.rc';
......@@ -17,6 +18,19 @@ function get_user_home() {
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}
function get_unix_path(target) {
if(process.platform == 'win32') {
var out = execSync(CYGWIN_BASH +
" -c \"/usr/bin/cygpath '" + exec_path + "' \"");
var win_value = String(out).replace(/(\r\n|\n|\r)/gm, "");
return win_value + "/" + target;
}
return path.join(exec_path, target);
}
var DUPLICITY_PATH = get_unix_path("duplicity");
var TIMEVIEW_PATH = get_unix_path("timeview.py");
function create_baas_dir() {
var dir = path.join(get_user_home(), BAAS_HOME_DIR);
fs.stat(dir, function (err, stats) {
......
......@@ -220,7 +220,7 @@ function run_duplicity(restore, force) {
dirs = " swift://" + container_name + " " + directory;
}
var cmd = build_win_commands();
var dup_cmd = "duplicity " + force_arg + include_arg +
var dup_cmd = DUPLICITY_PATH + " " + force_arg + include_arg +
exclude_arg + file_arg + time_arg + dirs + ";";
exec(CYGWIN_BASH + " -c '" + cmd + dup_cmd + "'", dup_output);
......@@ -232,7 +232,7 @@ function run_duplicity(restore, force) {
if(restore) {
dirs = " swift://" + container_name + " " + directory;
}
var dup_cmd = "duplicity " + force_arg + dup_verbosity + log_arg +
var dup_cmd = DUPLICITY_PATH + " " + force_arg + dup_verbosity + log_arg +
include_arg + exclude_arg + file_arg + time_arg + dirs + ";";
exec(dup_cmd , dup_output);
}
......@@ -254,7 +254,7 @@ function load_status() {
}
$("#loader").hide();
}
var dup_cmd = "duplicity collection-status swift://" + container;
var dup_cmd = DUPLICITY_PATH + " collection-status swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
exec(CYGWIN_BASH + " -c '" + cmd + dup_cmd + "'", puts);
......
......@@ -120,24 +120,15 @@ function get_contents_by_date(value) {
} else {
init_path = time_path;
}
var time_script = path.join(exec_path, 'timeview.py');
var datapath = path.join(BAAS_CACHE_DIR, 'timeviews');
var time_cmd = "python " + TIMEVIEW_PATH + " " + datapath + " swift://" +
container + " get " + value + " '" + time_path + "'"
if(process.platform == 'win32') {
time_script = time_script.replace(/\\/g, "\\\\");
exec(CYGWIN_BASH + " -c \"/usr/bin/cygpath '" + time_script + "' \"",
function(error, stdout, stderr) {
time_script = String(stdout).replace(/(\r\n|\n|\r)/gm, "");
if(error) $("#msg").html(error);
var cmd = build_win_commands();
var time_cmd = "python " + time_script + " " + datapath + " swift://" +
container + " get " + value + " '" + time_path + "'"
exec(CYGWIN_BASH + " -c '" + cmd + time_cmd + "'",
show_contents_by_date);
});
var cmd = build_win_commands();
exec(CYGWIN_BASH + " -c '" + cmd + time_cmd + "'",
show_contents_by_date);
} else {
var time_cmd = "python " + time_script + " " + datapath + " swift://" +
container + " get " + value + " '" + time_path + "'"
exec(time_cmd, show_contents_by_date);
}
}
......@@ -171,7 +162,7 @@ function load_timeview() {
}
$("#loader").hide();
}
var dup_cmd = "duplicity collection-status swift://" + container;
var dup_cmd = DUPLICITY_PATH + " collection-status swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
exec(CYGWIN_BASH + " -c '" + cmd + dup_cmd + "'", puts);
......
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