Load the system particle image as the extension permissions
776198
private void loadSystemParticleImage() {
		AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
        		try {
        			if (mask != null) {
        				sprite = new Image(defaultImageName, mask);
        			} else {
        				sprite = new Image(defaultImageName);
        			}
        		} catch (SlickException e) {
        			Log.error(e);
        			defaultImageName = null;
        		}
                return null; // nothing to return
            }
        });
	}
1046225
function () {
    var options = { publicAccessLevel: BlobUtilities.BlobContainerPublicAccessType.CONTAINER };
    blobService.setContainerAcl(container, signedIdentifiers, options, function(error) {
      if (error) {
        console.log(error);
      } else {
        console.log('Uploaded the permissions for the container ' + container);
        callback();
      }
    });
  }
316703
private void loadEnabledPermissionCheckingDirs(Configuration conf) 
      throws IOException {
    if (this.isPermissionEnabled) {
      String[] permissionCheckingDirs = 
          conf.getStrings("dfs.permissions.checking.paths", "/");
      int numDirs = permissionCheckingDirs.length;
      if (numDirs == 0) {
        return;
      }
      this.permissionEnabled = new INode[numDirs];
      int i = 0;
      for (String src : permissionCheckingDirs) {
        INode permissionEnabledNode = this.dir.getINode(src);
        if (permissionEnabledNode == null) {
          throw new IOException(
              "Non-existent path for disabling permission Checking: " + src);
        }
        permissionEnabled[i++] = permissionEnabledNode;
      }
    }
  }
294177
def load_extension(self, extension):
        
        # Load extension from installed pip package
        try:
            package = importlib.import_module(extension)
            extension_directory = package.__path__[0]
        except ImportError:
            message = linesep.join([traceback.format_exc(),
                                    'Error loading extension: `{}` is neither a directory, nor a package.'.format(extension),
                                    'Are you sure it is installed in your environment? If so, look at the stack trace above to determine the origin of this error.',
                                    'See more at <https://github.com/openfisca/openfisca-extension-template#installing>.'])
            raise ValueError(message)

        self.add_variables_from_directory(extension_directory)
        param_dir = path.join(extension_directory, 'parameters')
        if path.isdir(param_dir):
            extension_parameters = ParameterNode(directory_path = param_dir)
            self.parameters.merge(extension_parameters)
1056956
def cli(env, identifier):
    """"""

    image_mgr = SoftLayer.ImageManager(env.client)
    image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image')

    image = image_mgr.get_image(image_id, mask=image_mod.DETAIL_MASK)
    disk_space = 0
    datacenters = []
    for child in image.get('children'):
        disk_space = int(child.get('blockDevicesDiskSpaceTotal', 0))
        if child.get('datacenter'):
            datacenters.append(utils.lookup(child, 'datacenter', 'name'))

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', image['id']])
    table.add_row(['global_identifier',
                   image.get('globalIdentifier', formatting.blank())])
    table.add_row(['name', image['name'].strip()])
    table.add_row(['status', formatting.FormattedItem(
        utils.lookup(image, 'status', 'keyname'),
        utils.lookup(image, 'status', 'name'),
    )])
    table.add_row([
        'active_transaction',
        formatting.transaction_status(image.get('transaction')),
    ])
    table.add_row(['account', image.get('accountId', formatting.blank())])
    table.add_row(['visibility',
                   image_mod.PUBLIC_TYPE if image['publicFlag']
                   else image_mod.PRIVATE_TYPE])
    table.add_row(['type',
                   formatting.FormattedItem(
                       utils.lookup(image, 'imageType', 'keyName'),
                       utils.lookup(image, 'imageType', 'name'),
                   )])
    table.add_row(['flex', image.get('flexImageFlag')])
    table.add_row(['note', image.get('note')])
    table.add_row(['created', image.get('createDate')])
    table.add_row(['disk_space', formatting.b_to_gb(disk_space)])
    table.add_row(['datacenters', formatting.listing(sorted(datacenters),
                                                     separator=',')])

    env.fout(table)
