Initial version to 1000

    :param portal_setup: The portal_setup tool
174971
def to_1000(portal_setup):
    

    logger.info("Run all import steps from SENAITE LIMS ...")
    context = portal_setup._getImportContext(PROFILE_ID)
    portal = context.getSite()
    setup_html_filter(portal)
    portal_setup.runAllImportStepsFromProfile(PROFILE_ID)
    logger.info("Run all import steps from SENAITE LIMS [DONE]")
86891
def initialize_vthunder(a10_cfg, device_cfg, client):
    """"""

    vth = a10_cfg.get_vthunder_config()
    initialize_interfaces(vth, device_cfg, client)
    initialize_dns(vth, device_cfg, client)
    initialize_licensing(vth, device_cfg, client)
    initialize_sflow(vth, device_cfg, client)
73863
def setup(app):
    """"""
    app.add_domain(EverettDomain)
    app.add_directive('autocomponent', AutoComponentDirective)

    return {
        'version': __version__,
        'parallel_read_safe': True,
        'parallel_write_safe': True
    }
436132
def setup_benchbuild():
    
    LOG.debug("Setting up Benchbuild...")

    venv_dir = local.path("/benchbuild")
    prefixes = CFG["container"]["prefixes"].value
    prefixes.append(venv_dir)
    CFG["container"]["prefixes"] = prefixes

    src_dir = str(CFG["source_dir"])
    have_src = src_dir is not None
    if have_src:
        __mount_source(src_dir)

    benchbuild = find_benchbuild()
    if benchbuild and not requires_update(benchbuild):
        if have_src:
            __upgrade_from_source(venv_dir, with_deps=False)
        return

    setup_virtualenv(venv_dir)
    if have_src:
        __upgrade_from_source(venv_dir)
    else:
        __upgrade_from_pip(venv_dir)
1165141
def initialise_api(
    debug=False,
    host=None,
    key=None,
    proxy=None,
    user_agent=None,
    headers=None,
    rate_limit=True,
    rate_limit_callback=None,
    error_retry_max=None,
    error_retry_backoff=None,
    error_retry_codes=None,
):
    """"""
    config = cloudsmith_api.Configuration()
    config.debug = debug
    config.host = host if host else config.host
    config.proxy = proxy if proxy else config.proxy
    config.user_agent = user_agent
    config.headers = headers
    config.rate_limit = rate_limit
    config.rate_limit_callback = rate_limit_callback
    config.error_retry_max = error_retry_max
    config.error_retry_backoff = error_retry_backoff
    config.error_retry_codes = error_retry_codes

    if headers:
        if "Authorization" in config.headers:
            encoded = config.headers["Authorization"].split(" ")[1]
            decoded = base64.b64decode(encoded)
            values = decoded.decode("utf-8")
            config.username, config.password = values.split(":")

    set_api_key(config, key)
    return config
594029
def init(port=8813, numRetries=10, host="localhost", label="default"):
    
    _connections[label] = connect(port, numRetries, host)
    switch(label)
    return getVersion()
355748
public static function startup()
    {
        global $PPHP;

        $sessionSeconds = $PPHP['config']['session']['gc_maxlifetime'] * 60;
        // Start a PHP-handled session and bind it to the current remote IP address as
        // a precaution per https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet
        // We'll go one step further in _magic() and throw in User Agent details.
        ini_set('session.gc_probability', 1);
        ini_set('session.gc_gc_divisor', 1000);
        ini_set('session.gc_maxlifetime', $sessionSeconds);
        session_save_path($PPHP['dir'] . '/var/sessions');
        ini_set('session.cookie_lifetime', 0);  // Session
        ini_set('session.cookie_httponly', true);
        session_start();
        if (isset($_SESSION['magic'])) {
            if ($_SESSION['magic'] !== self::_magic()) {
                self::reset();
            };
        } else {
            self::_init();
        };
    }
661738
def __init_url(self):
        """"""
        portals_self_url = "{}/portals/self".format(self._url)
        params = {
            "f" :"json"
        }
        if not self._securityHandler is None:
            params['token'] = self._securityHandler.token
        res = self._get(url=portals_self_url,
                           param_dict=params,
                           securityHandler=self._securityHandler,
                           proxy_url=self._proxy_url,
                           proxy_port=self._proxy_port)
        if "helperServices" in res:
            helper_services = res.get("helperServices")
            if "hydrology" in helper_services:
                analysis_service = helper_services.get("elevation")
                if "url" in analysis_service:
                    self._analysis_url = analysis_service.get("url")
        self._gpService = GPService(url=self._analysis_url,
                                    securityHandler=self._securityHandler,
                                    proxy_url=self._proxy_url,
                                    proxy_port=self._proxy_port,
                                    initialize=False)
