<commit_before>class VirtualizationController extends KDController

  constructor:->
    super

    @kc = KD.getSingleton("kiteController")
    @payment = KD.singleton "paymentController"
    @resetVMData()

    @kites = {}

    @osKites = {}

    mc = KD.getSingleton('mainController')
    mc.once 'AppIsReady', => @fetchVMs => @emit 'ready'
    mc.on   'AccountChanged', => @emit 'VMListChanged'

    @on 'VMListChanged', @bound 'resetVMData'

  run:(options, callback = noop)->
    options ?= {}
    if "string" is typeof options
      command = options
      options =
        withArgs : command

    @fetchVmName options, (err, vmName) =>
      return callback err  if err?
      options.correlationName = vmName
      @fetchRegion vmName, (region)=>
        options.kiteName = "os-#{region}"
        @kc.run options, callback

  _runWrapper:(command, vm, callback)->
    if vm and 'string' isnt typeof vm
      [callback, vm] = [vm, callback]
    @fetchDefaultVmName (defaultVm)=>
      vm or= defaultVm
      return  unless vm
      @askForApprove command, (approved)=>
        if approved
          cb =<commit_msg>vmController: run will return Promises<commit_after>class VirtualizationController extends KDController

  constructor:->
    super

    @kc = KD.getSingleton("kiteController")
    @payment = KD.singleton "paymentController"
    @resetVMData()

    @kites = {}

    @osKites = {}

    mc = KD.getSingleton('mainController')
    mc.once 'AppIsReady', => @fetchVMs => @emit 'ready'
    mc.on   'AccountChanged', => @emit 'VMListChanged'

    @on 'VMListChanged', @bound 'resetVMData'

  run: Promise.promisify (options, callback = noop)->
    options ?= {}
    if "string" is typeof options
      command = options
      options =
        withArgs : command

    @fetchVmName options, (err, vmName) =>
      return callback err  if err?
      options.correlationName = vmName
      @fetchRegion vmName, (region)=>
        options.kiteName = "os-#{region}"
        @kc.run options, callback

  _runWrapper:(command, vm, callback)->
    if vm and 'string' isnt typeof vm
      [callback, vm] = [vm, callback]
    @fetchDefaultVmName (defaultVm)=>
      vm or= defaultVm
      return  unless vm
      @askForApprove command, (approved)=>
        if approved
          cb =
{'fraction_non_alphanumeric': 0.11877729257641921, 'fraction_numerical': 0.0, 'mean_word_length': 2.8056478405315612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4728865', 'n_tokens_mistral': 727, 'n_tokens_neox': 689, 'n_words': 186}