Browse Source

Merge branch 'master' of https://git.bbh.org.in/chess/elxr

master
guest 2 years ago
parent
commit
7809b31f97
2 changed files with 30 additions and 12 deletions
  1. 6
    6
      index.js
  2. 24
    6
      win_verse.js

+ 6
- 6
index.js View File

var statuslog = utils.Traq var statuslog = utils.Traq
var Traq = utils.Traq var Traq = utils.Traq
Tasq.addlistener(statuslog.statuslog) Tasq.addlistener(statuslog.statuslog)
fs.writeFileSync('run.log', ', ' + JSON.stringify( { m : 'Hello'} ), { 'flag': 'a+' })
// fs.writeFileSync('run.log', ', ' + JSON.stringify( { m : 'Hello'} ), { 'flag': 'a+' })
Tasq.addlistener((e)=>{ fs.writeFileSync('run.log', ', ' + JSON.stringify( e ), { 'flag': 'a+' }) }) Tasq.addlistener((e)=>{ fs.writeFileSync('run.log', ', ' + JSON.stringify( e ), { 'flag': 'a+' }) })
var cli = require('./cliverse') var cli = require('./cliverse')
function isWin(){ return /^win/.test(process.platform) } function isWin(){ return /^win/.test(process.platform) }
initTask(task) initTask(task)


