stack:set STACK

 set new app stack
355202
def set
      unless stack = Codex.in(shift_argument)
        error("Usage: heroku stack:set STACK.\nMust specify target stack.")
      end

      api.put_stack(app, stack)
      display "Stack set. Next release on #{app} will use #{Codex.out(stack)}."
      display "Run `git push heroku master` to create a new release on #{Codex.out(stack)}."
    end
945255
def init_app(cls, app, callback=None):
        
        processed = set()
        cls.__views__ = set()
        cls.is_always_available = False
        for base in cls.__mro__:
            for name, attr in base.__dict__.items():
                if name in processed:
                    continue
                processed.add(name)
                if isinstance(attr, ViewHandler):
                    if base != cls:  # Copy ViewHandler instances into subclasses
                        # TODO: Don't do this during init_app. Use a metaclass
                        # and do this when the class is defined.
                        attr = attr.copy_for_subclass()
                        setattr(cls, name, attr)
                    attr.__set_name__(cls, name)  # Required for Python < 3.6
                    cls.__views__.add(name)
                    attr.init_app(app, cls, callback=callback)
                    if not hasattr(attr.wrapped_func, 'is_available'):
                        cls.is_always_available = True
736867
public static void setStack(final Collection<String> stack) {
        if (stack.isEmpty() || !useStack) {
            return;
        }
        contextStack.clear();
        contextStack.addAll(stack);
    }
854487
def init_app(self, app):
        """"""
        app.config.from_pyfile('{0}.cfg'.format(app.name), silent=True)
170798
def stack_push(self, key, value):
        
        task = Task.current_task()
        try:
            context = task._context_stack
        except AttributeError:
            task._context_stack = context = {}
        if key not in context:
            context[key] = []
        context[key].append(value)
648208
def init_app(app, *storages):
    '''
    
    '''

    # Set default configuration
    app.config.setdefault('FS_SERVE', app.config.get('DEBUG', False))
    app.config.setdefault('FS_ROOT', join(app.instance_path, 'fs'))
    app.config.setdefault('FS_PREFIX', None)
    app.config.setdefault('FS_URL', None)
    app.config.setdefault('FS_BACKEND', DEFAULT_BACKEND)
    app.config.setdefault('FS_IMAGES_OPTIMIZE', False)

    state = app.extensions['fs'] = app.extensions.get('fs', {})
    for storage in storages:
        storage.configure(app)
        state[storage.name] = storage

    from .views import bp
    app.register_blueprint(bp, url_prefix=app.config['FS_PREFIX'])
1346641
def new(self, name=None, stack='cedar', region=None):
        """"""

        payload = {}

        if name:
            payload['app[name]'] = name

        if stack:
            payload['app[stack]'] = stack

        if region:
            payload['app[region]'] = region

        r = self._h._http_resource(
            method='POST',
            resource=('apps',),
            data=payload
        )

        name = json.loads(r.content).get('name')
        return self._h.apps.get(name)
321473
def init_app(self, app):
        """"""
        if self.module:
            app.config.from_object(self.module)
580247
def newapp(path):
    

    app_path = os.path.join(VODKA_INSTALL_DIR, "resources", "blank_app")
    if not os.path.exists(path):
        os.makedirs(path)
    elif os.path.exists(os.path.join(path, "application.py")):
        click.error("There already exists a vodka app at %s, please specify a different path" % path)
    os.makedirs(os.path.join(path, "plugins"))
    shutil.copy(os.path.join(app_path, "application.py"), os.path.join(path, "application.py"))
    shutil.copy(os.path.join(app_path, "__init__.py"), os.path.join(path, "__init__.py"))
    shutil.copy(os.path.join(app_path, "plugins", "example.py"), os.path.join(path, "plugins", "example.py"))
    shutil.copy(os.path.join(app_path, "plugins", "__init__.py"), os.path.join(path, "plugins", "__init__.py"))
211898
function (start, step) {
    this.step = step || 1;
    this.last = (utils.isUndefined(start) ? 1 : start) - this.step;
    this.stack = [];
}
947940
private function creationStacks()
    {
        $cloudFormation = $this->getService();

        if (true !== $this->getUpdateOnConflict()) {
            throw new \BuildException('Stack ' . $this->getName() . ' not exist. Creation stack was skip due to property updateOnConflict set to false');
        }

        try {
            $this->log('Create stacks...');
            $cloudFormation->createStack($this->stackProperties());
        } catch (CloudFormationException $e) {
            if ($e->getAwsErrorCode() !== 'AlreadyExistsException') {
                throw $e;
            } else {
                $this->log('stack [' . $this->getName() . '] creation already in progress.');
            }
        }
    }