203497
def load_ipython_extension(shell):
  

  # Inject our user agent on all requests by monkey-patching a wrapper around httplib2.Http.request.

  def _request(self, uri, method="GET", body=None, headers=None,
               redirections=_httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None):
    if headers is None:
      headers = {}
    headers['user-agent'] = 'GoogleCloudDataLab/1.0'
    return _orig_request(self, uri, method=method, body=body, headers=headers,
                         redirections=redirections, connection_type=connection_type)

  _httplib2.Http.request = _request

  # Similarly for the requests library.

  def _init_session(self):
    _orig_init(self)
    self.headers['User-Agent'] = 'GoogleCloudDataLab/1.0'

  _requests.Session.__init__ = _init_session

  # Be more tolerant with magics. If the user specified a cell magic that doesn't
  # exist and an empty cell body but a line magic with that name exists, run that
  # instead. Conversely, if the user specified a line magic that doesn't exist but
  # a cell magic exists with that name, run the cell magic with an empty body.

  def _run_line_magic(self, magic_name, line):
    fn = self.find_line_magic(magic_name)
    if fn is None:
      cm = self.find_cell_magic(magic_name)
      if cm:
        return _run_cell_magic(self, magic_name, line, None)
    return _orig_run_line_magic(self, magic_name, line)

  def _run_cell_magic(self, magic_name, line, cell):
    if cell is None or len(cell) == 0 or cell.isspace():
      fn = self.find_line_magic(magic_name)
      if fn:
        return _orig_run_line_magic(self, magic_name, line)
      # IPython will complain if cell is empty string but not if it is None
      cell = None
    return _orig_run_cell_magic(self, magic_name, line, cell)

  _shell.InteractiveShell.run_cell_magic = _run_cell_magic
  _shell.InteractiveShell.run_line_magic = _run_line_magic

  # Define global 'project_id' and 'set_project_id' functions to manage the default project ID. We
  # do this conditionally in a try/catch # to avoid the call to Context.default() when running tests
  # which mock IPython.get_ipython().

  def _get_project_id():
    try:
      return google.datalab.Context.default().project_id
    except Exception:
      return None

  def _set_project_id(project_id):
    context = google.datalab.Context.default()
    context.set_project_id(project_id)
    try:
      from datalab.context import Context as _old_context
      _old_context.default().set_project_id(project_id)
    except ImportError:
      # If the old library is not loaded, then we don't have to do anything
      pass

  try:
    if 'datalab_project_id' not in _IPython.get_ipython().user_ns:
      _IPython.get_ipython().user_ns['datalab_project_id'] = _get_project_id
      _IPython.get_ipython().user_ns['set_datalab_project_id'] = _set_project_id
  except TypeError:
    pass
342010
function loadUses() {
          var globs = Array.prototype.slice.call(arguments, 0);
          var path = require('path');
          utils.forEach(globs, function(patt) {
            var files = glob.sync(patt, {});
            utils.forEach(files, function(file) {
              require(path.join(process.cwd(), file));
            });
          });

          return moduleInstance;
        }
775283
def push_images(base_path, image_namespace, engine_obj, config, **kwargs):
    
    config_path = kwargs.get('config_path', engine_obj.auth_config_path)
    username = kwargs.get('username')
    password = kwargs.get('password')
    push_to = kwargs.get('push_to')
    url = engine_obj.default_registry_url
    registry_name = engine_obj.default_registry_name
    namespace = image_namespace
    save_conductor = config.save_conductor
    repository_prefix = None
    pull_from_url = None

    if push_to:
        if config.get('registries', dict()).get(push_to):
            url = config['registries'][push_to].get('url')
            namespace = config['registries'][push_to].get('namespace', namespace)
            repository_prefix = config['registries'][push_to].get('repository_prefix')
            pull_from_url = config['registries'][push_to].get('pull_from_url')
            if not url:
                raise AnsibleContainerRegistryAttributeException(
                    u"Registry {} missing required attribute 'url'".format(push_to)
                )
        else:
            url, namespace = resolve_push_to(push_to, engine_obj.default_registry_url, namespace)

    if username and not password:
        # If a username was supplied without a password, prompt for it
        if url != engine_obj.default_registry_url:
            registry_name = url
        while not password:
            password = getpass.getpass(u"Enter password for {0} at {1}: ".format(username, registry_name))

    if config_path:
        # Make sure the config_path exists
        #  - gives us a chance to create the file with correct permissions, if it does not exists
        #  - makes sure we mount a path to the conductor for a specific file
        config_path = os.path.normpath(os.path.expanduser(config_path))
        if os.path.exists(config_path) and os.path.isdir(config_path):
            raise AnsibleContainerException(
                u"Expecting --config-path to be a path to a file, not a directory"
            )
        elif not os.path.exists(config_path):
            # Make sure the directory path exists
            if not os.path.exists(os.path.dirname(config_path)):
                try:
                    os.makedirs(os.path.dirname(config_path), 0o750)
                except OSError:
                    raise AnsibleContainerException(
                        u"Failed to create the requested the path {}".format(os.path.dirname(config_path))
                    )
            # Touch the file
            open(config_path, 'w').close()

    # If you ran build with --save-build-container, then you're broken without first removing
    #  the old build container.
    remove_existing_container(engine_obj, 'conductor', remove_volumes=True)

    push_params = {}
    push_params.update(kwargs)
    push_params['config_path'] = config_path
    push_params['password'] = password
    push_params['url'] = url
    push_params['namespace'] = namespace
    push_params['repository_prefix'] = repository_prefix
    push_params['pull_from_url'] = pull_from_url

    # Push
    engine_obj.await_conductor_command('push', dict(config), base_path, push_params, save_container=save_conductor)

    return {'url': url,
            'namespace': namespace,
            'repository_prefix': repository_prefix,
            'pull_from_url': pull_from_url }
