Download the profile picture
14271
def pic_path
      if picture
        # Get path
        dir = "public/uploads/pictures/"
        full_path = dir+picture.split("/").last.chomp.strip

        # Get file
        `wget -P #{dir} #{picture}` if !File.file?(full_path)
        return full_path
      end
    end
674249
private static String checkProfilePicturePath(
			final FormItemList formItemList,
			final CreateUserResponse createUserResponse) {
		final String profilePicturePath = formItemList
				.getField(ProtocolConstants.Parameters.Create.User.PROFILE_PICTURE_PATH);
		if (profilePicturePath != null) {
			return profilePicturePath;
		} else {
			createUserResponse.profilePicturePathMissing();
		}

		return null;
	}
1051527
def profile():
    """"""
    # Create forms
    verification_form = VerificationForm(formdata=None, prefix="verification")
    profile_form = profile_form_factory()

    # Process forms
    form = request.form.get('submit', None)
    if form == 'profile':
        handle_profile_form(profile_form)
    elif form == 'verification':
        handle_verification_form(verification_form)

    return render_template(
        current_app.config['USERPROFILES_PROFILE_TEMPLATE'],
        profile_form=profile_form,
        verification_form=verification_form,)
767379
def takeSnapshot(self, reconnect=False):
        '''
        
        '''

        if PROFILE:
            profileStart()

        global PIL_AVAILABLE
        if not PIL_AVAILABLE:
            try:
                global Image
                from PIL import Image
                PIL_AVAILABLE = True
            except:
                raise Exception("You have to install PIL to use takeSnapshot()")

        sdk_version = self.getSdkVersion()
        USE_ADB_FRAMEBUFFER_METHOD = (sdk_version < 14 or sdk_version >= 23)
        if USE_ADB_FRAMEBUFFER_METHOD:
            self.__checkTransport()

            self.__send('framebuffer:', checkok=True, reconnect=False)
            # case 1: // version
            #           return 12; // bpp, size, width, height, 4*(length, offset)
            # case 2: // version
            #           return 13; // bpp, colorSpace, size, width, height, 4*(length, offset)
            # let's assume version==1 and change later if it's not
            received = self.__receive(1 * 4 + 12 * 4)
            (version, bpp, size, width, height, roffset, rlen, boffset, blen, goffset, glen, aoffset, alen) = \
                struct.unpack('<' + 'L' * 13, received)
            if version == 2:
                # receive one more
                received += self.__receive(4)
                (version, bpp, colorspace, size, width, height, roffset, rlen, boffset, blen, goffset, glen, aoffset,
                 alen) = struct.unpack('<' + 'L' * 14, received)
            if DEBUG:
                if version == 1:
                    print >> sys.stderr, "    takeSnapshot:", (
                        version, bpp, size, width, height, roffset, rlen, boffset, blen, goffset, glen, aoffset, alen)
                elif version == 2:
                    print >> sys.stderr, "    takeSnapshot:", (
                        version, bpp, colorspace, width, height, roffset, rlen, boffset, blen, goffset, glen, aoffset,
                        alen)
                else:
                    print >> sys.stderr, "    takeSnapshot: unknown version", version

            offsets = {roffset: 'R', goffset: 'G', boffset: 'B'}
            if bpp == 32:
                if alen != 0:
                    offsets[aoffset] = 'A'
                else:
                    warnings.warn('''framebuffer is specified as 32bpp but alpha length is 0''')
            argMode = ''.join([offsets[o] for o in sorted(offsets)])
            if DEBUG:
                if version == 1:
                    print >> sys.stderr, "    takeSnapshot:", (
                        version, bpp, size, width, height, roffset, rlen, boffset, blen, goffset, blen, aoffset, alen,
                        argMode)
                elif version == 2:
                    print >> sys.stderr, "    takeSnapshot:", (
                        version, bpp, colorspace, size, width, height, roffset, rlen, boffset, blen, goffset, blen,
                        aoffset, alen,
                        argMode)

            if argMode == 'BGRA':
                argMode = 'RGBA'
            if bpp == 16:
                mode = 'RGB'
                argMode += ';16'
            else:
                mode = argMode
            self.__send('\0', checkok=False, reconnect=False)
            if DEBUG:
                print >> sys.stderr, "    takeSnapshot: reading %d bytes" % size
            received = self.__receive(size)
            if reconnect:
                self.socket = AdbClient.connect(self.hostname, self.port, self.timeout)
                self.__setTransport()
            if DEBUG:
                print >> sys.stderr, "    takeSnapshot: Image.frombuffer(%s, %s, %s, %s, %s, %s, %s)" % (
                    mode, (width, height), 'data', 'raw', argMode, 0, 1)
            image = Image.frombuffer(mode, (width, height), received, 'raw', argMode, 0, 1)
        else:
            # ALTERNATIVE_METHOD: screencap
            received = self.shell('/system/bin/screencap -p').replace("\r\n", "\n")
            if not received:
                raise RuntimeError('"/system/bin/screencap -p" result was empty')
            stream = StringIO.StringIO(received)
            try:
                image = Image.open(stream)
            except IOError, ex:
                print >> sys.stderr, ex
                print >> sys.stderr, repr(stream)
                print >> sys.stderr, repr(received)
                raise RuntimeError('Cannot convert stream to image: ' + ex.message)

        # Just in case let's get the real image size
        (w, h) = image.size
        if w == self.display['height'] and h == self.display['width']:
            # FIXME: We are not catching the 180 degrees rotation here
            if 'orientation' in self.display:
                r = (0, 90, 180, -90)[self.display['orientation']]
            else:
                r = 90
            image = image.rotate(r, expand=1).resize((h, w))

        if PROFILE:
            profileEnd()
        return image
