Creates a new Profile
546851
public function createAction()
    {
        if ($this->request->isPost()) {

            $profile = new Profiles([
                'name' => $this->request->getPost('name', 'striptags'),
                'active' => $this->request->getPost('active')
            ]);

            if (!$profile->save()) {
                $this->flash->error($profile->getMessages());
            } else {
                $this->flash->success("Profile was created successfully");
            }

            Tag::resetInput();
        }

        $this->view->form = new ProfilesForm(null);
    }
1233018
def create(name, profile="splunk", **kwargs):
    '''
    
    '''
    client = _get_splunk(profile)
    search = client.saved_searches.create(name, **kwargs)

    # use the REST API to set owner and permissions
    # this is hard-coded for now; all managed searches are app scope and
    # readable by all
    config = __salt__['config.option'](profile)
    url = "https://{0}:{1}".format(config.get('host'), config.get('port'))
    auth = (config.get('username'), config.get('password'))
    data = {
        "owner": config.get("username"),
        "sharing": "app",
        "perms.read": "*",
    }
    _req_url = "{0}/servicesNS/{1}/search/saved/searches/{2}/acl".format(
        url, config.get("username"), urllib.quote(name)
    )
    requests.post(_req_url, auth=auth, verify=True, data=data)
    return _get_splunk_search_props(search)
118937
def addProfile(self, profile):
        
        # use the existing version
        for exist in self.profiles():
            if exist.name() == profile.name():
                if exist.version() < profile.version():
                    exist.setProfile(profile)
                
                return
        
        # otherwise create a new profile 
        act = XViewProfileAction(profile, self)
        self._profileGroup.addAction(act)
        self.addAction(act)
        return act
249305
def create_profiles(self, prefix, weeks, ip_user=False):
        """"""
        # Future: Add a time range in weeks for how long a user is considered
        #         as the same user.

        # Count accessed records
        record_counter = {}
        for year, week in weeks:
            file = self.storage.get(prefix, year, week)
            self.count_records(record_counter, file)

        # TODO: Statistics, count records
        print("Records read all: {}".format(self.stat))

        # Filter records with to less/much views.
        records_valid = self.filter_counter(record_counter)

        # Create user profiles
        profiles = defaultdict(list)
        for year, week in weeks:
            file = self.storage.get(prefix, year, week)
            self._create_user_profiles(profiles, file, records_valid, ip_user,
                                       year, week)

        return profiles
96558
def profile(self, username):
        """"""
        if not username and g.user:
            username = g.user.username

        payload = {
            'user': bootstrap_user_data(username, include_perms=True),
            'common': self.common_bootsrap_payload(),
        }

        return self.render_template(
            'superset/basic.html',
            title=_("%(user)s's profile", user=username),
            entry='profile',
            bootstrap_data=json.dumps(payload, default=utils.json_iso_dttm_ser),
        )
863609
def create_user_profile(sender, instance, created, **kwargs):
    """"""
    if created:
        profile = UserProfile.objects.get_or_create(user=instance)[0]
        profile.hash_pass = create_htpasswd(instance.hash_pass)
        profile.save()
    else:
        # update password
        try:
            up = UserProfile.objects.get(user=instance.id)
            up.hash_pass = create_htpasswd(instance.hash_pass)
            up.save()
        except AttributeError:
            pass
153148
def create(config_file, profile):
    """"""

    # determine the config file path
    if config_file:
        click.echo("Using configuration file: {}".format(config_file))
    else:
        # path not given, try to detect; or use default, but allow user to override
        config_file = get_configfile_path()
        if config_file:
            click.echo("Found existing configuration file: {}".format(config_file))
        else:
            config_file = get_default_configfile_path()
            click.echo("Configuration file not found; the default location is: {}".format(config_file))
        config_file = default_text_input("Configuration file path", config_file)
        config_file = os.path.expanduser(config_file)

    # create config_file path
    config_base = os.path.dirname(config_file)
    if config_base and not os.path.exists(config_base):
        if click.confirm("Configuration file path does not exist. Create it?", abort=True):
            try:
                os.makedirs(config_base)
            except Exception as e:
                click.echo("Error creating configuration path: {}".format(e))
                return 1

    # try loading existing config, or use defaults
    try:
        config = load_config_from_files([config_file])
    except:
        config = get_default_config()

    # determine profile
    if profile:
        click.echo("Using profile: {}".format(profile))
    else:
        existing = config.sections()
        if existing:
            profiles = 'create new or choose from: {}'.format(', '.join(existing))
            default_profile = ''
        else:
            profiles = 'create new'
            default_profile = 'prod'
        profile = default_text_input("Profile (%s)" % profiles, default_profile, optional=False)

    if not config.has_section(profile):
        config.add_section(profile)

    # fill out the profile variables
    variables = 'endpoint token client solver proxy'.split()
    prompts = ['API endpoint URL',
               'Authentication token',
               'Default client class (qpu or sw)',
               'Default solver']
    for var, prompt in zip(variables, prompts):
        default_val = config.get(profile, var, fallback=None)
        val = default_text_input(prompt, default_val)
        if val:
            val = os.path.expandvars(val)
        if val != default_val:
            config.set(profile, var, val)

    try:
        with open(config_file, 'w') as fp:
            config.write(fp)
    except Exception as e:
        click.echo("Error writing to configuration file: {}".format(e))
        return 2

    click.echo("Configuration saved.")
    return 0