if(repodef.requiresElevation) { if(repodef.requiresElevation) {
elevatedBatch.push(shell_verse.getElevatedTaskInBatch( task ));
if(elevatedBatch.length === 1) { initTask(elevatedBatch[0]) } // PB : TDOO -- Make sure first task also has run context. May need to be moved to win_verse if(elevatedBatch.length === 1) { initTask(elevatedBatch[0]) } // PB : TDOO -- Make sure first task also has run context. May need to be moved to win_verse
elevatedBatch.push(shell_verse.getElevatedTask( task ));
return elevatedBatch[elevatedBatch.length-1] return elevatedBatch[elevatedBatch.length-1]
} }
else { else {
initTask(task) initTask(task)


if(repodef.requiresElevation) { if(repodef.requiresElevation) {
elevatedBatch.push(shell_verse.getElevatedTask( task ));
elevatedBatch.push(shell_verse.getElevatedTaskInBatch( task ));
return elevatedBatch[elevatedBatch.length-1] return elevatedBatch[elevatedBatch.length-1]
} }
else { else {
initTask(task) initTask(task)
if(repodef.requiresElevation) { if(repodef.requiresElevation) {
elevatedBatch.push(shell_verse.getElevatedTask( task ));
elevatedBatch.push(shell_verse.getElevatedTaskInBatch( task ));
return elevatedBatch[elevatedBatch.length-1] return elevatedBatch[elevatedBatch.length-1]
} }
else { else {
var regularpulltasks = function(){ return Promise.resolve(true) } var regularpulltasks = function(){ return Promise.resolve(true) }
if(def.elevated){ if(def.elevated){
elevatedpulltasks = function() {
// shell_verse.getElevatedTask( t1 )
elevatedpulltasks = function() {
var eBatch = [] var eBatch = []
def.elevated.map((def) => getPullTask(def, null, null, null, eBatch)) def.elevated.map((def) => getPullTask(def, null, null, null, eBatch))
return shell_verse.runElevatedBatch(eBatch).then(() => { return shell_verse.runElevatedBatch(eBatch).then(() => {
l('<Br/>cmd = ' + processedArgs._[0]) l('<Br/>cmd = ' + processedArgs._[0])
processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null; processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null;
l('<Br/><Br/>') l('<Br/><Br/>')
// alert(fso.GetAbsolutePathName("."))
var timer = function(){ var timer = function(){
l('.'); l('.');

+ 24
- 6
win_verse.js View File

else return shell_verse.runNonElevated( taskToRun ) else return shell_verse.runNonElevated( taskToRun )
} }


, elevatedRunner( taskToRun ){
, elevatedRunner( taskToRun, inBatch ){
// PB : TODO -- Should be called only when we are in an elevated shell that was already requested from an unelevated shell with a batch of tasks. // PB : TODO -- Should be called only when we are in an elevated shell that was already requested from an unelevated shell with a batch of tasks.
try { try {
var __runasresult = null; var __runasresult = null;
return taskToRun().then((r)=>{ return taskToRun().then((r)=>{
// PB : TODO -- Every elevation should have its own messaging file. Async writes from multiple processes are a problem here... // PB : TODO -- Every elevation should have its own messaging file. Async writes from multiple processes are a problem here...
fs.writeFileSync('run.log', ', ' + JSON.stringify( { info : taskToRun.info, success: true }), { 'flag': 'a+' }) fs.writeFileSync('run.log', ', ' + JSON.stringify( { info : taskToRun.info, success: true }), { 'flag': 'a+' })
fs.writeFileSync('run.done', 'success') // PB : TODO -- This should be done conditionally if we are running inproc.
if(!inBatch) fs.writeFileSync('run.done', 'success') // PB : TODO -- This should be done conditionally if we are running inproc.
return __runasresult = r; return __runasresult = r;
}) })
.catch((e) => { .catch((e) => {
fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' }) fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' })
fs.writeFileSync('run.done', 'failure')
if(!inBatch)fs.writeFileSync('run.done', 'failure')
console.error(e) console.error(e)
}) })
.finally(() => { .finally(() => {
if(__runasresult && !__runasresult.skipped) fs.unlinkSync('run.done')
// if(__runasresult && !__runasresult.skipped) fs.unlinkSync('run.done')
}) })
} }
catch (e) { catch (e) {
console.error('Error Invalid command : ' + e) console.error('Error Invalid command : ' + e)
fs.writeFileSync('run.done', 'error')
if(!inBatch) fs.writeFileSync('run.done', 'error')
} }
finally { finally {
} }
} }
, getElevatedTask : function( taskToRun ){ return ()=>{ return shell_verse.runElevated(taskToRun) }} , getElevatedTask : function( taskToRun ){ return ()=>{ return shell_verse.runElevated(taskToRun) }}
, getElevatedTaskInBatch : function( taskToRun ){ return ()=>{ return shell_verse.runElevatedInBatch(taskToRun) }}
, runElevatedInBatch : ( taskToRun ) => {
if (__isElevated) return shell_verse.elevatedRunner(taskToRun, true)
else return shell_verse.requestElevation(shell_verse.elevatedRunner, taskToRun)
}
, runElevated : ( taskToRun ) => { , runElevated : ( taskToRun ) => {
// Let shell_verse decide whether to Elevate Out of Proc or In Proc // Let shell_verse decide whether to Elevate Out of Proc or In Proc
// In windows we don't need to run each task. We hand over to another shell which in elevated state rebuilds the whole batch and runs. // In windows we don't need to run each task. We hand over to another shell which in elevated state rebuilds the whole batch and runs.
// Irrespective of the batch we just call runElevated once. // Irrespective of the batch we just call runElevated once.
if (__isElevated) { if (__isElevated) {
return any(batchToRun);
return any(batchToRun).then((r)=>{
// PB : TODO -- Every elevation should have its own messaging file. Async writes from multiple processes are a problem here...
// fs.writeFileSync('run.log', ', ' + JSON.stringify( { info : taskToRun.info, success: true }), { 'flag': 'a+' })
fs.writeFileSync('run.done', 'success') // PB : TODO -- This should be done conditionally if we are running inproc.
return __runasresult = r;
})
.catch((e) => {
// fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' })
fs.writeFileSync('run.done', 'failure')
console.error(e)
})
// .finally(() => {
// if(__runasresult && !__runasresult.skipped) fs.unlinkSync('run.done')
// });
} }
else { else {
return this.runElevated(batchToRun[0]) return this.runElevated(batchToRun[0])

Loading…
Cancel
Save