947190
def upload_profile_avatar filename
      # The Marketing API should be enabled for the APP to use this feature
      # A publish_pages permission is required.
      raise_not_provided_error unless switch_to_page

      media_info = page_client.put_picture filename
      picture_url = page_client.get_picture_data(media_info['id'])['data']['url']
      page_client.put_connections('me', 'picture', { picture: picture_url })
    end
63051
def generate_img_id(profile, ext=None, label=None, tmp=False):
    
    if ext and not ext.startswith('.'):
        ext = '.' + ext
    if label:
        label = re.sub(r'[^a-z0-9_\-]', '', label, flags=re.I)
        label = re.sub(r'_+', '_', label)
        label = label[:60]
    return '{profile}:{tmp}{dtstr}_{rand}{label}{ext}'.format(
        profile=profile,
        tmp=(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX if tmp else ''),
        dtstr=datetime_to_dtstr(),
        rand=get_random_string(4, 'abcdefghijklmnopqrstuvwxyz0123456789'),
        label=(('_' + label) if label else ''),
        ext=(ext or ''),
    )
377835
def save_profile(self, **params):
        
        image = self.get_image()
        if (image is None):
            return

        profile = image.get('profile', None)
        if profile is None:
            # If image has no profile then create one
            profile = Settings.SettingGroup()
            image.set(profile=profile)

        self.logger.debug("saving to image profile: params=%s" % (
            str(params)))
        profile.set(**params)
        return profile
874395
def image_list(name=None, profile=None, **kwargs):
    '''
    
    '''
    conn = _auth(profile, **kwargs)
    return conn.image_list(name)
1347876
def get_person_from_legacy_format(profile_record):
    

    if not is_profile_in_legacy_format(profile_record):
        raise ValueError("Not a legacy profile")

    profile = profile_record

    try:
        profile = json.loads(json.dumps(profile))
    except ValueError:
        pass

    images = []
    accounts = []
    profile_data = {
        "@type": "Person"
    }

    if profile.has_key("name") and type(profile["name"]) == dict \
            and profile["name"].has_key("formatted"):
        profile_data["name"] = profile["name"]["formatted"]

    if profile.has_key("bio"):
        profile_data["description"] = profile["bio"]

    if profile.has_key("location") and type(profile["location"]) == dict \
            and profile["location"].has_key("formatted"):
        profile_data["address"] = {
            "@type": "PostalAddress",
            "addressLocality": profile["location"]["formatted"]
        }

    if profile.has_key("avatar") and type(profile["avatar"]) == dict and \
            profile["avatar"].has_key("url"):
        images.append({
            "@type": "ImageObject",
            "name": "avatar",
            "contentUrl": profile["avatar"]["url"]
        })

    if profile.has_key("cover") and type(profile["cover"]) == dict and \
            profile["cover"].has_key("url"):
        images.append({
            "@type": "ImageObject",
            "name": "cover",
            "contentUrl": profile["cover"]["url"]
        })

    if len(images) > 0:
        profile_data["image"] = images

    if profile.has_key("website") and type(profile["website"]) in [str, unicode]:
        profile_data["website"] = [{
            "@type": "WebSite",
            "url": profile["website"]
        }]

    for service_name in ["twitter", "facebook", "github"]:
        if profile.has_key(service_name):
            accounts.append(
                format_account(service_name, profile[service_name])
            )

    if profile.has_key("bitcoin") and type(profile["bitcoin"]) == dict and \
            profile["bitcoin"].has_key("address"):
        accounts.append({
            "@type": "Account",
            "role": "payment",
            "service": "bitcoin",
            "identifier": profile["bitcoin"]["address"]
        })

    if profile.has_key("auth"):
        if len(profile["auth"]) > 0 and type(profile["auth"]) == dict:
            if profile["auth"][0].has_key("publicKeychain"):
                accounts.append({
                    "@type": "Account",
                    "role": "key",
                    "service": "bip32",
                    "identifier": profile["auth"][0]["publicKeychain"]
                })

    if profile.has_key("pgp") and type(profile["pgp"]) == dict \
            and profile["pgp"].has_key("url") \
            and profile["pgp"].has_key("fingerprint"):
        accounts.append({
            "@type": "Account",
            "role": "key",
            "service": "pgp",
            "identifier": profile["pgp"]["fingerprint"],
            "contentUrl": profile["pgp"]["url"]
        })

    profile_data["account"] = accounts 

    return profile_data