875787
def load_template(name, directory, extension, encoding, encoding_errors):
    
    abs_path = get_abs_template_path(name, directory, extension)
    return load_file(abs_path, encoding, encoding_errors)
551162
def cli(env, identifier, enable, permission, from_user):
    """"""
    mgr = SoftLayer.UserManager(env.client)
    user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
    result = False
    if from_user:
        from_user_id = helpers.resolve_id(mgr.resolve_ids, from_user, 'username')
        result = mgr.permissions_from_user(user_id, from_user_id)
    elif enable:
        result = mgr.add_permissions(user_id, permission)
    else:
        result = mgr.remove_permissions(user_id, permission)

    if result:
        click.secho("Permissions updated successfully: %s" % ", ".join(permission), fg='green')
    else:
        click.secho("Failed to update permissions: %s" % ", ".join(permission), fg='red')
979644
def _loadData(self, data):
        
        self._data = data
        self.allowCameraUpload = cast(bool, data.attrib.get('allowCameraUpload'))
        self.allowChannelAccess = cast(bool, data.attrib.get('allowChannelAccess'))
        self.allowMediaDeletion = cast(bool, data.attrib.get('allowMediaDeletion'))
        self.allowSharing = cast(bool, data.attrib.get('allowSharing'))
        self.allowSync = cast(bool, data.attrib.get('allowSync'))
        self.backgroundProcessing = cast(bool, data.attrib.get('backgroundProcessing'))
        self.certificate = cast(bool, data.attrib.get('certificate'))
        self.companionProxy = cast(bool, data.attrib.get('companionProxy'))
        self.diagnostics = utils.toList(data.attrib.get('diagnostics'))
        self.eventStream = cast(bool, data.attrib.get('eventStream'))
        self.friendlyName = data.attrib.get('friendlyName')
        self.hubSearch = cast(bool, data.attrib.get('hubSearch'))
        self.machineIdentifier = data.attrib.get('machineIdentifier')
        self.multiuser = cast(bool, data.attrib.get('multiuser'))
        self.myPlex = cast(bool, data.attrib.get('myPlex'))
        self.myPlexMappingState = data.attrib.get('myPlexMappingState')
        self.myPlexSigninState = data.attrib.get('myPlexSigninState')
        self.myPlexSubscription = cast(bool, data.attrib.get('myPlexSubscription'))
        self.myPlexUsername = data.attrib.get('myPlexUsername')
        self.ownerFeatures = utils.toList(data.attrib.get('ownerFeatures'))
        self.photoAutoTag = cast(bool, data.attrib.get('photoAutoTag'))
        self.platform = data.attrib.get('platform')
        self.platformVersion = data.attrib.get('platformVersion')
        self.pluginHost = cast(bool, data.attrib.get('pluginHost'))
        self.readOnlyLibraries = cast(int, data.attrib.get('readOnlyLibraries'))
        self.requestParametersInCookie = cast(bool, data.attrib.get('requestParametersInCookie'))
        self.streamingBrainVersion = data.attrib.get('streamingBrainVersion')
        self.sync = cast(bool, data.attrib.get('sync'))
        self.transcoderActiveVideoSessions = int(data.attrib.get('transcoderActiveVideoSessions', 0))
        self.transcoderAudio = cast(bool, data.attrib.get('transcoderAudio'))
        self.transcoderLyrics = cast(bool, data.attrib.get('transcoderLyrics'))
        self.transcoderPhoto = cast(bool, data.attrib.get('transcoderPhoto'))
        self.transcoderSubtitles = cast(bool, data.attrib.get('transcoderSubtitles'))
        self.transcoderVideo = cast(bool, data.attrib.get('transcoderVideo'))
        self.transcoderVideoBitrates = utils.toList(data.attrib.get('transcoderVideoBitrates'))
        self.transcoderVideoQualities = utils.toList(data.attrib.get('transcoderVideoQualities'))
        self.transcoderVideoResolutions = utils.toList(data.attrib.get('transcoderVideoResolutions'))
        self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
        self.updater = cast(bool, data.attrib.get('updater'))
        self.version = data.attrib.get('version')
        self.voiceSearch = cast(bool, data.attrib.get('voiceSearch'))
