(self, with_media=False, build_profile_id=None, download_target_version=False)
Returns a QR code, as a PNG to install on CC-ODK
Returns a QR code, as a PNG to install on CC-ODK
Returns a QR code as a PNG to install on CC - ODK
def get_odk_qr_code(self, with_media=False, build_profile_id=None, download_target_version=False):
        """Returns a QR code, as a PNG to install on CC-ODK"""
        filename = 'qrcode.png' if not download_target_version else 'qrcode-targeted.png'
        try:
            return self.lazy_fetch_attachment(filename)
        except ResourceNotFound:
            url = self.odk_profile_url if not with_media else self.odk_media_profile_url
            kwargs = []
            if build_profile_id is not None:
                kwargs.append('profile={profile_id}'.format(profile_id=build_profile_id))
            if download_target_version:
                kwargs.append('download_target_version=true')
            url += '?' + '&'.join(kwargs)

            image = qrcode.make(url)
            output = BytesIO()
            image.save(output, "PNG")
            qr_content = output.getvalue()
            self.lazy_put_attachment(qr_content, filename,
                                     content_type="image/png")
            return qr_content
def get_odk_qr_code ( self , with_media = False , build_profile_id = None , download_target_version = False ) : filename = 'qrcode.png' if not download_target_version else 'qrcode-targeted.png' try : return self . lazy_fetch_attachment ( filename ) except ResourceNotFound : url = self . odk_profile_url if not with_media else self . odk_media_profile_url kwargs = [ ] if build_profile_id is not None : kwargs . append ( 'profile={profile_id}' . format ( profile_id = build_profile_id ) ) if download_target_version : kwargs . append ( 'download_target_version=true' ) url += '?' + '&' . join ( kwargs ) image = qrcode . make ( url ) output = BytesIO ( ) image . save ( output , "PNG" ) qr_content = output . getvalue ( ) self . lazy_put_attachment ( qr_content , filename , content_type = "image/png" ) return qr_content