1259154
def saveProfileAs( self ):
        
        name, ok = QInputDialog.getText(self, 'Create Profile', 'Name:')
        if ( not name ):
            return
        
        manager = self.parent()
        prof    = manager.viewWidget().saveProfile()
        prof.setName(nativestring(name))
        self.parent().addProfile(prof)
256529
public function sendRemoveProfilePicture()
    {
        $msgId = $this->createIqId();

        $picture = new ProtocolNode('picture', null, null, null);

        $thumb = new ProtocolNode('picture',
            [
                'type' => 'preview',
            ], null, null);

        $node = new ProtocolNode('iq',
            [
                'id'    => $msgId,
                'to'    => $this->getJID($this->phoneNumber),
                'type'  => 'set',
                'xmlns' => 'w:profile:picture',
            ], [$picture, $thumb], null);

        $this->sendNode($node);
    }
374459
def __profile_file(self):
        """"""
        self.line_profiler = pprofile.Profile()
        self.line_profiler.runfile(
            open(self.pyfile.path, "r"), {}, self.pyfile.path
        )
995306
async def _download_photo(self, photo, file, date, thumb, progress_callback):
        """"""
        # Determine the photo and its largest size
        if isinstance(photo, types.MessageMediaPhoto):
            photo = photo.photo
        if not isinstance(photo, types.Photo):
            return

        size = self._get_thumb(photo.sizes, thumb)
        if not size or isinstance(size, types.PhotoSizeEmpty):
            return

        file = self._get_proper_filename(file, 'photo', '.jpg', date=date)
        if isinstance(size, (types.PhotoCachedSize, types.PhotoStrippedSize)):
            return self._download_cached_photo_size(size, file)

        result = await self.download_file(
            types.InputPhotoFileLocation(
                id=photo.id,
                access_hash=photo.access_hash,
                file_reference=photo.file_reference,
                thumb_size=size.type
            ),
            file,
            file_size=size.size,
            progress_callback=progress_callback
        )
        return result if file is bytes else file
271065
def get_profile(self):
        
        r = self._session.get(API_URL + "/logins/me")
        r.raise_for_status()

        return r.json()
769682
def get_avatar_upload_to(self, filename):
        
        dummy, ext = os.path.splitext(filename)
        return os.path.join(
            machina_settings.PROFILE_AVATAR_UPLOAD_TO,
            '{id}{ext}'.format(id=str(uuid.uuid4()).replace('-', ''), ext=ext),
        )
1253788
def photos(self):
        """"""
        # Reverse because pictures appear in inverse chronological order.
        for photo_info in self.dest_user.profile.photo_infos:
            self.dest_user.photo.delete(photo_info)
        return [self.dest_user.photo.upload_and_confirm(info)
                for info in reversed(self.source_profile.photo_infos)]
1358105
def setProfile( self, profile ):
        
        self._profile = profile
        
        if not profile:
            self.uiNameTXT.setText('')
            self.uiVersionSPN.setValue(1.0)
            self.uiDescriptionTXT.setText('')
            self.uiIconBTN.setFilepath(resources.find('img/profile_48.png'))
        else:
            self.uiNameTXT.setText(profile.name())
            self.uiVersionSPN.setValue(profile.version())
            self.uiDescriptionTXT.setText(profile.description())
            
            filepath = profile.icon()
            if ( not filepath ):
                filepath = resources.find('img/profile_48.png')
            self.uiIconBTN.setFilepath(filepath)