235198
def create_storage_policy(profile_manager, policy_spec):
    '''
    
    '''
    try:
        profile_manager.Create(policy_spec)
    except vim.fault.NoPermission as exc:
        log.exception(exc)
        raise VMwareApiError('Not enough permissions. Required privilege: '
                             '{0}'.format(exc.privilegeId))
    except vim.fault.VimFault as exc:
        log.exception(exc)
        raise VMwareApiError(exc.msg)
    except vmodl.RuntimeFault as exc:
        log.exception(exc)
        raise VMwareRuntimeError(exc.msg)
1102061
def _load_extensions(root):
    """"""
    out = collections.OrderedDict()
    for elem in root.findall('extensions/extension'):
        name = elem.attrib['name']
        supported = set(elem.attrib['supported'].split('|'))
        requires = [_load_require(x) for x in elem.findall('require')]
        comment = elem.get('comment')
        out[name] = Extension(name, supported, requires, comment)
    return out
131160
public static void requireAccess (ClientObject clobj, Permission perm, Object context)
        throws InvocationException
    {
        String errmsg = clobj.checkAccess(perm, context);
        if (errmsg != null) {
            throw new InvocationException(errmsg);
        }
    }
1300316
function loadEngines() {
  
  // Initialize engine properties
  this.enginesByExtension = {};
  
  // Engine local variables
  var exts = [];
  var loadedEngines = this.loadedEngines = Object.keys(protos.engines);
  
  if (loadedEngines.length > 0) {
    
    // Get view engines
    var engine, instance, engineProps = ['className', 'extensions'];
    for (engine in protos.engines) {
      instance = new protos.engines[engine]();
      instance.className = instance.constructor.name;
      protos.util.onlySetEnumerable(instance, engineProps);
      this.engines[engine] = instance;
    }

    // Register engine extensions
    for (var key in this.engines) {
      engine = this.engines[key];
      exts = exts.concat(engine.extensions);
      for (var i=0; i < engine.extensions.length; i++) {
        key = engine.extensions[i];
        this.enginesByExtension[key] = engine;
      }
    }
    
    // Set default view extension if not set
    if (typeof this.config.viewExtensions.html == 'undefined') {
      this.config.viewExtensions.html = 'ejs';
    }

    // Override engine extensions (from config)
    var ext, extOverrides = this.config.viewExtensions;
    
    for (ext in extOverrides) {
      if (exts.indexOf(ext) == -1) exts.push(ext); // Register extension on `exts`
      engine = this.engines[extOverrides[ext]]; // Get engine object
      if (engine) {
        engine.extensions.push(ext); // Add ext to engine extensions
        this.enginesByExtension[ext] = engine; // Override engine extension
      } else {
        this.debug(util.format("Ignoring '%s' extension: the '%s' engine is not loaded"), ext, extOverrides[ext]);
      }
    }

    // Set default template engine
    this.defaultEngine = (this.engines.ejs || this.engines[loadedEngines[0]]);

    // Add the engines regular expression
    this.engineRegex = new RegExp('^(' + Object.keys(this.engines).join('|').replace(/\-/, '\\-') + ')$');

  }
  
  // Generate template file regex from registered template extensions
  this.regex.templateFile = new RegExp('\\.(' + exts.join('|') + ')$');
  this.templateExtensions = exts;

  this.emit('engines_loaded', this.engines); // Emit regardless
  
}
439961
static ZTFilePermissions fromPosixFileMode(int mode) {
    ZTFilePermissions permissions = new ZTFilePermissions();
    
    permissions.setOwnerCanExecute( (mode &  OWNER_EXECUTE_FLAG)  > 0 );
    permissions.setGroupCanExecute( (mode &  GROUP_EXECUTE_FLAG)  > 0 );
    permissions.setOthersCanExecute((mode &  OTHERS_EXECUTE_FLAG) > 0 );
    
    permissions.setOwnerCanWrite( (mode &  OWNER_WRITE_FLAG)  > 0 );
    permissions.setGroupCanWrite( (mode &  GROUP_WRITE_FLAG)  > 0 );
    permissions.setOthersCanWrite((mode &  OTHERS_WRITE_FLAG) > 0 );
    
    permissions.setOwnerCanRead( (mode &  OWNER_READ_FLAG)  > 0 );
    permissions.setGroupCanRead( (mode &  GROUP_READ_FLAG)  > 0 );
    permissions.setOthersCanRead((mode &  OTHERS_READ_FLAG) > 0 );
    
    return permissions;
  }
1261872
function(done) {
                var source = __dirname + '/manifest.json';
                var dest = self.dir + '/manifest.json';

                fs.readFile(source, function(err, manifest) {
                    if (err) return done(err);

                    manifest = JSON.parse(manifest);
                    manifest.permissions.push.apply(manifest.permissions, settings.permissions);

                    fs.writeFile(dest, JSON.stringify(manifest, null, '\t'), done);
                });
            }