17975
def makeMigrator(context, portal_type, remove_old_value=True):
    
    meta_type = portal_type

    class BlobMigrator(BaseInlineMigrator):
        """in-place migrator for archetypes based content that copies
        file/image data from old non-blob fields to new fields with the same
        name  provided by archetypes.schemaextender.

        see `plone3 to 4 migration guide`__

        .. __: https://plone.org/documentation/manual/upgrade-guide/version
        /upgrading-plone-3-x-to-4.0/updating-add-on-products-for-plone-4.0
        /use-plone.app.blob-based-blob-storage
        """

        src_portal_type = portal_type
        src_meta_type = meta_type
        dst_portal_type = portal_type
        dst_meta_type = meta_type
        fields = []

        def getFields(self, obj):
            if not self.fields:
                # get the blob fields to migrate from the first object
                for field in ISchema(obj).fields():
                    if IBlobField.providedBy(field):
                        self.fields.append(field.getName())
            return self.fields

        @property
        def fields_map(self):
            fields = self.getFields(None)
            return dict([(name, None) for name in fields])

        def migrate_data(self):
            fields = self.getFields(self.obj)
            for name in fields:
                # access old field by not using schemaextender
                oldfield = self.obj.schema[name]
                is_imagefield = False
                if hasattr(oldfield, 'removeScales'):
                    # clean up old image scales
                    is_imagefield = True
                    oldfield.removeScales(self.obj)
                value = oldfield.get(self.obj)

                if not value:
                    # no image/file data: don't copy it over to blob field
                    # this way it's save to run migration multiple times w/o
                    # overwriting existing data
                    continue

                if isinstance(aq_base(value), BlobWrapper):
                    # already a blob field, no need to migrate it
                    continue

                # access new field via schemaextender
                field = self.obj.getField(name)
                field.getMutator(self.obj)(value)

                if remove_old_value:
                    # Remove data from old field to not end up with data
                    # stored twice - in ZODB and blobstorage
                    if is_imagefield:
                        oldfield.set(self.obj, 'DELETE_IMAGE')
                    else:
                        oldfield.set(self.obj, 'DELETE_FILE')

        def last_migrate_reindex(self):
            # The original method checks the modification date in order to
            # keep the old one, but we don't care about it.
            self.obj.reindexObject()

    return BlobMigrator
1211292
def setup(app, version):
    
    app.add_config_value('imgur_api_cache_ttl', 172800, False)
    app.add_config_value('imgur_client_id', None, False)
    app.add_config_value('imgur_hide_post_details', False, True)
    app.add_config_value('imgur_target_default_gallery', False, True)
    app.add_config_value('imgur_target_default_largest', False, True)
    app.add_config_value('imgur_target_default_page', False, True)

    app.add_directive('imgur-embed', ImgurEmbedDirective)
    app.add_directive('imgur-image', ImgurImageDirective)
    app.add_node(ImgurEmbedNode, html=(ImgurEmbedNode.visit, ImgurEmbedNode.depart))
    app.add_node(ImgurImageNode, html=(ImgurImageNode.visit, ImgurImageNode.depart))
    app.add_node(ImgurJavaScriptNode, html=(ImgurJavaScriptNode.visit, ImgurJavaScriptNode.depart))
    app.add_role('imgur-description', imgur_role)
    app.add_role('imgur-title', imgur_role)

    app.connect('env-before-read-docs', event_before_read_docs)
    app.connect('doctree-read', event_doctree_read)
    app.connect('env-merge-info', event_env_merge_info)
    app.connect('env-updated', event_env_updated)
    app.connect('doctree-resolved', event_doctree_resolved)

    return dict(parallel_read_safe=True, version=version)