1100765
private void updateFromStack(Stack stack) {
    long startTime = System.currentTimeMillis();

    // Update LocalPeer
    Peer sLocalPeer = stack.getMetaData().getLocalPeer();

    localPeer.setUri(sLocalPeer.getUri().toString());
    for (InetAddress ipAddress : sLocalPeer.getIPAddresses()) {
      localPeer.addIpAddress(ipAddress.getHostAddress());
    }
    localPeer.setRealm(sLocalPeer.getRealmName());
    localPeer.setVendorId(sLocalPeer.getVendorId());
    localPeer.setProductName(sLocalPeer.getProductName());
    localPeer.setFirmwareRev(sLocalPeer.getFirmware());
    for (org.jdiameter.api.ApplicationId appId : sLocalPeer.getCommonApplications()) {
      if (appId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) {
        localPeer.addDefaultApplication(ApplicationIdJMX.createAuthApplicationId(appId.getVendorId(), appId.getAuthAppId()));
      }
      else {
        localPeer.addDefaultApplication(ApplicationIdJMX.createAcctApplicationId(appId.getVendorId(), appId.getAcctAppId()));
      }
    }
    HashMap<String, DiameterStatistic> lpStats = new HashMap<String, DiameterStatistic>();
    for (StatisticRecord stat : ((IPeer) sLocalPeer).getStatistic().getRecords()) {
      lpStats.put(stat.getName(), new DiameterStatistic(stat.getName(), stat.getDescription(), stat.toString()));
    }
    localPeer.setStatistics(lpStats);

    MutableConfiguration config = (MutableConfiguration) stack.getMetaData().getConfiguration();

    // Update Parameters
    this.parameters = new ParametersImpl(config);

    // Update Network ...
    // ... Peers (config)
    for (Configuration curPeer : config.getChildren(PeerTable.ordinal())) {
      String name = curPeer.getStringValue(PeerName.ordinal(), "");
      Boolean attemptConnect = curPeer.getBooleanValue(PeerAttemptConnection.ordinal(), false);
      Integer rating = curPeer.getIntValue(PeerRating.ordinal(), 0);
      String ip = curPeer.getStringValue(PeerIp.ordinal(), null);
      String portRange = curPeer.getStringValue(PeerLocalPortRange.ordinal(), "");
      Integer portRangeLow = null;
      Integer portRangeHigh = null;
      if (portRange != null && !portRange.equals("")) {
        String[] rng = portRange.trim().split("-");
        portRangeLow = Integer.parseInt(rng[0]);
        portRangeHigh = Integer.parseInt(rng[1]);
      }
      String securityRef = curPeer.getStringValue(SecurityRef.ordinal(), "");
      network.addPeer(new NetworkPeerImpl(name, attemptConnect, rating, ip, portRangeLow, portRangeHigh, securityRef));
    }

    // ... More Peers (mutable)
    try {
      MutablePeerTable peerTable;
      peerTable = stack.unwrap(MutablePeerTable.class);
      //Peer p = n.addPeer("aaa://127.0.0.1:13868", "mobicents.org", true);
      for (Peer peer : peerTable.getPeerTable()) {
        PeerImpl p = (PeerImpl) peer;
        NetworkPeerImpl nPeer = new NetworkPeerImpl(p.getUri().toString(), p.isAttemptConnection(), p.getRating(), null, null, null, null);
        HashMap<String, DiameterStatistic> npStats = new HashMap<String, DiameterStatistic>();
        for (StatisticRecord stat : p.getStatistic().getRecords()) {
          npStats.put(stat.getName(), new DiameterStatistic(stat.getName(), stat.getDescription(), stat.toString()));
        }
        nPeer.setStatistics(npStats);
        network.addPeer(nPeer);
      }
    }
    catch (InternalException e) {
      logger.error("Failed to update Diameter Configuration from Stack Mutable Peer Table", e);
    }

    // ... Realms (configuration)
    /*for(Configuration realmTable : config.getChildren(RealmTable.ordinal())) {
      for(Configuration curRealm : realmTable.getChildren(RealmEntry.ordinal())) {
        String name = curRealm.getStringValue(RealmName.ordinal(), "");
        String hosts = curRealm.getStringValue(RealmHosts.ordinal(), "localhost");
        ArrayList<String> peers = new ArrayList<String>();
        for(String peer : hosts.split(",")) {
          peers.add(peer.trim());
        }
        String localAction = curRealm.getStringValue(RealmLocalAction.ordinal(), "LOCAL");
        Boolean dynamic = curRealm.getBooleanValue(RealmEntryIsDynamic.ordinal(), false);
        Long expTime = curRealm.getLongValue(RealmEntryExpTime.ordinal(), 0);
        Configuration[] sAppIds = curRealm.getChildren(ApplicationId.ordinal());
        ArrayList<ApplicationIdJMX> appIds = new ArrayList<ApplicationIdJMX>();
        for(Configuration appId : sAppIds) {
          Long acctAppId = appId.getLongValue(AcctApplId.ordinal(), 0);
          Long authAppId = appId.getLongValue(AuthApplId.ordinal(), 0);
          Long vendorId = appId.getLongValue(VendorId.ordinal(), 0);
          if(authAppId != 0) {
            appIds.add(ApplicationIdJMX.createAuthApplicationId(vendorId, authAppId));
          }
          else if (acctAppId != 0){
            appIds.add(ApplicationIdJMX.createAcctApplicationId(vendorId, acctAppId));
          }
        }
        network.addRealm(new RealmImpl(appIds, name, peers, localAction, dynamic, expTime));
      }
    }
     */
    // ... Realms (mutable)
    try {
      MutablePeerTableImpl mpt = (MutablePeerTableImpl) stack.unwrap(PeerTable.class);
      for (org.jdiameter.api.Realm realm : mpt.getAllRealms()) {
        IRealm irealm = null;
        if (realm instanceof IRealm) {
          irealm = (IRealm) realm;
        }
        ArrayList<ApplicationIdJMX> x = new ArrayList<ApplicationIdJMX>();
        x.add(ApplicationIdJMX.fromApplicationId(realm.getApplicationId()));
        network.addRealm(new RealmImpl(x, realm.getName(), new ArrayList<String>(Arrays.asList(((IRealm) realm).getPeerNames())),
            realm.getLocalAction().toString(), irealm != null ? irealm.getAgentConfiguration() : null, realm.isDynamic(), realm.getExpirationTime()));
      }
    }
    catch (Exception e) {
      logger.error("Failed to update Diameter Configuration from Stack Mutable Peer Table", e);
    }

    long endTime = System.currentTimeMillis();

    logger.debug("Info gathered in {}ms", (endTime - startTime));
  }
