azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
784 lines (370 loc) • 40.9 kB
JavaScript
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var fs = require("fs");
var ss = require("streamline/lib/streams/streams");
var util = require("util");
var batchUtil = require("./batch.util");
var batchShowUtil = require("./batch.showUtil");
var utils = require("../../util/utils");
var StorageUtil = require("../../util/storage.util");
var pathUtil = require("path");
var startProgress = batchUtil.startProgress;
var endProgress = batchUtil.endProgress;
var $ = utils.getLocaleString;
exports.init = function(cli) {
batchUtil.init(cli);
var batch = cli.category("batch").description($("Commands to manage your Batch objects"));
var logger = cli.output;
var interaction = cli.interaction;
var taskfile = batch.category("task-file").description($("Commands to manage your Batch task files"));
var nodefile = batch.category("node-file").description($("Commands to manage your Batch compute node files"));
nodefile.command("delete [pool-id] [node-id] [file-name]").description($("Deletes the specified file from the compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node from which you want to delete the file")).option("-f, --file-name <user-name>", $("the path to the file that you want to delete")).option("-r, --recursive", $("whether to delete children of a directory")).option("-q, --quiet", $("delete file(s) without confirmation")).appendBatchAccountOption().execute(deleteNodeFile);
taskfile.command("delete [job-id] [task-id] [file-name]").description($("Deletes the specified task file from the compute node where the task ran")).option("-j, --job-id <job-Id>", $("the id of the job that contains the task")).option("-i, --task-id <task-Id>", $("the id of the task whose file you want to delete")).option("-f, --file-name <user-name>", $("the path to the task file that you want to delete")).option("-r, --recursive", $("whether to delete children of a directory")).option("-q, --quiet", $("delete file(s) without confirmation")).appendBatchAccountOption().execute(deleteTaskFile);
nodefile.command("download [pool-id] [node-id] [file-name] [destination]").description($("Download a file from a Batch compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that contains the file")).option("-f, --file-name <user-name>", $("the path to the file that you want to download")).option("-d, --destination <destination>", $("path to the destination file or directory")).option("--range <range>", $("the byte range to be retrieved, the default is to retrieve the entire file")).option("-q, --quiet", $("overwrite the destination file without confirmation")).appendCommonHeaderFilterOption(false, true).appendBatchAccountOption().execute(getNodeFile);
taskfile.command("download [job-id] [task-id] [file-name] [destination]").description($("Download a Batch task file")).option("-j, --job-id <job-Id>", $("the batch job id")).option("-i, --task-id <task-Id>", $("the batch task id")).option("-f, --file-name <user-name>", $("the path to the file that you want to download")).option("-d, --destination <destination>", $("path to the destination file or directory")).option("--range <range>", $("the byte range to be retrieved, the default is to retrieve the entire file")).option("-q, --quiet", $("overwrite the destination file without confirmation")).appendCommonHeaderFilterOption(false, true).appendBatchAccountOption().execute(getTaskFile);
nodefile.command("show [pool-id] [node-id] [file-name]").description($("Get the properties of the specified compute node file")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node that contains the file")).option("-f, --file-name <user-name>", $("the path to the file that you want to get the properties of")).appendCommonHeaderFilterOption(false, true).appendBatchAccountOption().execute(showNodeFile);
taskfile.command("show [job-id] [task-id] [file-name]").description($("Gets the properties of the specified task file")).option("-j, --job-id <job-Id>", $("the id of the job that contains the task")).option("-i, --task-id <task-Id>", $("the id of the task whose file you want to get the properties of")).option("-f, --file-name <user-name>", $("the path to the file that you want to get the properties of")).appendCommonHeaderFilterOption(false, true).appendBatchAccountOption().execute(showTaskFile);
nodefile.command("list [pool-id] [node-id]").description($("Lists all of the files in task directories on the specified compute node")).option("-p, --pool-id <pool-Id>", $("the id of the pool that contains the compute node")).option("-i, --node-id <node-Id>", $("the id of the compute node whose files you want to list")).option("-r, --recursive", $("whether to list children of a directory")).appendODataFilterOption(false, true, false).appendBatchAccountOption().execute(listNodeFile);
taskfile.command("list [job-id] [task-id]").description($("Lists the files in a task's directory on its compute node")).option("-j, --job-id <job-Id>", $("the id of the job that contains the task")).option("-i, --task-id <task-Id>", $("the id of the task whose files you want to list")).option("-r, --recursive", $("whether to list children of a directory")).appendODataFilterOption(false, true, false).appendBatchAccountOption().execute(listTaskFile);
function deleteNodeFile(poolId, nodeId, fileName, options, _) { var client, tips, batchOptions; var __frame = { name: "deleteNodeFile", line: 146 }; return __func(_, this, arguments, deleteNodeFile, 4, __frame, function __$deleteNodeFile() {
if (!poolId) {
poolId = options.poolId; } ;
return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
if (!nodeId) {
nodeId = options.nodeId; } ;
return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __2) { nodeId = __2;
if (!fileName) {
fileName = options.fileName; } ;
return interaction.promptIfNotGiven($("File name: "), fileName, __cb(_, __frame, 12, 27, function ___(__0, __3) { fileName = __3; return (function __$deleteNodeFile(__then) {
if (!options.quiet) {
return interaction.confirm(util.format($("Do you want to delete file %s? "), fileName), __cb(_, __frame, 15, 23, function ___(__0, __5) { var __4 = !__5; return (function __$deleteNodeFile(__then) { if (__4) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$deleteNodeFile() {
client = batchUtil.createBatchServiceClient(options);
tips = util.format($("Deleting file %s"), fileName);
batchOptions = { };
batchOptions.fileDeleteFromComputeNodeOptions = batchUtil.getBatchOperationDefaultOption();
if (options.recursive) {
batchOptions.recursive = true; } ;
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteNodeFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteNodeFile() {
return client.file.deleteFromComputeNode(poolId, nodeId, fileName, batchOptions, __cb(_, __frame, 31, 18, __then, true)); }); })(function ___(err, __result) { __catch(function __$deleteNodeFile() { if (err) {
if (batchUtil.isNotFoundException(err)) {
return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
else {
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteNodeFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteNodeFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteNodeFile() {
logger.info(util.format($("File %s has been deleted successfully"), fileName)); _(); }); }); }); }, true)); }, true)); }, true)); }); };
function deleteTaskFile(jobId, taskId, fileName, options, _) { var client, tips, batchOptions; var __frame = { name: "deleteTaskFile", line: 205 }; return __func(_, this, arguments, deleteTaskFile, 4, __frame, function __$deleteTaskFile() {
if (!jobId) {
jobId = options.jobId; } ;
return interaction.promptIfNotGiven($("Job id: "), jobId, __cb(_, __frame, 4, 24, function ___(__0, __1) { jobId = __1;
if (!taskId) {
taskId = options.taskId; } ;
return interaction.promptIfNotGiven($("Task id: "), taskId, __cb(_, __frame, 8, 25, function ___(__0, __2) { taskId = __2;
if (!fileName) {
fileName = options.fileName; } ;
return interaction.promptIfNotGiven($("File name: "), fileName, __cb(_, __frame, 12, 27, function ___(__0, __3) { fileName = __3; return (function __$deleteTaskFile(__then) {
if (!options.quiet) {
return interaction.confirm(util.format($("Do you want to delete file %s? "), fileName), __cb(_, __frame, 15, 23, function ___(__0, __5) { var __4 = !__5; return (function __$deleteTaskFile(__then) { if (__4) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$deleteTaskFile() {
client = batchUtil.createBatchServiceClient(options);
tips = util.format($("Deleting file %s"), fileName);
batchOptions = { };
batchOptions.fileDeleteFromTaskOptions = batchUtil.getBatchOperationDefaultOption();
if (options.recursive) {
batchOptions.recursive = true; } ;
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteTaskFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteTaskFile() {
return client.file.deleteFromTask(jobId, taskId, fileName, batchOptions, __cb(_, __frame, 31, 18, __then, true)); }); })(function ___(err, __result) { __catch(function __$deleteTaskFile() { if (err) {
if (batchUtil.isNotFoundException(err)) {
return _(new Error(util.format($("Job %s or task %s doesn't exist"), jobId, taskId))); }
else {
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteTaskFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteTaskFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteTaskFile() {
logger.info(util.format($("File %s has been deleted successfully"), fileName)); _(); }); }); }); }, true)); }, true)); }, true)); }); };
function showNodeFile(poolId, nodeId, fileName, options, _) { var client, tips, batchOptions, properties, results, headers; var __frame = { name: "showNodeFile", line: 264 }; return __func(_, this, arguments, showNodeFile, 4, __frame, function __$showNodeFile() {
if (!poolId) {
poolId = options.id; } ;
return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
if (!nodeId) {
nodeId = options.nodeId; } ;
return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __2) { nodeId = __2;
if (!fileName) {
fileName = options.fileName; } ;
return interaction.promptIfNotGiven($("File name: "), fileName, __cb(_, __frame, 12, 27, function ___(__0, __3) { fileName = __3;
client = batchUtil.createBatchServiceClient(options);
tips = $("Getting Batch file properties");
batchOptions = { };
batchOptions.fileGetNodeFilePropertiesFromComputeNodeOptions = batchUtil.getBatchOperationDefaultOption();
if (options.ifModifiedSince) {
batchOptions.fileGetNodeFilePropertiesFromComputeNodeOptions.ifModifiedSince = options.ifModifiedSince; } ;
if (options.ifUnmodifiedSince) {
batchOptions.fileGetNodeFilePropertiesFromComputeNodeOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;
properties = null;
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showNodeFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showNodeFile() {
return client.file.getNodeFilePropertiesFromComputeNode(poolId, nodeId, fileName, batchOptions, __cb(_, __frame, 30, 32, function ___(__0, __4) { results = __4;
properties = { };
properties.name = fileName;
properties.properties = { };
headers = results[2].headers;
if (headers) {
if (headers["ocp-batch-file-isdirectory"]) {
properties.isDirectory = (((headers["ocp-batch-file-isdirectory"] === "True") || (headers["ocp-batch-file-isdirectory"] === "true"))); } ;
properties.properties.contentLength = headers["content-length"];
properties.properties.creationTime = new Date(headers["ocp-creation-time"]);
properties.properties.lastModified = new Date(headers["last-modified"]);
properties.properties.contentType = headers["content-type"]; } ; __then(); }, true, true)); }); })(function ___(err, __result) { __catch(function __$showNodeFile() { if (err) {
if (batchUtil.isNotFoundException(err)) {
return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
else {
if ((err.statusCode === 404)) {
return _(new Error(util.format($("File %s doesn't exist"), fileName))); } ;
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showNodeFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showNodeFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showNodeFile() {
batchShowUtil.showFile(properties, cli.output); _(); }); }); }, true)); }, true)); }, true)); }); };
function showTaskFile(jobId, taskId, fileName, options, _) { var client, tips, batchOptions, properties, results, headers; var __frame = { name: "showTaskFile", line: 338 }; return __func(_, this, arguments, showTaskFile, 4, __frame, function __$showTaskFile() {
if (!jobId) {
jobId = options.jobId; } ;
return interaction.promptIfNotGiven($("Job id: "), jobId, __cb(_, __frame, 4, 24, function ___(__0, __1) { jobId = __1;
if (!taskId) {
taskId = options.taskId; } ;
return interaction.promptIfNotGiven($("Task id: "), taskId, __cb(_, __frame, 8, 25, function ___(__0, __2) { taskId = __2;
if (!fileName) {
fileName = options.fileName; } ;
return interaction.promptIfNotGiven($("File name: "), fileName, __cb(_, __frame, 12, 27, function ___(__0, __3) { fileName = __3;
client = batchUtil.createBatchServiceClient(options);
tips = $("Getting Batch file properties");
batchOptions = { };
batchOptions.fileGetNodeFilePropertiesFromTaskOptions = batchUtil.getBatchOperationDefaultOption();
if (options.ifModifiedSince) {
batchOptions.fileGetNodeFilePropertiesFromTaskOptions.ifModifiedSince = options.ifModifiedSince; } ;
if (options.ifUnmodifiedSince) {
batchOptions.fileGetNodeFilePropertiesFromTaskOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;
properties = null;
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showTaskFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showTaskFile() {
return client.file.getNodeFilePropertiesFromTask(jobId, taskId, fileName, batchOptions, __cb(_, __frame, 30, 32, function ___(__0, __4) { results = __4;
properties = { };
properties.name = fileName;
properties.properties = { };
headers = results[2].headers;
if (headers) {
if (headers["ocp-batch-file-isdirectory"]) {
properties.isDirectory = (((headers["ocp-batch-file-isdirectory"] === "True") || (headers["ocp-batch-file-isdirectory"] === "true"))); } ;
properties.properties.contentLength = headers["content-length"];
properties.properties.creationTime = new Date(headers["ocp-creation-time"]);
properties.properties.lastModified = new Date(headers["last-modified"]);
properties.properties.contentType = headers["content-type"]; } ; __then(); }, true, true)); }); })(function ___(err, __result) { __catch(function __$showTaskFile() { if (err) {
if (batchUtil.isNotFoundException(err)) {
return _(new Error(util.format($("Job %s or task %s doesn't exist"), jobId, taskId))); }
else {
if ((err.statusCode === 404)) {
return _(new Error(util.format($("File %s doesn't exist"), fileName))); } ;
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showTaskFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showTaskFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showTaskFile() {
batchShowUtil.showFile(properties, cli.output); _(); }); }); }, true)); }, true)); }, true)); }); };
function listNodeFile(poolId, nodeId, options, _) { var client, tips, batchOptions, files, result, nextLink; var __frame = { name: "listNodeFile", line: 411 }; return __func(_, this, arguments, listNodeFile, 3, __frame, function __$listNodeFile() {
if (!poolId) {
poolId = options.id; } ;
return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
if (!nodeId) {
nodeId = options.nodeId; } ;
return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __2) { nodeId = __2;
client = batchUtil.createBatchServiceClient(options);
tips = $("Listing node files");
batchOptions = { };
batchOptions.fileListFromComputeNodeOptions = batchUtil.getBatchOperationDefaultOption();
if (options.recursive) {
batchOptions.recursive = true; } ;
if (options.filterClause) {
batchOptions.fileListFromComputeNodeOptions.filter = options.filterClause; } ;
files = [];
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listNodeFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listNodeFile() {
return client.file.listFromComputeNode(poolId, nodeId, batchOptions, __cb(_, __frame, 26, 31, function ___(__0, __3) { result = __3;
result.forEach(function(file) {
files.push(file); });
nextLink = result.odatanextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$listNodeFile() { __more = false;
var __8 = nextLink; if (__8) {
batchOptions.fileListFromComputeNodeOptions = batchUtil.getBatchOperationDefaultOption();
return client.file.listFromComputeNodeNext(nextLink, batchOptions, __cb(_, __frame, 34, 29, function ___(__0, __4) { result = __4;
result.forEach(function(file) {
files.push(file); });
nextLink = result.odatanextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$listNodeFile() { if (err) {
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$listNodeFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listNodeFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listNodeFile() {
cli.interaction.formatOutput(files, function(outputData) {
var UTCFormat = "YYYY-MM-DDTHH:MI:SSZ";
if ((outputData.length === 0)) {
logger.info($("No file found")); }
else {
logger.table(outputData, function(row, item) {
row.cell($("Name"), item.name);
row.cell($("Is Directory"), item.isDirectory);
if (item.properties) {
row.cell($("Content Length"), item.properties.contentLength);
if (item.properties.creationTime) {
row.cell($("Creation Time"), item.properties.creationTime.toUTCFormat(UTCFormat)); } ; } ; }); } ; }); _(); }); }); }, true)); }, true)); }); };
function listTaskFile(jobId, taskId, options, _) { var client, tips, batchOptions, files, result, nextLink; var __frame = { name: "listTaskFile", line: 489 }; return __func(_, this, arguments, listTaskFile, 3, __frame, function __$listTaskFile() {
if (!jobId) {
jobId = options.jobId; } ;
return interaction.promptIfNotGiven($("Job Id: "), jobId, __cb(_, __frame, 4, 24, function ___(__0, __1) { jobId = __1;
if (!taskId) {
taskId = options.taskId; } ;
return interaction.promptIfNotGiven($("Task Id: "), taskId, __cb(_, __frame, 8, 25, function ___(__0, __2) { taskId = __2;
client = batchUtil.createBatchServiceClient(options);
tips = $("Listing task files");
batchOptions = { };
batchOptions.fileListFromTaskOptions = batchUtil.getBatchOperationDefaultOption();
if (options.recursive) {
batchOptions.recursive = true; } ;
if (options.filterClause) {
batchOptions.fileListFromTaskOptions.filter = options.filterClause; } ;
files = [];
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listTaskFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listTaskFile() {
return client.file.listFromTask(jobId, taskId, batchOptions, __cb(_, __frame, 26, 31, function ___(__0, __3) { result = __3;
result.forEach(function(file) {
files.push(file); });
nextLink = result.odatanextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$listTaskFile() { __more = false;
var __8 = nextLink; if (__8) {
batchOptions.fileListFromTaskOptions = batchUtil.getBatchOperationDefaultOption();
return client.file.fileListFromTaskOptions(nextLink, batchOptions, __cb(_, __frame, 34, 29, function ___(__0, __4) { result = __4;
result.forEach(function(file) {
files.push(file); });
nextLink = result.odatanextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$listTaskFile() { if (err) {
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$listTaskFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listTaskFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listTaskFile() {
cli.interaction.formatOutput(files, function(outputData) {
var UTCFormat = "YYYY-MM-DDTHH:MI:SSZ";
if ((outputData.length === 0)) {
logger.info($("No file found")); }
else {
logger.table(outputData, function(row, item) {
row.cell($("Name"), item.name);
row.cell($("Is Directory"), item.isDirectory);
if (item.properties) {
row.cell($("Content Length"), item.properties.contentLength);
if (item.properties.creationTime) {
row.cell($("Creation Time"), item.properties.creationTime.toUTCFormat(UTCFormat)); } ; } ; }); } ; }); _(); }); }); }, true)); }, true)); }); };
function getNodeFile(poolId, nodeId, fileName, destination, options, _) { var force, localFileName, result, directory, file, stat, client, tips, batchOptions, reader, fd, data, cur; var __frame = { name: "getNodeFile", line: 569 }; return __func(_, this, arguments, getNodeFile, 5, __frame, function __$getNodeFile() {
if (!poolId) {
poolId = options.id; } ;
return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __2) { poolId = __2;
if (!nodeId) {
nodeId = options.nodeId; } ;
return interaction.promptIfNotGiven($("Node id: "), nodeId, __cb(_, __frame, 8, 25, function ___(__0, __3) { nodeId = __3;
if (!fileName) {
fileName = options.fileName; } ;
return interaction.promptIfNotGiven($("File name: "), fileName, __cb(_, __frame, 12, 27, function ___(__0, __4) { fileName = __4;
if (!destination) {
destination = options.destination; } ;
force = !!options.quiet;
localFileName = StorageUtil.normalizePath(fileName);
result = StorageUtil.fetchBasenameAndDirname(localFileName);
directory = result.dirname;
file = result.basename;
logger.verbose(directory);
logger.verbose(file); return (function __$getNodeFile(__then) {
if (destination) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getNodeFile() {
return fs.stat(destination, __cb(_, __frame, 28, 18, function ___(__0, __5) { stat = __5;
if (stat.isDirectory()) {
destination = pathUtil.join(destination, file); } ; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$getNodeFile() { if (err) {
if (!StorageUtil.isFileNotFoundException(err)) {
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else {
destination = pathUtil.join(".", file); __then(); } ; })(function __$getNodeFile() {
return utils.fileExists(destination, __cb(_, __frame, 44, 14, function ___(__0, __6) { return (function __$getNodeFile(__then) { if (__6) { return (function __$getNodeFile(__then) {
if ((force !== true)) {
return interaction.confirm(util.format($("Do you want to overwrite file %s? "), destination), __cb(_, __frame, 46, 28, function ___(__0, __7) { force = __7;
if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$getNodeFile() {
client = batchUtil.createBatchServiceClient(options);
tips = util.format($("Downloading file %s"), fileName);
batchOptions = { };
batchOptions.fileGetFromComputeNodeOptions = batchUtil.getBatchOperationDefaultOption();
if (options.ifModifiedSince) {
batchOptions.fileGetFromComputeNodeOptions.ifModifiedSince = options.ifModifiedSince; } ;
if (options.ifUnmodifiedSince) {
batchOptions.fileGetFromComputeNodeOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;
if (options.range) {
batchOptions.fileGetFromComputeNodeOptions.ocpRange = options.range; } ;
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getNodeFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getNodeFile() {
return client.file.getFromComputeNode(poolId, nodeId, fileName, batchOptions, __cb(_, __frame, 71, 27, function ___(__0, __8) { stream = __8; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$getNodeFile() { if (err) {
if (batchUtil.isNotFoundException(err)) {
return _(new Error(util.format($("Pool %s or node %s doesn't exist"), poolId, nodeId))); }
else {
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getNodeFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getNodeFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getNodeFile() {
reader = new ss.ReadableStream(stream);
fd = fs.openSync(destination, "w");
cur = 0; var __1 = true; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$getNodeFile() { __more = false;
var __17 = (__1 || (data !== null)); if (__17) { __1 = false; return reader.read(__cb(_, __frame, 93, 20, function ___(__0, __9) { data = __9; return (function __$getNodeFile(__then) { if ((data !== null)) { return fs.write(fd, data, 0, data.length, cur, __cb(_, __frame, 95, 11, function __$getNodeFile() { cur += data.length; __then(); }, true)); } else { __then(); } ; })(function __$getNodeFile() { while (__more) { __loop(); }; __more = true; }); }, true), 10000); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$getNodeFile() {
fs.close(fd);
logger.info(util.format($("File %s has been saved to %s successfully"), fileName, destination)); _(); }); }); }); }); }, true)); }); }, true)); }, true)); }, true)); }); };
function getTaskFile(jobId, taskId, fileName, destination, options, _) { var force, localFileName, result, directory, file, stat, client, tips, batchOptions, reader, fd, data, cur; var __frame = { name: "getTaskFile", line: 682 }; return __func(_, this, arguments, getTaskFile, 5, __frame, function __$getTaskFile() {
if (!jobId) {
jobId = options.jobId; } ;
return interaction.promptIfNotGiven($("Job id: "), jobId, __cb(_, __frame, 4, 24, function ___(__0, __2) { jobId = __2;
if (!taskId) {
taskId = options.taskId; } ;
return interaction.promptIfNotGiven($("Task id: "), taskId, __cb(_, __frame, 8, 25, function ___(__0, __3) { taskId = __3;
if (!fileName) {
fileName = options.fileName; } ;
return interaction.promptIfNotGiven($("File name: "), fileName, __cb(_, __frame, 12, 27, function ___(__0, __4) { fileName = __4;
if (!destination) {
destination = options.destination; } ;
force = !!options.quiet;
localFileName = StorageUtil.normalizePath(fileName);
result = StorageUtil.fetchBasenameAndDirname(localFileName);
directory = result.dirname;
file = result.basename;
logger.verbose(directory);
logger.verbose(file); return (function __$getTaskFile(__then) {
if (destination) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getTaskFile() {
return fs.stat(destination, __cb(_, __frame, 28, 18, function ___(__0, __5) { stat = __5;
if (stat.isDirectory()) {
destination = pathUtil.join(destination, file); } ; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$getTaskFile() { if (err) {
if (!StorageUtil.isFileNotFoundException(err)) {
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else {
destination = pathUtil.join(".", file); __then(); } ; })(function __$getTaskFile() {
return utils.fileExists(destination, __cb(_, __frame, 44, 14, function ___(__0, __6) { return (function __$getTaskFile(__then) { if (__6) { return (function __$getTaskFile(__then) {
if ((force !== true)) {
return interaction.confirm(util.format($("Do you want to overwrite file %s? "), destination), __cb(_, __frame, 46, 28, function ___(__0, __7) { force = __7;
if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$getTaskFile() {
client = batchUtil.createBatchServiceClient(options);
tips = util.format($("Downloading file %s"), fileName);
batchOptions = { };
batchOptions.fileGetFromTaskOptions = batchUtil.getBatchOperationDefaultOption();
if (options.ifModifiedSince) {
batchOptions.fileGetFromTaskOptions.ifModifiedSince = options.ifModifiedSince; } ;
if (options.ifUnmodifiedSince) {
batchOptions.fileGetFromTaskOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;
if (options.range) {
batchOptions.fileGetFromTaskOptions.ocpRange = options.range; } ;
startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getTaskFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getTaskFile() {
return client.file.getFromTask(jobId, taskId, fileName, batchOptions, __cb(_, __frame, 71, 27, function ___(__0, __8) { stream = __8; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$getTaskFile() { if (err) {
if (batchUtil.isNotFoundException(err)) {
return _(new Error(util.format($("Job %s or task %s doesn't exist"), jobId, taskId))); }
else {
if (err.message) {
if ((typeof err.message === "object")) {
err.message = err.message.value; } ; } ;
return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getTaskFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getTaskFile() {
endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getTaskFile() {
reader = new ss.ReadableStream(stream);
fd = fs.openSync(destination, "w");
cur = 0; var __1 = true; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$getTaskFile() { __more = false;
var __17 = (__1 || (data !== null)); if (__17) { __1 = false; return reader.read(__cb(_, __frame, 93, 20, function ___(__0, __9) { data = __9; return (function __$getTaskFile(__then) { if ((data !== null)) { return fs.write(fd, data, 0, data.length, cur, __cb(_, __frame, 95, 11, function __$getTaskFile() { cur += data.length; __then(); }, true)); } else { __then(); } ; })(function __$getTaskFile() { while (__more) { __loop(); }; __more = true; }); }, true), 10000); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$getTaskFile() {
fs.close(fd);
logger.info(util.format($("File %s has been saved to %s successfully"), fileName, destination)); _(); }); }); }); }); }, true)); }); }, true)); }, true)); }, true)); }); };};