1136687
def setup(opts)
      missing_opts = REQ_OPTS.select { |o| !opts.has_key? o }
      raise ArgumentError, "Missing options: #{missing_opts.join(', ')}" unless missing_opts.empty?
      @service = opts[:service]
      @token = opts[:token]
      @logger = opts[:logger] || make_logger()
      @cld_ctrl_uri = http_uri(opts[:cloud_controller_uri])
      @provisioner = opts[:provisioner]
      @hb_interval = opts[:heartbeat_interval] || 60
      @node_timeout = opts[:node_timeout]
      @handle_fetch_interval = opts[:handle_fetch_interval] || 1
      @check_orphan_interval = opts[:check_orphan_interval] || -1
      @double_check_orphan_interval = opts[:double_check_orphan_interval] || 300
      @handle_fetched = opts[:handle_fetched] || false
      @fetching_handles = false
      @version_aliases = (service[:version_aliases] ||= {})

      opts[:gateway_name] ||= "Service Gateway"

      @cc_api_version = opts[:cc_api_version] || "v1"
      if @cc_api_version == "v1"
        require 'catalog_manager_v1'
        @catalog_manager = VCAP::Services::CatalogManagerV1.new(opts)
      elsif @cc_api_version == "v2"
        require 'catalog_manager_v2'
        @catalog_manager = VCAP::Services::CatalogManagerV2.new(opts)
      else
        raise "Unknown cc_api_version: #{@cc_api_version}"
      end

      @event_machine = opts[:event_machine] || EM

      # Setup heartbeats and exit handlers
      event_machine.add_periodic_timer(@hb_interval) { send_heartbeat }
      event_machine.next_tick { send_heartbeat }
      Kernel.at_exit do
        if event_machine.reactor_running?
          # :/ We can't stop others from killing the event-loop here. Let's hope that they play nice
          send_deactivation_notice(false)
        else
          event_machine.run { send_deactivation_notice }
        end
      end

      # Add any necessary handles we don't know about
      update_callback = Proc.new do |resp|
        @provisioner.update_handles(resp.handles)
        @handle_fetched = true
        event_machine.cancel_timer(@fetch_handle_timer)

        # TODO remove it when we finish the migration
        current_version = @version_aliases && @version_aliases[:current]
        if current_version
          @provisioner.update_version_info(current_version)
        else
          logger.info("No current version alias is supplied, skip update version in CCDB.")
        end
      end

      @fetch_handle_timer = event_machine.add_periodic_timer(@handle_fetch_interval) { fetch_handles(&update_callback) }
      event_machine.next_tick { fetch_handles(&update_callback) }

      if @check_orphan_interval > 0
        handler_check_orphan = Proc.new do |resp|
          check_orphan(resp.handles,
                       lambda { logger.info("Check orphan is requested") },
                       lambda { |errmsg| logger.error("Error on requesting to check orphan #{errmsg}") })
        end
        event_machine.add_periodic_timer(@check_orphan_interval) { fetch_handles(&handler_check_orphan) }
      end

      # Register update handle callback
      @provisioner.register_update_handle_callback { |handle, &blk| update_service_handle(handle, &blk) }
    end
911069
def _setup(self):
        
        # Expands ~user in queue
        if self.queue.path[0:1] == b'/':
            queue = self.queue
        else:
            if self.queue.path[0:1] == b'~':
                output = self.check_output('echo %s' %
                                           escape_queue(self.queue))
                queue = PosixPath(output.rstrip(b'\r\n'))
            else:
                output = self.check_output('pwd')
                queue = PosixPath(output.rstrip(b'\r\n')) / self.queue
            logger.debug("Resolved to %s", queue)

        # Select runtime
        if not self.setup_runtime:
            # Autoselect
            if self._call('which qsub', False)[0] == 0:
                logger.debug("qsub is available, using runtime 'pbs'")
                runtime = 'pbs'
            else:
                logger.debug("qsub not found, using runtime 'default'")
                runtime = 'default'
        else:
            runtime = self.setup_runtime

        if self.need_runtime is not None and runtime not in self.need_runtime:
            raise ValueError("About to setup runtime %s but that wouldn't "
                             "match explicitely allowed runtimes" % runtime)

        logger.info("Installing runtime %s%s at %s",
                    runtime,
                    "" if self.setup_runtime else " (auto)",
                    self.queue)

        # Uploads runtime
        scp_client = self.get_scp_client()
        filename = pkg_resources.resource_filename('tej',
                                                   'remotes/%s' % runtime)
        scp_client.put(filename, str(queue), recursive=True)
        logger.debug("Files uploaded")

        # Runs post-setup script
        self.check_call('/bin/sh %s' % shell_escape(queue / 'commands/setup'))
        logger.debug("Post-setup script done")

        self._queue = queue
        return queue
397755
def first_time_setup(self):
        
        if not self._auto_unlock_key_position():
            pw  = password.create_passwords()[0]
            attrs = {'application': self.keyring}
            gkr.item_create_sync(self.default_keyring
                                ,gkr.ITEM_GENERIC_SECRET
                                ,self.keyring
                                ,attrs
                                ,pw
                                ,True)
        found_pos = self._auto_unlock_key_position()
        item_info = gkr.item_get_info_sync(self.default_keyring, found_pos)
        gkr.create_sync(self.keyring, item_info.get_secret())