1036195
def _add_to_stack(self, item, value):
        
        p_value = (item, value)
        if p_value not in self.stack:
            self.stack.append(p_value)
370333
def update_stack(name, template_body=None, template_url=None, parameters=None, notification_arns=None,
                 disable_rollback=False, timeout_in_minutes=None, capabilities=None, tags=None,
                 use_previous_template=None, stack_policy_during_update_body=None, stack_policy_during_update_url=None,
                 stack_policy_body=None, stack_policy_url=None, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        update = conn.update_stack(name, template_body, template_url, parameters, notification_arns,
                                   disable_rollback, timeout_in_minutes, capabilities, tags, use_previous_template,
                                   stack_policy_during_update_body, stack_policy_during_update_url,
                                   stack_policy_body, stack_policy_url)
        log.debug('Updated result is : %s.', update)
        return update
    except BotoServerError as e:
        msg = 'Failed to update stack {0}.'.format(name)
        log.debug(e)
        log.error(msg)
        return six.text_type(e)
463811
def init_app(self, app):
        """"""

        self.app = app
        self.app.apscheduler = self

        self._load_config()
        self._load_jobs()

        if self.api_enabled:
            self._load_api()
1199185
def _set_update(self):
        
        try:
            self._updateStack = False
            stack_name = self._config.get('environment', {}).get('stack_name', None)
            response = self._cloudFormation.describe_stacks(StackName=stack_name)
            stack = response['Stacks'][0]
            if stack['StackStatus'] == 'ROLLBACK_COMPLETE':
                logging.info('stack is in ROLLBACK_COMPLETE status and should be deleted')
                del_stack_resp = self._cloudFormation.delete_stack(StackName=stack_name)
                logging.info('delete started for stack: {}'.format(stack_name))
                logging.debug('delete_stack returned: {}'.format(json.dumps(del_stack_resp, indent=4)))
                stack_delete = self.poll_stack()
                if not stack_delete:
                    return False

            if stack['StackStatus'] in ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_ROLLBACK_COMPLETE']:
                self._updateStack = True
        except:
            self._updateStack = False

        logging.info('update_stack: ' + str(self._updateStack))
        return True
1250615
def refresh_stack(self):
        
        self.stack, _ = self.compute_stack(self.fullstack)
        # find the current frame in the new stack
        for i, (frame, _) in enumerate(self.stack):
            if frame is self.curframe:
                self.curindex = i
                break
        else:
            self.curindex = len(self.stack)-1
            self.curframe = self.stack[-1][0]
            self.print_current_stack_entry()