126227
def save_profile_id(self, profile: Profile):
        
        os.makedirs(self.dirname_pattern.format(profile=profile.username,
                                                target=profile.username), exist_ok=True)
        with open(self._get_id_filename(profile.username), 'w') as text_file:
            text_file.write(str(profile.userid) + "\n")
            self.context.log("Stored ID {0} for profile {1}.".format(profile.userid, profile.username))
419246
public function createProfile($id, array $policies, array $options = [])
    {
        $action = 'createProfile';
        $data = [
            '_id' => $id,
            'body' => [ 'policies' => $policies ]
        ];

        if (array_key_exists('replaceIfExist', $options)) {
            $action = 'createOrReplaceProfile';
        }

        $response = $this->kuzzle->query(
            $this->buildQueryArgs($action),
            $data,
            $options
        );

        return new Profile($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']);
    }
958248
def profile
      unless @profile
        if associated_profile
          @profile = Profile.new(associated_profile)
        else
          options = {:fields => 'user_id', :includes => 'Profile'}
          options = options.merge(:access_token => token, :access_secret => secret) if (token && secret)
          tmp = User.find(username, options)
          @profile = Profile.new(tmp.associated_profile)
        end
      end
      @profile
    end
120570
def update_profile(self, about_me=None, display_name=None, email=None, first_name=None, gender=None, last_name=None,
                       mobile_number=None, relationship_status=None, title=None, where_am_i=None,
                       scope='profile/write'):
        

        data = {}
        if about_me:
            data['AboutMe'] = about_me
        if display_name:
            data['DisplayName'] = display_name
        if email:
            data['Email'] = email
        if first_name:
            data['FirstName'] = first_name
        if gender:
            data['Gender'] = gender
        if last_name:
            data['LastName'] = last_name
        if mobile_number:
            data['MobileNumber'] = mobile_number
        if relationship_status:
            data['RelationshipStatus'] = relationship_status
        if title:
            data['Title'] = title
        if where_am_i:
            data['WhereAmI'] = where_am_i

        if data:
            _put(
                token=self.oauth.get_user_token(scope),
                uri='/user/profile',
                data=data
            )
1039462
public function create($profileData = array(), $applicationData = array(), $serverData = array())
    {
        $profile = Profile::create();
        $profile->setProfileData($profileData);
        $profile->setApplicationData($applicationData);
        $profile->setServerData($serverData);

        return $profile;
    }
1330824
def load(self, profile_args):
        
        for key, value in profile_args.items():
            self.add(key, value)
864159
def fromProfile(cls, profile):
        
        session = bones.SessionAPI.fromProfile(profile)
        return cls(session)
624475
def profile_update(request, template="accounts/account_profile_update.html",
                   extra_context=None):
    
    profile_form = get_profile_form()
    form = profile_form(request.POST or None, request.FILES or None,
                        instance=request.user)
    if request.method == "POST" and form.is_valid():
        user = form.save()
        info(request, _("Profile updated"))
        try:
            return redirect("profile", username=user.username)
        except NoReverseMatch:
            return redirect("profile_update")
    context = {"form": form, "title": _("Update Profile")}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
199120
def createKmerProfile(self, k, profileCsvFN):
        '''
        
        '''
        searches = [('', 0, self.bwt.shape[0])]
        normTotal = 0
        lines = []
        while len(searches) > 0:
            (seq, start, end) = searches.pop(0)
            
            if len(seq) == k:
                lines.append(seq+','+str(end-start))
                normTotal += (end-start)**2
            else:
                nls = self.getFullFMAtIndex(start)
                nhs = self.getFullFMAtIndex(end)
                for c in xrange(self.vcLen-1, -1, -1):
                    if nls[c] == nhs[c]:
                        #do nothing
                        pass
                    else:
                        newSeq = self.numToChar[c]+seq
                        searches.insert(0, (newSeq, int(nls[c]), int(nhs[c])))
        
        fp = open(profileCsvFN, 'w+')
        fp.write('total,'+str(math.sqrt(normTotal))+'\n')
        for l in sorted(lines):
            fp.write(l+'\n')
        fp.close()
1300043
public ApplyProfile createDefaultProfile(String profileType, String profileTypeName, Profile profile) throws RuntimeFault, RemoteException {
        return getVimService().createDefaultProfile(getMOR(), profileType, profileTypeName,
            profile == null ? null : profile.getMOR());
    }