987740
def setup(basepath=DEFAULT_BASEPATH):
    """"""

    module_version = os.environ.get('MODULE_VERSION', DEFAULT_VERSION)
    moduleshome = os.path.join(basepath, module_version)

    # Abort if MODULESHOME does not exist
    if not os.path.isdir(moduleshome):
        print('payu: warning: MODULESHOME does not exist; disabling '
              'environment modules.')
        os.environ['MODULESHOME'] = ''
        return

    os.environ['MODULE_VERSION'] = module_version
    os.environ['MODULE_VERSION_STACK'] = module_version
    os.environ['MODULESHOME'] = moduleshome

    if 'MODULEPATH' not in os.environ:
        module_initpath = os.path.join(moduleshome, 'init', '.modulespath')
        with open(module_initpath) as initpaths:
            modpaths = [
                line.partition('#')[0].strip()
                for line in initpaths.readlines() if not line.startswith('#')
            ]

        os.environ['MODULEPATH'] = ':'.join(modpaths)

    os.environ['LOADEDMODULES'] = os.environ.get('LOADEDMODULES', '')

    # Environment modules with certain characters will cause corruption
    # when MPI jobs get launched on other nodes (possibly a PBS issue).
    #
    # Bash processes obscure the issue on Raijin, since it occurs in an
    # environment module function, and bash moves those to the end of
    # the environment variable list.
    #
    # Raijin's mpirun wrapper is a bash script, and therefore "fixes" by doing
    # the shuffle and limiting the damage to other bash functions, but some
    # wrappers (e.g. OpenMPI 2.1.x) may not be present.  So we manually patch
    # the problematic variable here.  But a more general solution would be nice
    # someday.

    if 'BASH_FUNC_module()' in os.environ:
        bash_func_module = os.environ['BASH_FUNC_module()']
        os.environ['BASH_FUNC_module()'] = bash_func_module.replace('\n', ';')
739977
def generate_setup_py(target, source, env):
    """"""

    tile = env['TILE']
    data = {}

    entry_points = {}

    for _mod, import_string, entry_point in iter_python_modules(tile):
        if entry_point not in entry_points:
            entry_points[entry_point] = []

        entry_points[entry_point].append(import_string)

    data['name'] = tile.support_distribution
    data['package'] = tile.support_distribution
    data['version'] = tile.parsed_version.pep440_string()
    data['deps'] = ["{0} {1}".format(x.support_distribution, x.parsed_version.pep440_compatibility_specifier())
                    for x in _iter_dependencies(tile) if x.has_wheel]

    # If there are some python packages needed, we add them to the list of dependencies required
    if tile.support_wheel_depends:
        data['deps'] += tile.support_wheel_depends

    data['entry_points'] = entry_points

    outdir = os.path.dirname(str(target[0]))

    render_template('setup.py.tpl', data, out_path=str(target[0]))

    # Run setuptools to generate a wheel and an sdist
    curr = os.getcwd()
    os.chdir(outdir)
    try:
        setuptools.sandbox.run_setup('setup.py', ['-q', 'clean', 'sdist'])
        if "python_universal" in tile.settings:
            setuptools.sandbox.run_setup('setup.py', ['-q', 'clean', 'bdist_wheel', '--universal'])
        else:
            setuptools.sandbox.run_setup('setup.py', ['-q', 'clean', 'bdist_wheel'])
    finally:
        os.chdir(curr)
776975
def update_portal(self, portal_obj):
        
        headers = {
                'User-Agent': self.user_agent(),
        }
        headers.update(self.headers())

        r = requests.put(   self.portals_url()+'/portals/'+self.portal_id(), 
                            data=json.dumps(portal_obj),
                            headers=headers,
                            auth=self.auth())
        if HTTP_STATUS.OK == r.status_code:
            return r.json()
        else:
            print("update_portal: Something went wrong: <{0}>: {1}".format(
                        r.status_code, r.reason))
            r.raise_for_status()
346640
def setup(app):
    """"""
    app.setup_extension('nbsphinx')
    app.add_source_suffix('.nblink', 'linked_jupyter_notebook')
    app.add_source_parser(LinkedNotebookParser)
    app.add_config_value('nbsphinx_link_target_root', None, rebuild='env')

    return {'version': __version__, 'parallel_read_safe': True}